// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.
use crate::datadog;
use async_stream::try_stream;
use flate2::{
write::{GzEncoder, ZlibEncoder},
Compression,
};
use futures_core::stream::Stream;
use log::warn;
use reqwest::header::{HeaderMap, HeaderValue};
use serde::{Deserialize, Serialize};
use std::io::Write;
/// GetFindingOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_finding`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct GetFindingOptionalParams {
/// Return the finding for a given snapshot of time (Unix ms).
pub snapshot_timestamp: Option<i64>,
}
impl GetFindingOptionalParams {
/// Return the finding for a given snapshot of time (Unix ms).
pub fn snapshot_timestamp(mut self, value: i64) -> Self {
self.snapshot_timestamp = Some(value);
self
}
}
/// GetResourceEvaluationFiltersOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_resource_evaluation_filters`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct GetResourceEvaluationFiltersOptionalParams {
/// Filter resource filters by cloud provider (e.g. aws, gcp, azure).
pub cloud_provider: Option<String>,
/// Filter resource filters by cloud provider account ID. This parameter is only valid when provider is specified.
pub account_id: Option<String>,
/// Skip cache for resource filters.
pub skip_cache: Option<bool>,
}
impl GetResourceEvaluationFiltersOptionalParams {
/// Filter resource filters by cloud provider (e.g. aws, gcp, azure).
pub fn cloud_provider(mut self, value: String) -> Self {
self.cloud_provider = Some(value);
self
}
/// Filter resource filters by cloud provider account ID. This parameter is only valid when provider is specified.
pub fn account_id(mut self, value: String) -> Self {
self.account_id = Some(value);
self
}
/// Skip cache for resource filters.
pub fn skip_cache(mut self, value: bool) -> Self {
self.skip_cache = Some(value);
self
}
}
/// GetRuleVersionHistoryOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_rule_version_history`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct GetRuleVersionHistoryOptionalParams {
/// Size for a given page. The maximum allowed value is 100.
pub page_size: Option<i64>,
/// Specific page number to return.
pub page_number: Option<i64>,
}
impl GetRuleVersionHistoryOptionalParams {
/// Size for a given page. The maximum allowed value is 100.
pub fn page_size(mut self, value: i64) -> Self {
self.page_size = Some(value);
self
}
/// Specific page number to return.
pub fn page_number(mut self, value: i64) -> Self {
self.page_number = Some(value);
self
}
}
/// GetSBOMOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_sbom`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct GetSBOMOptionalParams {
/// The container image `repo_digest` for the SBOM request. When the requested asset type is 'Image', this filter is mandatory.
pub filter_repo_digest: Option<String>,
/// The standard of the SBOM.
pub ext_format: Option<crate::datadogV2::model::SBOMFormat>,
}
impl GetSBOMOptionalParams {
/// The container image `repo_digest` for the SBOM request. When the requested asset type is 'Image', this filter is mandatory.
pub fn filter_repo_digest(mut self, value: String) -> Self {
self.filter_repo_digest = Some(value);
self
}
/// The standard of the SBOM.
pub fn ext_format(mut self, value: crate::datadogV2::model::SBOMFormat) -> Self {
self.ext_format = Some(value);
self
}
}
/// GetSecurityMonitoringHistsignalsByJobIdOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_security_monitoring_histsignals_by_job_id`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct GetSecurityMonitoringHistsignalsByJobIdOptionalParams {
/// The search query for security signals.
pub filter_query: Option<String>,
/// The minimum timestamp for requested security signals.
pub filter_from: Option<chrono::DateTime<chrono::Utc>>,
/// The maximum timestamp for requested security signals.
pub filter_to: Option<chrono::DateTime<chrono::Utc>>,
/// The order of the security signals in results.
pub sort: Option<crate::datadogV2::model::SecurityMonitoringSignalsSort>,
/// A list of results using the cursor provided in the previous query.
pub page_cursor: Option<String>,
/// The maximum number of security signals in the response.
pub page_limit: Option<i32>,
}
impl GetSecurityMonitoringHistsignalsByJobIdOptionalParams {
/// The search query for security signals.
pub fn filter_query(mut self, value: String) -> Self {
self.filter_query = Some(value);
self
}
/// The minimum timestamp for requested security signals.
pub fn filter_from(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
self.filter_from = Some(value);
self
}
/// The maximum timestamp for requested security signals.
pub fn filter_to(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
self.filter_to = Some(value);
self
}
/// The order of the security signals in results.
pub fn sort(mut self, value: crate::datadogV2::model::SecurityMonitoringSignalsSort) -> Self {
self.sort = Some(value);
self
}
/// A list of results using the cursor provided in the previous query.
pub fn page_cursor(mut self, value: String) -> Self {
self.page_cursor = Some(value);
self
}
/// The maximum number of security signals in the response.
pub fn page_limit(mut self, value: i32) -> Self {
self.page_limit = Some(value);
self
}
}
/// GetSuppressionVersionHistoryOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_suppression_version_history`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct GetSuppressionVersionHistoryOptionalParams {
/// Size for a given page. The maximum allowed value is 100.
pub page_size: Option<i64>,
/// Specific page number to return.
pub page_number: Option<i64>,
}
impl GetSuppressionVersionHistoryOptionalParams {
/// Size for a given page. The maximum allowed value is 100.
pub fn page_size(mut self, value: i64) -> Self {
self.page_size = Some(value);
self
}
/// Specific page number to return.
pub fn page_number(mut self, value: i64) -> Self {
self.page_number = Some(value);
self
}
}
/// ListAssetsSBOMsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_assets_sbo_ms`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListAssetsSBOMsOptionalParams {
/// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
pub page_token: Option<String>,
/// The page number to be retrieved. It should be equal to or greater than 1.
pub page_number: Option<i64>,
/// The type of the assets for the SBOM request.
pub filter_asset_type: Option<crate::datadogV2::model::AssetType>,
/// The name of the asset for the SBOM request.
pub filter_asset_name: Option<String>,
/// The name of the component that is a dependency of an asset.
pub filter_package_name: Option<String>,
/// The version of the component that is a dependency of an asset.
pub filter_package_version: Option<String>,
/// The software license name of the component that is a dependency of an asset.
pub filter_license_name: Option<String>,
/// The software license type of the component that is a dependency of an asset.
pub filter_license_type: Option<crate::datadogV2::model::SBOMComponentLicenseType>,
}
impl ListAssetsSBOMsOptionalParams {
/// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
pub fn page_token(mut self, value: String) -> Self {
self.page_token = Some(value);
self
}
/// The page number to be retrieved. It should be equal to or greater than 1.
pub fn page_number(mut self, value: i64) -> Self {
self.page_number = Some(value);
self
}
/// The type of the assets for the SBOM request.
pub fn filter_asset_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
self.filter_asset_type = Some(value);
self
}
/// The name of the asset for the SBOM request.
pub fn filter_asset_name(mut self, value: String) -> Self {
self.filter_asset_name = Some(value);
self
}
/// The name of the component that is a dependency of an asset.
pub fn filter_package_name(mut self, value: String) -> Self {
self.filter_package_name = Some(value);
self
}
/// The version of the component that is a dependency of an asset.
pub fn filter_package_version(mut self, value: String) -> Self {
self.filter_package_version = Some(value);
self
}
/// The software license name of the component that is a dependency of an asset.
pub fn filter_license_name(mut self, value: String) -> Self {
self.filter_license_name = Some(value);
self
}
/// The software license type of the component that is a dependency of an asset.
pub fn filter_license_type(
mut self,
value: crate::datadogV2::model::SBOMComponentLicenseType,
) -> Self {
self.filter_license_type = Some(value);
self
}
}
/// ListFindingsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_findings`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListFindingsOptionalParams {
/// Limit the number of findings returned. Must be <= 1000.
pub page_limit: Option<i64>,
/// Return findings for a given snapshot of time (Unix ms).
pub snapshot_timestamp: Option<i64>,
/// Return the next page of findings pointed to by the cursor.
pub page_cursor: Option<String>,
/// Return findings that have these associated tags (repeatable).
pub filter_tags: Option<String>,
/// Return findings that have changed from pass to fail or vice versa on a specified date (Unix ms) or date range (using comparison operators).
pub filter_evaluation_changed_at: Option<String>,
/// Set to `true` to return findings that are muted. Set to `false` to return unmuted findings.
pub filter_muted: Option<bool>,
/// Return findings for the specified rule ID.
pub filter_rule_id: Option<String>,
/// Return findings for the specified rule.
pub filter_rule_name: Option<String>,
/// Return only findings for the specified resource type.
pub filter_resource_type: Option<String>,
/// Return only findings for the specified resource id.
pub filter_resource_id: Option<String>,
/// Return findings that were found on a specified date (Unix ms) or date range (using comparison operators).
pub filter_discovery_timestamp: Option<String>,
/// Return only `pass` or `fail` findings.
pub filter_evaluation: Option<crate::datadogV2::model::FindingEvaluation>,
/// Return only findings with the specified status.
pub filter_status: Option<crate::datadogV2::model::FindingStatus>,
/// Return findings that match the selected vulnerability types (repeatable).
pub filter_vulnerability_type: Option<Vec<crate::datadogV2::model::FindingVulnerabilityType>>,
/// Return additional fields for some findings.
pub detailed_findings: Option<bool>,
}
impl ListFindingsOptionalParams {
/// Limit the number of findings returned. Must be <= 1000.
pub fn page_limit(mut self, value: i64) -> Self {
self.page_limit = Some(value);
self
}
/// Return findings for a given snapshot of time (Unix ms).
pub fn snapshot_timestamp(mut self, value: i64) -> Self {
self.snapshot_timestamp = Some(value);
self
}
/// Return the next page of findings pointed to by the cursor.
pub fn page_cursor(mut self, value: String) -> Self {
self.page_cursor = Some(value);
self
}
/// Return findings that have these associated tags (repeatable).
pub fn filter_tags(mut self, value: String) -> Self {
self.filter_tags = Some(value);
self
}
/// Return findings that have changed from pass to fail or vice versa on a specified date (Unix ms) or date range (using comparison operators).
pub fn filter_evaluation_changed_at(mut self, value: String) -> Self {
self.filter_evaluation_changed_at = Some(value);
self
}
/// Set to `true` to return findings that are muted. Set to `false` to return unmuted findings.
pub fn filter_muted(mut self, value: bool) -> Self {
self.filter_muted = Some(value);
self
}
/// Return findings for the specified rule ID.
pub fn filter_rule_id(mut self, value: String) -> Self {
self.filter_rule_id = Some(value);
self
}
/// Return findings for the specified rule.
pub fn filter_rule_name(mut self, value: String) -> Self {
self.filter_rule_name = Some(value);
self
}
/// Return only findings for the specified resource type.
pub fn filter_resource_type(mut self, value: String) -> Self {
self.filter_resource_type = Some(value);
self
}
/// Return only findings for the specified resource id.
pub fn filter_resource_id(mut self, value: String) -> Self {
self.filter_resource_id = Some(value);
self
}
/// Return findings that were found on a specified date (Unix ms) or date range (using comparison operators).
pub fn filter_discovery_timestamp(mut self, value: String) -> Self {
self.filter_discovery_timestamp = Some(value);
self
}
/// Return only `pass` or `fail` findings.
pub fn filter_evaluation(mut self, value: crate::datadogV2::model::FindingEvaluation) -> Self {
self.filter_evaluation = Some(value);
self
}
/// Return only findings with the specified status.
pub fn filter_status(mut self, value: crate::datadogV2::model::FindingStatus) -> Self {
self.filter_status = Some(value);
self
}
/// Return findings that match the selected vulnerability types (repeatable).
pub fn filter_vulnerability_type(
mut self,
value: Vec<crate::datadogV2::model::FindingVulnerabilityType>,
) -> Self {
self.filter_vulnerability_type = Some(value);
self
}
/// Return additional fields for some findings.
pub fn detailed_findings(mut self, value: bool) -> Self {
self.detailed_findings = Some(value);
self
}
}
/// ListHistoricalJobsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_historical_jobs`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListHistoricalJobsOptionalParams {
/// Size for a given page. The maximum allowed value is 100.
pub page_size: Option<i64>,
/// Specific page number to return.
pub page_number: Option<i64>,
/// The order of the jobs in results.
pub sort: Option<String>,
/// Query used to filter items from the fetched list.
pub filter_query: Option<String>,
}
impl ListHistoricalJobsOptionalParams {
/// Size for a given page. The maximum allowed value is 100.
pub fn page_size(mut self, value: i64) -> Self {
self.page_size = Some(value);
self
}
/// Specific page number to return.
pub fn page_number(mut self, value: i64) -> Self {
self.page_number = Some(value);
self
}
/// The order of the jobs in results.
pub fn sort(mut self, value: String) -> Self {
self.sort = Some(value);
self
}
/// Query used to filter items from the fetched list.
pub fn filter_query(mut self, value: String) -> Self {
self.filter_query = Some(value);
self
}
}
/// ListIndicatorsOfCompromiseOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_indicators_of_compromise`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListIndicatorsOfCompromiseOptionalParams {
/// Number of results per page.
pub limit: Option<i32>,
/// Pagination offset.
pub offset: Option<i32>,
/// Search/filter query (supports field:value syntax).
pub query: Option<String>,
/// Sort column: score, first_seen_ts_epoch, last_seen_ts_epoch, indicator, indicator_type, signal_count, log_count, category, as_type.
pub sort_column: Option<String>,
/// Sort order: asc or desc.
pub sort_order: Option<String>,
}
impl ListIndicatorsOfCompromiseOptionalParams {
/// Number of results per page.
pub fn limit(mut self, value: i32) -> Self {
self.limit = Some(value);
self
}
/// Pagination offset.
pub fn offset(mut self, value: i32) -> Self {
self.offset = Some(value);
self
}
/// Search/filter query (supports field:value syntax).
pub fn query(mut self, value: String) -> Self {
self.query = Some(value);
self
}
/// Sort column: score, first_seen_ts_epoch, last_seen_ts_epoch, indicator, indicator_type, signal_count, log_count, category, as_type.
pub fn sort_column(mut self, value: String) -> Self {
self.sort_column = Some(value);
self
}
/// Sort order: asc or desc.
pub fn sort_order(mut self, value: String) -> Self {
self.sort_order = Some(value);
self
}
}
/// ListScannedAssetsMetadataOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_scanned_assets_metadata`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListScannedAssetsMetadataOptionalParams {
/// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
pub page_token: Option<String>,
/// The page number to be retrieved. It should be equal to or greater than 1.
pub page_number: Option<i64>,
/// The type of the scanned asset.
pub filter_asset_type: Option<crate::datadogV2::model::CloudAssetType>,
/// The name of the scanned asset.
pub filter_asset_name: Option<String>,
/// The origin of last success scan.
pub filter_last_success_origin: Option<String>,
/// The environment of last success scan.
pub filter_last_success_env: Option<String>,
}
impl ListScannedAssetsMetadataOptionalParams {
/// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
pub fn page_token(mut self, value: String) -> Self {
self.page_token = Some(value);
self
}
/// The page number to be retrieved. It should be equal to or greater than 1.
pub fn page_number(mut self, value: i64) -> Self {
self.page_number = Some(value);
self
}
/// The type of the scanned asset.
pub fn filter_asset_type(mut self, value: crate::datadogV2::model::CloudAssetType) -> Self {
self.filter_asset_type = Some(value);
self
}
/// The name of the scanned asset.
pub fn filter_asset_name(mut self, value: String) -> Self {
self.filter_asset_name = Some(value);
self
}
/// The origin of last success scan.
pub fn filter_last_success_origin(mut self, value: String) -> Self {
self.filter_last_success_origin = Some(value);
self
}
/// The environment of last success scan.
pub fn filter_last_success_env(mut self, value: String) -> Self {
self.filter_last_success_env = Some(value);
self
}
}
/// ListSecurityFindingsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_security_findings`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListSecurityFindingsOptionalParams {
/// The search query following log search syntax.
pub filter_query: Option<String>,
/// Get the next page of results with a cursor provided in the previous query.
pub page_cursor: Option<String>,
/// The maximum number of findings in the response.
pub page_limit: Option<i64>,
/// Sorts by @detection_changed_at.
pub sort: Option<crate::datadogV2::model::SecurityFindingsSort>,
}
impl ListSecurityFindingsOptionalParams {
/// The search query following log search syntax.
pub fn filter_query(mut self, value: String) -> Self {
self.filter_query = Some(value);
self
}
/// Get the next page of results with a cursor provided in the previous query.
pub fn page_cursor(mut self, value: String) -> Self {
self.page_cursor = Some(value);
self
}
/// The maximum number of findings in the response.
pub fn page_limit(mut self, value: i64) -> Self {
self.page_limit = Some(value);
self
}
/// Sorts by @detection_changed_at.
pub fn sort(mut self, value: crate::datadogV2::model::SecurityFindingsSort) -> Self {
self.sort = Some(value);
self
}
}
/// ListSecurityMonitoringHistsignalsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_security_monitoring_histsignals`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListSecurityMonitoringHistsignalsOptionalParams {
/// The search query for security signals.
pub filter_query: Option<String>,
/// The minimum timestamp for requested security signals.
pub filter_from: Option<chrono::DateTime<chrono::Utc>>,
/// The maximum timestamp for requested security signals.
pub filter_to: Option<chrono::DateTime<chrono::Utc>>,
/// The order of the security signals in results.
pub sort: Option<crate::datadogV2::model::SecurityMonitoringSignalsSort>,
/// A list of results using the cursor provided in the previous query.
pub page_cursor: Option<String>,
/// The maximum number of security signals in the response.
pub page_limit: Option<i32>,
}
impl ListSecurityMonitoringHistsignalsOptionalParams {
/// The search query for security signals.
pub fn filter_query(mut self, value: String) -> Self {
self.filter_query = Some(value);
self
}
/// The minimum timestamp for requested security signals.
pub fn filter_from(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
self.filter_from = Some(value);
self
}
/// The maximum timestamp for requested security signals.
pub fn filter_to(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
self.filter_to = Some(value);
self
}
/// The order of the security signals in results.
pub fn sort(mut self, value: crate::datadogV2::model::SecurityMonitoringSignalsSort) -> Self {
self.sort = Some(value);
self
}
/// A list of results using the cursor provided in the previous query.
pub fn page_cursor(mut self, value: String) -> Self {
self.page_cursor = Some(value);
self
}
/// The maximum number of security signals in the response.
pub fn page_limit(mut self, value: i32) -> Self {
self.page_limit = Some(value);
self
}
}
/// ListSecurityMonitoringRulesOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_security_monitoring_rules`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListSecurityMonitoringRulesOptionalParams {
/// Size for a given page. The maximum allowed value is 100.
pub page_size: Option<i64>,
/// Specific page number to return.
pub page_number: Option<i64>,
/// A search query to filter security rules. You can filter by attributes such as `type`, `source`, `tags`.
pub query: Option<String>,
/// Attribute used to sort rules. Prefix with `-` to sort in descending order.
pub sort: Option<crate::datadogV2::model::SecurityMonitoringRuleSort>,
}
impl ListSecurityMonitoringRulesOptionalParams {
/// Size for a given page. The maximum allowed value is 100.
pub fn page_size(mut self, value: i64) -> Self {
self.page_size = Some(value);
self
}
/// Specific page number to return.
pub fn page_number(mut self, value: i64) -> Self {
self.page_number = Some(value);
self
}
/// A search query to filter security rules. You can filter by attributes such as `type`, `source`, `tags`.
pub fn query(mut self, value: String) -> Self {
self.query = Some(value);
self
}
/// Attribute used to sort rules. Prefix with `-` to sort in descending order.
pub fn sort(mut self, value: crate::datadogV2::model::SecurityMonitoringRuleSort) -> Self {
self.sort = Some(value);
self
}
}
/// ListSecurityMonitoringSignalsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_security_monitoring_signals`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListSecurityMonitoringSignalsOptionalParams {
/// The search query for security signals.
pub filter_query: Option<String>,
/// The minimum timestamp for requested security signals.
pub filter_from: Option<chrono::DateTime<chrono::Utc>>,
/// The maximum timestamp for requested security signals.
pub filter_to: Option<chrono::DateTime<chrono::Utc>>,
/// The order of the security signals in results.
pub sort: Option<crate::datadogV2::model::SecurityMonitoringSignalsSort>,
/// A list of results using the cursor provided in the previous query.
pub page_cursor: Option<String>,
/// The maximum number of security signals in the response.
pub page_limit: Option<i32>,
}
impl ListSecurityMonitoringSignalsOptionalParams {
/// The search query for security signals.
pub fn filter_query(mut self, value: String) -> Self {
self.filter_query = Some(value);
self
}
/// The minimum timestamp for requested security signals.
pub fn filter_from(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
self.filter_from = Some(value);
self
}
/// The maximum timestamp for requested security signals.
pub fn filter_to(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
self.filter_to = Some(value);
self
}
/// The order of the security signals in results.
pub fn sort(mut self, value: crate::datadogV2::model::SecurityMonitoringSignalsSort) -> Self {
self.sort = Some(value);
self
}
/// A list of results using the cursor provided in the previous query.
pub fn page_cursor(mut self, value: String) -> Self {
self.page_cursor = Some(value);
self
}
/// The maximum number of security signals in the response.
pub fn page_limit(mut self, value: i32) -> Self {
self.page_limit = Some(value);
self
}
}
/// ListSecurityMonitoringSuppressionsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_security_monitoring_suppressions`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListSecurityMonitoringSuppressionsOptionalParams {
/// Query string.
pub query: Option<String>,
/// Attribute used to sort the list of suppression rules. Prefix with `-` to sort in descending order.
pub sort: Option<crate::datadogV2::model::SecurityMonitoringSuppressionSort>,
/// Size for a given page. Use `-1` to return all items.
pub page_size: Option<i64>,
/// Specific page number to return.
pub page_number: Option<i64>,
}
impl ListSecurityMonitoringSuppressionsOptionalParams {
/// Query string.
pub fn query(mut self, value: String) -> Self {
self.query = Some(value);
self
}
/// Attribute used to sort the list of suppression rules. Prefix with `-` to sort in descending order.
pub fn sort(
mut self,
value: crate::datadogV2::model::SecurityMonitoringSuppressionSort,
) -> Self {
self.sort = Some(value);
self
}
/// Size for a given page. Use `-1` to return all items.
pub fn page_size(mut self, value: i64) -> Self {
self.page_size = Some(value);
self
}
/// Specific page number to return.
pub fn page_number(mut self, value: i64) -> Self {
self.page_number = Some(value);
self
}
}
/// ListVulnerabilitiesOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_vulnerabilities`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListVulnerabilitiesOptionalParams {
/// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
pub page_token: Option<String>,
/// The page number to be retrieved. It should be equal or greater than `1`
pub page_number: Option<i64>,
/// Filter by vulnerability type.
pub filter_type: Option<crate::datadogV2::model::VulnerabilityType>,
/// Filter by vulnerability base (i.e. from the original advisory) severity score.
pub filter_cvss_base_score_op: Option<f64>,
/// Filter by vulnerability base severity.
pub filter_cvss_base_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
/// Filter by vulnerability base CVSS vector.
pub filter_cvss_base_vector: Option<String>,
/// Filter by vulnerability Datadog severity score.
pub filter_cvss_datadog_score_op: Option<f64>,
/// Filter by vulnerability Datadog severity.
pub filter_cvss_datadog_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
/// Filter by vulnerability Datadog CVSS vector.
pub filter_cvss_datadog_vector: Option<String>,
/// Filter by the status of the vulnerability.
pub filter_status: Option<crate::datadogV2::model::VulnerabilityStatus>,
/// Filter by the tool of the vulnerability.
pub filter_tool: Option<crate::datadogV2::model::VulnerabilityTool>,
/// Filter by library name.
pub filter_library_name: Option<String>,
/// Filter by library version.
pub filter_library_version: Option<String>,
/// Filter by advisory ID.
pub filter_advisory_id: Option<String>,
/// Filter by exploitation probability.
pub filter_risks_exploitation_probability: Option<bool>,
/// Filter by POC exploit availability.
pub filter_risks_poc_exploit_available: Option<bool>,
/// Filter by public exploit availability.
pub filter_risks_exploit_available: Option<bool>,
/// Filter by vulnerability [EPSS](<https://www.first.org/epss/>) severity score.
pub filter_risks_epss_score_op: Option<f64>,
/// Filter by vulnerability [EPSS](<https://www.first.org/epss/>) severity.
pub filter_risks_epss_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
/// Filter by language.
pub filter_language: Option<String>,
/// Filter by ecosystem.
pub filter_ecosystem: Option<crate::datadogV2::model::VulnerabilityEcosystem>,
/// Filter by vulnerability location.
pub filter_code_location_location: Option<String>,
/// Filter by vulnerability file path.
pub filter_code_location_file_path: Option<String>,
/// Filter by method.
pub filter_code_location_method: Option<String>,
/// Filter by fix availability.
pub filter_fix_available: Option<bool>,
/// Filter by vulnerability `repo_digest` (when the vulnerability is related to `Image` asset).
pub filter_repo_digests: Option<String>,
/// Filter by origin.
pub filter_origin: Option<String>,
/// Filter for whether the vulnerability affects a running kernel (for vulnerabilities related to a `Host` asset).
pub filter_running_kernel: Option<bool>,
/// Filter by asset name. This field supports the usage of wildcards (*).
pub filter_asset_name: Option<String>,
/// Filter by asset type.
pub filter_asset_type: Option<crate::datadogV2::model::AssetType>,
/// Filter by the first version of the asset this vulnerability has been detected on.
pub filter_asset_version_first: Option<String>,
/// Filter by the last version of the asset this vulnerability has been detected on.
pub filter_asset_version_last: Option<String>,
/// Filter by the repository url associated to the asset.
pub filter_asset_repository_url: Option<String>,
/// Filter whether the asset is in production or not.
pub filter_asset_risks_in_production: Option<bool>,
/// Filter whether the asset is under attack or not.
pub filter_asset_risks_under_attack: Option<bool>,
/// Filter whether the asset is publicly accessible or not.
pub filter_asset_risks_is_publicly_accessible: Option<bool>,
/// Filter whether the asset is publicly accessible or not.
pub filter_asset_risks_has_privileged_access: Option<bool>,
/// Filter whether the asset has access to sensitive data or not.
pub filter_asset_risks_has_access_to_sensitive_data: Option<bool>,
/// Filter by asset environments.
pub filter_asset_environments: Option<String>,
/// Filter by asset teams.
pub filter_asset_teams: Option<String>,
/// Filter by asset architecture.
pub filter_asset_arch: Option<String>,
/// Filter by asset operating system name.
pub filter_asset_operating_system_name: Option<String>,
/// Filter by asset operating system version.
pub filter_asset_operating_system_version: Option<String>,
}
impl ListVulnerabilitiesOptionalParams {
/// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
pub fn page_token(mut self, value: String) -> Self {
self.page_token = Some(value);
self
}
/// The page number to be retrieved. It should be equal or greater than `1`
pub fn page_number(mut self, value: i64) -> Self {
self.page_number = Some(value);
self
}
/// Filter by vulnerability type.
pub fn filter_type(mut self, value: crate::datadogV2::model::VulnerabilityType) -> Self {
self.filter_type = Some(value);
self
}
/// Filter by vulnerability base (i.e. from the original advisory) severity score.
pub fn filter_cvss_base_score_op(mut self, value: f64) -> Self {
self.filter_cvss_base_score_op = Some(value);
self
}
/// Filter by vulnerability base severity.
pub fn filter_cvss_base_severity(
mut self,
value: crate::datadogV2::model::VulnerabilitySeverity,
) -> Self {
self.filter_cvss_base_severity = Some(value);
self
}
/// Filter by vulnerability base CVSS vector.
pub fn filter_cvss_base_vector(mut self, value: String) -> Self {
self.filter_cvss_base_vector = Some(value);
self
}
/// Filter by vulnerability Datadog severity score.
pub fn filter_cvss_datadog_score_op(mut self, value: f64) -> Self {
self.filter_cvss_datadog_score_op = Some(value);
self
}
/// Filter by vulnerability Datadog severity.
pub fn filter_cvss_datadog_severity(
mut self,
value: crate::datadogV2::model::VulnerabilitySeverity,
) -> Self {
self.filter_cvss_datadog_severity = Some(value);
self
}
/// Filter by vulnerability Datadog CVSS vector.
pub fn filter_cvss_datadog_vector(mut self, value: String) -> Self {
self.filter_cvss_datadog_vector = Some(value);
self
}
/// Filter by the status of the vulnerability.
pub fn filter_status(mut self, value: crate::datadogV2::model::VulnerabilityStatus) -> Self {
self.filter_status = Some(value);
self
}
/// Filter by the tool of the vulnerability.
pub fn filter_tool(mut self, value: crate::datadogV2::model::VulnerabilityTool) -> Self {
self.filter_tool = Some(value);
self
}
/// Filter by library name.
pub fn filter_library_name(mut self, value: String) -> Self {
self.filter_library_name = Some(value);
self
}
/// Filter by library version.
pub fn filter_library_version(mut self, value: String) -> Self {
self.filter_library_version = Some(value);
self
}
/// Filter by advisory ID.
pub fn filter_advisory_id(mut self, value: String) -> Self {
self.filter_advisory_id = Some(value);
self
}
/// Filter by exploitation probability.
pub fn filter_risks_exploitation_probability(mut self, value: bool) -> Self {
self.filter_risks_exploitation_probability = Some(value);
self
}
/// Filter by POC exploit availability.
pub fn filter_risks_poc_exploit_available(mut self, value: bool) -> Self {
self.filter_risks_poc_exploit_available = Some(value);
self
}
/// Filter by public exploit availability.
pub fn filter_risks_exploit_available(mut self, value: bool) -> Self {
self.filter_risks_exploit_available = Some(value);
self
}
/// Filter by vulnerability [EPSS](<https://www.first.org/epss/>) severity score.
pub fn filter_risks_epss_score_op(mut self, value: f64) -> Self {
self.filter_risks_epss_score_op = Some(value);
self
}
/// Filter by vulnerability [EPSS](<https://www.first.org/epss/>) severity.
pub fn filter_risks_epss_severity(
mut self,
value: crate::datadogV2::model::VulnerabilitySeverity,
) -> Self {
self.filter_risks_epss_severity = Some(value);
self
}
/// Filter by language.
pub fn filter_language(mut self, value: String) -> Self {
self.filter_language = Some(value);
self
}
/// Filter by ecosystem.
pub fn filter_ecosystem(
mut self,
value: crate::datadogV2::model::VulnerabilityEcosystem,
) -> Self {
self.filter_ecosystem = Some(value);
self
}
/// Filter by vulnerability location.
pub fn filter_code_location_location(mut self, value: String) -> Self {
self.filter_code_location_location = Some(value);
self
}
/// Filter by vulnerability file path.
pub fn filter_code_location_file_path(mut self, value: String) -> Self {
self.filter_code_location_file_path = Some(value);
self
}
/// Filter by method.
pub fn filter_code_location_method(mut self, value: String) -> Self {
self.filter_code_location_method = Some(value);
self
}
/// Filter by fix availability.
pub fn filter_fix_available(mut self, value: bool) -> Self {
self.filter_fix_available = Some(value);
self
}
/// Filter by vulnerability `repo_digest` (when the vulnerability is related to `Image` asset).
pub fn filter_repo_digests(mut self, value: String) -> Self {
self.filter_repo_digests = Some(value);
self
}
/// Filter by origin.
pub fn filter_origin(mut self, value: String) -> Self {
self.filter_origin = Some(value);
self
}
/// Filter for whether the vulnerability affects a running kernel (for vulnerabilities related to a `Host` asset).
pub fn filter_running_kernel(mut self, value: bool) -> Self {
self.filter_running_kernel = Some(value);
self
}
/// Filter by asset name. This field supports the usage of wildcards (*).
pub fn filter_asset_name(mut self, value: String) -> Self {
self.filter_asset_name = Some(value);
self
}
/// Filter by asset type.
pub fn filter_asset_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
self.filter_asset_type = Some(value);
self
}
/// Filter by the first version of the asset this vulnerability has been detected on.
pub fn filter_asset_version_first(mut self, value: String) -> Self {
self.filter_asset_version_first = Some(value);
self
}
/// Filter by the last version of the asset this vulnerability has been detected on.
pub fn filter_asset_version_last(mut self, value: String) -> Self {
self.filter_asset_version_last = Some(value);
self
}
/// Filter by the repository url associated to the asset.
pub fn filter_asset_repository_url(mut self, value: String) -> Self {
self.filter_asset_repository_url = Some(value);
self
}
/// Filter whether the asset is in production or not.
pub fn filter_asset_risks_in_production(mut self, value: bool) -> Self {
self.filter_asset_risks_in_production = Some(value);
self
}
/// Filter whether the asset is under attack or not.
pub fn filter_asset_risks_under_attack(mut self, value: bool) -> Self {
self.filter_asset_risks_under_attack = Some(value);
self
}
/// Filter whether the asset is publicly accessible or not.
pub fn filter_asset_risks_is_publicly_accessible(mut self, value: bool) -> Self {
self.filter_asset_risks_is_publicly_accessible = Some(value);
self
}
/// Filter whether the asset is publicly accessible or not.
pub fn filter_asset_risks_has_privileged_access(mut self, value: bool) -> Self {
self.filter_asset_risks_has_privileged_access = Some(value);
self
}
/// Filter whether the asset has access to sensitive data or not.
pub fn filter_asset_risks_has_access_to_sensitive_data(mut self, value: bool) -> Self {
self.filter_asset_risks_has_access_to_sensitive_data = Some(value);
self
}
/// Filter by asset environments.
pub fn filter_asset_environments(mut self, value: String) -> Self {
self.filter_asset_environments = Some(value);
self
}
/// Filter by asset teams.
pub fn filter_asset_teams(mut self, value: String) -> Self {
self.filter_asset_teams = Some(value);
self
}
/// Filter by asset architecture.
pub fn filter_asset_arch(mut self, value: String) -> Self {
self.filter_asset_arch = Some(value);
self
}
/// Filter by asset operating system name.
pub fn filter_asset_operating_system_name(mut self, value: String) -> Self {
self.filter_asset_operating_system_name = Some(value);
self
}
/// Filter by asset operating system version.
pub fn filter_asset_operating_system_version(mut self, value: String) -> Self {
self.filter_asset_operating_system_version = Some(value);
self
}
}
/// ListVulnerableAssetsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_vulnerable_assets`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListVulnerableAssetsOptionalParams {
/// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
pub page_token: Option<String>,
/// The page number to be retrieved. It should be equal or greater than `1`
pub page_number: Option<i64>,
/// Filter by name. This field supports the usage of wildcards (*).
pub filter_name: Option<String>,
/// Filter by type.
pub filter_type: Option<crate::datadogV2::model::AssetType>,
/// Filter by the first version of the asset since it has been vulnerable.
pub filter_version_first: Option<String>,
/// Filter by the last detected version of the asset.
pub filter_version_last: Option<String>,
/// Filter by the repository url associated to the asset.
pub filter_repository_url: Option<String>,
/// Filter whether the asset is in production or not.
pub filter_risks_in_production: Option<bool>,
/// Filter whether the asset (Service) is under attack or not.
pub filter_risks_under_attack: Option<bool>,
/// Filter whether the asset (Host) is publicly accessible or not.
pub filter_risks_is_publicly_accessible: Option<bool>,
/// Filter whether the asset (Host) has privileged access or not.
pub filter_risks_has_privileged_access: Option<bool>,
/// Filter whether the asset (Host) has access to sensitive data or not.
pub filter_risks_has_access_to_sensitive_data: Option<bool>,
/// Filter by environment.
pub filter_environments: Option<String>,
/// Filter by teams.
pub filter_teams: Option<String>,
/// Filter by architecture.
pub filter_arch: Option<String>,
/// Filter by operating system name.
pub filter_operating_system_name: Option<String>,
/// Filter by operating system version.
pub filter_operating_system_version: Option<String>,
}
impl ListVulnerableAssetsOptionalParams {
/// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
pub fn page_token(mut self, value: String) -> Self {
self.page_token = Some(value);
self
}
/// The page number to be retrieved. It should be equal or greater than `1`
pub fn page_number(mut self, value: i64) -> Self {
self.page_number = Some(value);
self
}
/// Filter by name. This field supports the usage of wildcards (*).
pub fn filter_name(mut self, value: String) -> Self {
self.filter_name = Some(value);
self
}
/// Filter by type.
pub fn filter_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
self.filter_type = Some(value);
self
}
/// Filter by the first version of the asset since it has been vulnerable.
pub fn filter_version_first(mut self, value: String) -> Self {
self.filter_version_first = Some(value);
self
}
/// Filter by the last detected version of the asset.
pub fn filter_version_last(mut self, value: String) -> Self {
self.filter_version_last = Some(value);
self
}
/// Filter by the repository url associated to the asset.
pub fn filter_repository_url(mut self, value: String) -> Self {
self.filter_repository_url = Some(value);
self
}
/// Filter whether the asset is in production or not.
pub fn filter_risks_in_production(mut self, value: bool) -> Self {
self.filter_risks_in_production = Some(value);
self
}
/// Filter whether the asset (Service) is under attack or not.
pub fn filter_risks_under_attack(mut self, value: bool) -> Self {
self.filter_risks_under_attack = Some(value);
self
}
/// Filter whether the asset (Host) is publicly accessible or not.
pub fn filter_risks_is_publicly_accessible(mut self, value: bool) -> Self {
self.filter_risks_is_publicly_accessible = Some(value);
self
}
/// Filter whether the asset (Host) has privileged access or not.
pub fn filter_risks_has_privileged_access(mut self, value: bool) -> Self {
self.filter_risks_has_privileged_access = Some(value);
self
}
/// Filter whether the asset (Host) has access to sensitive data or not.
pub fn filter_risks_has_access_to_sensitive_data(mut self, value: bool) -> Self {
self.filter_risks_has_access_to_sensitive_data = Some(value);
self
}
/// Filter by environment.
pub fn filter_environments(mut self, value: String) -> Self {
self.filter_environments = Some(value);
self
}
/// Filter by teams.
pub fn filter_teams(mut self, value: String) -> Self {
self.filter_teams = Some(value);
self
}
/// Filter by architecture.
pub fn filter_arch(mut self, value: String) -> Self {
self.filter_arch = Some(value);
self
}
/// Filter by operating system name.
pub fn filter_operating_system_name(mut self, value: String) -> Self {
self.filter_operating_system_name = Some(value);
self
}
/// Filter by operating system version.
pub fn filter_operating_system_version(mut self, value: String) -> Self {
self.filter_operating_system_version = Some(value);
self
}
}
/// SearchSecurityMonitoringHistsignalsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::search_security_monitoring_histsignals`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct SearchSecurityMonitoringHistsignalsOptionalParams {
pub body: Option<crate::datadogV2::model::SecurityMonitoringSignalListRequest>,
}
impl SearchSecurityMonitoringHistsignalsOptionalParams {
pub fn body(
mut self,
value: crate::datadogV2::model::SecurityMonitoringSignalListRequest,
) -> Self {
self.body = Some(value);
self
}
}
/// SearchSecurityMonitoringSignalsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::search_security_monitoring_signals`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct SearchSecurityMonitoringSignalsOptionalParams {
pub body: Option<crate::datadogV2::model::SecurityMonitoringSignalListRequest>,
}
impl SearchSecurityMonitoringSignalsOptionalParams {
pub fn body(
mut self,
value: crate::datadogV2::model::SecurityMonitoringSignalListRequest,
) -> Self {
self.body = Some(value);
self
}
}
/// ActivateContentPackError is a struct for typed errors of method [`SecurityMonitoringAPI::activate_content_pack`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ActivateContentPackError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// AttachCaseError is a struct for typed errors of method [`SecurityMonitoringAPI::attach_case`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AttachCaseError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// AttachJiraIssueError is a struct for typed errors of method [`SecurityMonitoringAPI::attach_jira_issue`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AttachJiraIssueError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// BulkEditSecurityMonitoringSignalsError is a struct for typed errors of method [`SecurityMonitoringAPI::bulk_edit_security_monitoring_signals`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkEditSecurityMonitoringSignalsError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// BulkEditSecurityMonitoringSignalsAssigneeError is a struct for typed errors of method [`SecurityMonitoringAPI::bulk_edit_security_monitoring_signals_assignee`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkEditSecurityMonitoringSignalsAssigneeError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// BulkEditSecurityMonitoringSignalsStateError is a struct for typed errors of method [`SecurityMonitoringAPI::bulk_edit_security_monitoring_signals_state`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkEditSecurityMonitoringSignalsStateError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// BulkExportSecurityMonitoringRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::bulk_export_security_monitoring_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkExportSecurityMonitoringRulesError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// BulkExportSecurityMonitoringTerraformResourcesError is a struct for typed errors of method [`SecurityMonitoringAPI::bulk_export_security_monitoring_terraform_resources`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkExportSecurityMonitoringTerraformResourcesError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// CancelHistoricalJobError is a struct for typed errors of method [`SecurityMonitoringAPI::cancel_historical_job`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CancelHistoricalJobError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ConvertExistingSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::convert_existing_security_monitoring_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConvertExistingSecurityMonitoringRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ConvertJobResultToSignalError is a struct for typed errors of method [`SecurityMonitoringAPI::convert_job_result_to_signal`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConvertJobResultToSignalError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ConvertSecurityMonitoringRuleFromJSONToTerraformError is a struct for typed errors of method [`SecurityMonitoringAPI::convert_security_monitoring_rule_from_json_to_terraform`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConvertSecurityMonitoringRuleFromJSONToTerraformError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ConvertSecurityMonitoringTerraformResourceError is a struct for typed errors of method [`SecurityMonitoringAPI::convert_security_monitoring_terraform_resource`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConvertSecurityMonitoringTerraformResourceError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// CreateCasesError is a struct for typed errors of method [`SecurityMonitoringAPI::create_cases`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCasesError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// CreateCustomFrameworkError is a struct for typed errors of method [`SecurityMonitoringAPI::create_custom_framework`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCustomFrameworkError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// CreateJiraIssuesError is a struct for typed errors of method [`SecurityMonitoringAPI::create_jira_issues`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateJiraIssuesError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// CreateSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::create_security_filter`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateSecurityFilterError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// CreateSecurityMonitoringCriticalAssetError is a struct for typed errors of method [`SecurityMonitoringAPI::create_security_monitoring_critical_asset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateSecurityMonitoringCriticalAssetError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// CreateSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::create_security_monitoring_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateSecurityMonitoringRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// CreateSecurityMonitoringSuppressionError is a struct for typed errors of method [`SecurityMonitoringAPI::create_security_monitoring_suppression`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateSecurityMonitoringSuppressionError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// CreateSignalNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::create_signal_notification_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateSignalNotificationRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// CreateVulnerabilityNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::create_vulnerability_notification_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateVulnerabilityNotificationRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// DeactivateContentPackError is a struct for typed errors of method [`SecurityMonitoringAPI::deactivate_content_pack`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeactivateContentPackError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// DeleteCustomFrameworkError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_custom_framework`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCustomFrameworkError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// DeleteHistoricalJobError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_historical_job`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteHistoricalJobError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// DeleteSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_security_filter`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteSecurityFilterError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// DeleteSecurityMonitoringCriticalAssetError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_security_monitoring_critical_asset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteSecurityMonitoringCriticalAssetError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// DeleteSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_security_monitoring_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteSecurityMonitoringRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// DeleteSecurityMonitoringSuppressionError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_security_monitoring_suppression`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteSecurityMonitoringSuppressionError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// DeleteSignalNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_signal_notification_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteSignalNotificationRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// DeleteVulnerabilityNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_vulnerability_notification_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteVulnerabilityNotificationRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// DetachCaseError is a struct for typed errors of method [`SecurityMonitoringAPI::detach_case`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DetachCaseError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// EditSecurityMonitoringSignalError is a struct for typed errors of method [`SecurityMonitoringAPI::edit_security_monitoring_signal`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EditSecurityMonitoringSignalError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// EditSecurityMonitoringSignalAssigneeError is a struct for typed errors of method [`SecurityMonitoringAPI::edit_security_monitoring_signal_assignee`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EditSecurityMonitoringSignalAssigneeError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// EditSecurityMonitoringSignalIncidentsError is a struct for typed errors of method [`SecurityMonitoringAPI::edit_security_monitoring_signal_incidents`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EditSecurityMonitoringSignalIncidentsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// EditSecurityMonitoringSignalStateError is a struct for typed errors of method [`SecurityMonitoringAPI::edit_security_monitoring_signal_state`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EditSecurityMonitoringSignalStateError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ExportSecurityMonitoringTerraformResourceError is a struct for typed errors of method [`SecurityMonitoringAPI::export_security_monitoring_terraform_resource`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ExportSecurityMonitoringTerraformResourceError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetContentPacksStatesError is a struct for typed errors of method [`SecurityMonitoringAPI::get_content_packs_states`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetContentPacksStatesError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetCriticalAssetsAffectingRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_critical_assets_affecting_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCriticalAssetsAffectingRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetCustomFrameworkError is a struct for typed errors of method [`SecurityMonitoringAPI::get_custom_framework`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCustomFrameworkError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetFindingError is a struct for typed errors of method [`SecurityMonitoringAPI::get_finding`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFindingError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetHistoricalJobError is a struct for typed errors of method [`SecurityMonitoringAPI::get_historical_job`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetHistoricalJobError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetIndicatorOfCompromiseError is a struct for typed errors of method [`SecurityMonitoringAPI::get_indicator_of_compromise`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIndicatorOfCompromiseError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetInvestigationLogQueriesMatchingSignalError is a struct for typed errors of method [`SecurityMonitoringAPI::get_investigation_log_queries_matching_signal`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInvestigationLogQueriesMatchingSignalError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetResourceEvaluationFiltersError is a struct for typed errors of method [`SecurityMonitoringAPI::get_resource_evaluation_filters`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetResourceEvaluationFiltersError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetRuleVersionHistoryError is a struct for typed errors of method [`SecurityMonitoringAPI::get_rule_version_history`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetRuleVersionHistoryError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSBOMError is a struct for typed errors of method [`SecurityMonitoringAPI::get_sbom`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSBOMError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSecretsRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::get_secrets_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecretsRulesError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_filter`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecurityFilterError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSecurityMonitoringCriticalAssetError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_monitoring_critical_asset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecurityMonitoringCriticalAssetError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSecurityMonitoringHistsignalError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_monitoring_histsignal`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecurityMonitoringHistsignalError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSecurityMonitoringHistsignalsByJobIdError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_monitoring_histsignals_by_job_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecurityMonitoringHistsignalsByJobIdError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_monitoring_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecurityMonitoringRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSecurityMonitoringSignalError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_monitoring_signal`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecurityMonitoringSignalError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSecurityMonitoringSuppressionError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_monitoring_suppression`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecurityMonitoringSuppressionError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSignalNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_signal_notification_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSignalNotificationRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSignalNotificationRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::get_signal_notification_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSignalNotificationRulesError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSuggestedActionsMatchingSignalError is a struct for typed errors of method [`SecurityMonitoringAPI::get_suggested_actions_matching_signal`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSuggestedActionsMatchingSignalError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSuppressionVersionHistoryError is a struct for typed errors of method [`SecurityMonitoringAPI::get_suppression_version_history`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSuppressionVersionHistoryError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSuppressionsAffectingFutureRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_suppressions_affecting_future_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSuppressionsAffectingFutureRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetSuppressionsAffectingRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_suppressions_affecting_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSuppressionsAffectingRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetVulnerabilityNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_vulnerability_notification_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetVulnerabilityNotificationRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// GetVulnerabilityNotificationRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::get_vulnerability_notification_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetVulnerabilityNotificationRulesError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListAssetsSBOMsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_assets_sbo_ms`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAssetsSBOMsError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListFindingsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_findings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListFindingsError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListHistoricalJobsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_historical_jobs`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListHistoricalJobsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListIndicatorsOfCompromiseError is a struct for typed errors of method [`SecurityMonitoringAPI::list_indicators_of_compromise`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListIndicatorsOfCompromiseError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListMultipleRulesetsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_multiple_rulesets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListMultipleRulesetsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListScannedAssetsMetadataError is a struct for typed errors of method [`SecurityMonitoringAPI::list_scanned_assets_metadata`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListScannedAssetsMetadataError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListSecurityFiltersError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_filters`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSecurityFiltersError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListSecurityFindingsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_findings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSecurityFindingsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListSecurityMonitoringCriticalAssetsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_monitoring_critical_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSecurityMonitoringCriticalAssetsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListSecurityMonitoringHistsignalsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_monitoring_histsignals`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSecurityMonitoringHistsignalsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListSecurityMonitoringRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_monitoring_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSecurityMonitoringRulesError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListSecurityMonitoringSignalsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_monitoring_signals`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSecurityMonitoringSignalsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListSecurityMonitoringSuppressionsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_monitoring_suppressions`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSecurityMonitoringSuppressionsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListVulnerabilitiesError is a struct for typed errors of method [`SecurityMonitoringAPI::list_vulnerabilities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListVulnerabilitiesError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ListVulnerableAssetsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_vulnerable_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListVulnerableAssetsError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// MuteFindingsError is a struct for typed errors of method [`SecurityMonitoringAPI::mute_findings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MuteFindingsError {
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
UnknownValue(serde_json::Value),
}
/// PatchSignalNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::patch_signal_notification_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchSignalNotificationRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
UnknownValue(serde_json::Value),
}
/// PatchVulnerabilityNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::patch_vulnerability_notification_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchVulnerabilityNotificationRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
UnknownValue(serde_json::Value),
}
/// RunHistoricalJobError is a struct for typed errors of method [`SecurityMonitoringAPI::run_historical_job`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RunHistoricalJobError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// SearchSecurityFindingsError is a struct for typed errors of method [`SecurityMonitoringAPI::search_security_findings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchSecurityFindingsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// SearchSecurityMonitoringHistsignalsError is a struct for typed errors of method [`SecurityMonitoringAPI::search_security_monitoring_histsignals`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchSecurityMonitoringHistsignalsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// SearchSecurityMonitoringSignalsError is a struct for typed errors of method [`SecurityMonitoringAPI::search_security_monitoring_signals`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchSecurityMonitoringSignalsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// TestExistingSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::test_existing_security_monitoring_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum TestExistingSecurityMonitoringRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// TestSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::test_security_monitoring_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum TestSecurityMonitoringRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// UpdateCustomFrameworkError is a struct for typed errors of method [`SecurityMonitoringAPI::update_custom_framework`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCustomFrameworkError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// UpdateResourceEvaluationFiltersError is a struct for typed errors of method [`SecurityMonitoringAPI::update_resource_evaluation_filters`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateResourceEvaluationFiltersError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// UpdateSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::update_security_filter`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateSecurityFilterError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// UpdateSecurityMonitoringCriticalAssetError is a struct for typed errors of method [`SecurityMonitoringAPI::update_security_monitoring_critical_asset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateSecurityMonitoringCriticalAssetError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// UpdateSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::update_security_monitoring_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateSecurityMonitoringRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// UpdateSecurityMonitoringSuppressionError is a struct for typed errors of method [`SecurityMonitoringAPI::update_security_monitoring_suppression`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateSecurityMonitoringSuppressionError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ValidateSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::validate_security_monitoring_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ValidateSecurityMonitoringRuleError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// ValidateSecurityMonitoringSuppressionError is a struct for typed errors of method [`SecurityMonitoringAPI::validate_security_monitoring_suppression`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ValidateSecurityMonitoringSuppressionError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}
/// Create and manage your security rules, signals, filters, and more. See the [Datadog Security page](<https://docs.datadoghq.com/security/>) for more information.
#[derive(Debug, Clone)]
pub struct SecurityMonitoringAPI {
config: datadog::Configuration,
client: reqwest_middleware::ClientWithMiddleware,
}
impl Default for SecurityMonitoringAPI {
fn default() -> Self {
Self::with_config(datadog::Configuration::default())
}
}
impl SecurityMonitoringAPI {
pub fn new() -> Self {
Self::default()
}
pub fn with_config(config: datadog::Configuration) -> Self {
let reqwest_client_builder = {
let builder = reqwest::Client::builder();
#[cfg(not(target_arch = "wasm32"))]
let builder = if let Some(proxy_url) = &config.proxy_url {
builder.proxy(reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL"))
} else {
builder
};
builder
};
let middleware_client_builder = {
let builder =
reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
#[cfg(feature = "retry")]
let builder = if config.enable_retry {
struct RetryableStatus;
impl reqwest_retry::RetryableStrategy for RetryableStatus {
fn handle(
&self,
res: &Result<reqwest::Response, reqwest_middleware::Error>,
) -> Option<reqwest_retry::Retryable> {
match res {
Ok(success) => reqwest_retry::default_on_request_success(success),
Err(_) => None,
}
}
}
let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
.build_with_max_retries(config.max_retries);
let retry_middleware =
reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
backoff_policy,
RetryableStatus,
);
builder.with(retry_middleware)
} else {
builder
};
builder
};
let client = middleware_client_builder.build();
Self { config, client }
}
pub fn with_client_and_config(
config: datadog::Configuration,
client: reqwest_middleware::ClientWithMiddleware,
) -> Self {
Self { config, client }
}
/// Activate a Cloud SIEM content pack. This operation configures the necessary
/// log filters or security filters depending on the pricing model and updates the content
/// pack activation state.
pub async fn activate_content_pack(
&self,
content_pack_id: String,
) -> Result<(), datadog::Error<ActivateContentPackError>> {
match self
.activate_content_pack_with_http_info(content_pack_id)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Activate a Cloud SIEM content pack. This operation configures the necessary
/// log filters or security filters depending on the pricing model and updates the content
/// pack activation state.
pub async fn activate_content_pack_with_http_info(
&self,
content_pack_id: String,
) -> Result<datadog::ResponseContent<()>, datadog::Error<ActivateContentPackError>> {
let local_configuration = &self.config;
let operation_id = "v2.activate_content_pack";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.activate_content_pack' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/content_packs/{content_pack_id}/activate",
local_configuration.get_operation_host(operation_id),
content_pack_id = datadog::urlencode(content_pack_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<ActivateContentPackError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Attach security findings to a case.
/// You can attach up to 50 security findings per case. Security findings that are already attached to another case will be detached from their previous case and attached to the specified case.
pub async fn attach_case(
&self,
case_id: String,
body: crate::datadogV2::model::AttachCaseRequest,
) -> Result<crate::datadogV2::model::FindingCaseResponse, datadog::Error<AttachCaseError>> {
match self.attach_case_with_http_info(case_id, body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Attach security findings to a case.
/// You can attach up to 50 security findings per case. Security findings that are already attached to another case will be detached from their previous case and attached to the specified case.
pub async fn attach_case_with_http_info(
&self,
case_id: String,
body: crate::datadogV2::model::AttachCaseRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::FindingCaseResponse>,
datadog::Error<AttachCaseError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.attach_case";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/findings/cases/{case_id}",
local_configuration.get_operation_host(operation_id),
case_id = datadog::urlencode(case_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::FindingCaseResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<AttachCaseError> = serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Attach security findings to a Jira issue by providing the Jira issue URL.
/// You can attach up to 50 security findings per Jira issue. If the Jira issue is not linked to any case, this operation will create a case for the security findings and link the Jira issue to the newly created case. To configure the Jira integration, see [Bidirectional ticket syncing with Jira](<https://docs.datadoghq.com/security/ticketing_integrations/#bidirectional-ticket-syncing-with-jira>). Security findings that are already attached to another Jira issue will be detached from their previous Jira issue and attached to the specified Jira issue.
pub async fn attach_jira_issue(
&self,
body: crate::datadogV2::model::AttachJiraIssueRequest,
) -> Result<crate::datadogV2::model::FindingCaseResponse, datadog::Error<AttachJiraIssueError>>
{
match self.attach_jira_issue_with_http_info(body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Attach security findings to a Jira issue by providing the Jira issue URL.
/// You can attach up to 50 security findings per Jira issue. If the Jira issue is not linked to any case, this operation will create a case for the security findings and link the Jira issue to the newly created case. To configure the Jira integration, see [Bidirectional ticket syncing with Jira](<https://docs.datadoghq.com/security/ticketing_integrations/#bidirectional-ticket-syncing-with-jira>). Security findings that are already attached to another Jira issue will be detached from their previous Jira issue and attached to the specified Jira issue.
pub async fn attach_jira_issue_with_http_info(
&self,
body: crate::datadogV2::model::AttachJiraIssueRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::FindingCaseResponse>,
datadog::Error<AttachJiraIssueError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.attach_jira_issue";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/findings/jira_issues",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::FindingCaseResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<AttachJiraIssueError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Update the triage state or assignee of multiple security signals at once.
/// The maximum number of signals that can be updated in a single request is 199.
pub async fn bulk_edit_security_monitoring_signals(
&self,
body: crate::datadogV2::model::SecurityMonitoringSignalsBulkUpdateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalsBulkTriageUpdateResponse,
datadog::Error<BulkEditSecurityMonitoringSignalsError>,
> {
match self
.bulk_edit_security_monitoring_signals_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Update the triage state or assignee of multiple security signals at once.
/// The maximum number of signals that can be updated in a single request is 199.
pub async fn bulk_edit_security_monitoring_signals_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringSignalsBulkUpdateRequest,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringSignalsBulkTriageUpdateResponse,
>,
datadog::Error<BulkEditSecurityMonitoringSignalsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.bulk_edit_security_monitoring_signals";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/bulk/update",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalsBulkTriageUpdateResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<BulkEditSecurityMonitoringSignalsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Change the triage assignees of multiple security signals at once.
/// The maximum number of signals that can be updated in a single request is 199.
pub async fn bulk_edit_security_monitoring_signals_assignee(
&self,
body: crate::datadogV2::model::SecurityMonitoringSignalsBulkAssigneeUpdateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalsBulkTriageUpdateResponse,
datadog::Error<BulkEditSecurityMonitoringSignalsAssigneeError>,
> {
match self
.bulk_edit_security_monitoring_signals_assignee_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Change the triage assignees of multiple security signals at once.
/// The maximum number of signals that can be updated in a single request is 199.
pub async fn bulk_edit_security_monitoring_signals_assignee_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringSignalsBulkAssigneeUpdateRequest,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringSignalsBulkTriageUpdateResponse,
>,
datadog::Error<BulkEditSecurityMonitoringSignalsAssigneeError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.bulk_edit_security_monitoring_signals_assignee";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/bulk/assignee",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalsBulkTriageUpdateResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<BulkEditSecurityMonitoringSignalsAssigneeError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Change the triage states of multiple security signals at once.
/// The maximum number of signals that can be updated in a single request is 199.
pub async fn bulk_edit_security_monitoring_signals_state(
&self,
body: crate::datadogV2::model::SecurityMonitoringSignalsBulkStateUpdateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalsBulkTriageUpdateResponse,
datadog::Error<BulkEditSecurityMonitoringSignalsStateError>,
> {
match self
.bulk_edit_security_monitoring_signals_state_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Change the triage states of multiple security signals at once.
/// The maximum number of signals that can be updated in a single request is 199.
pub async fn bulk_edit_security_monitoring_signals_state_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringSignalsBulkStateUpdateRequest,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringSignalsBulkTriageUpdateResponse,
>,
datadog::Error<BulkEditSecurityMonitoringSignalsStateError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.bulk_edit_security_monitoring_signals_state";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/bulk/state",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalsBulkTriageUpdateResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<BulkEditSecurityMonitoringSignalsStateError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Export a list of security monitoring rules as a ZIP file containing JSON rule definitions.
/// The endpoint accepts a list of rule IDs and returns a ZIP archive where each rule is
/// saved as a separate JSON file named after the rule.
pub async fn bulk_export_security_monitoring_rules(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleBulkExportPayload,
) -> Result<Vec<u8>, datadog::Error<BulkExportSecurityMonitoringRulesError>> {
match self
.bulk_export_security_monitoring_rules_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Export a list of security monitoring rules as a ZIP file containing JSON rule definitions.
/// The endpoint accepts a list of rule IDs and returns a ZIP archive where each rule is
/// saved as a separate JSON file named after the rule.
pub async fn bulk_export_security_monitoring_rules_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleBulkExportPayload,
) -> Result<
datadog::ResponseContent<Vec<u8>>,
datadog::Error<BulkExportSecurityMonitoringRulesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.bulk_export_security_monitoring_rules";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules/bulk_export",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content.clone(),
entity: Some(local_content.into_bytes()),
})
} else {
let local_entity: Option<BulkExportSecurityMonitoringRulesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Export multiple security monitoring resources to Terraform, packaged as a zip archive.
/// The `resource_type` path parameter specifies the type of resources to export
/// and must be one of `suppressions` or `critical_assets`.
/// A maximum of 1000 resources can be exported in a single request.
pub async fn bulk_export_security_monitoring_terraform_resources(
&self,
resource_type: crate::datadogV2::model::SecurityMonitoringTerraformResourceType,
body: crate::datadogV2::model::SecurityMonitoringTerraformBulkExportRequest,
) -> Result<Vec<u8>, datadog::Error<BulkExportSecurityMonitoringTerraformResourcesError>> {
match self
.bulk_export_security_monitoring_terraform_resources_with_http_info(resource_type, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Export multiple security monitoring resources to Terraform, packaged as a zip archive.
/// The `resource_type` path parameter specifies the type of resources to export
/// and must be one of `suppressions` or `critical_assets`.
/// A maximum of 1000 resources can be exported in a single request.
pub async fn bulk_export_security_monitoring_terraform_resources_with_http_info(
&self,
resource_type: crate::datadogV2::model::SecurityMonitoringTerraformResourceType,
body: crate::datadogV2::model::SecurityMonitoringTerraformBulkExportRequest,
) -> Result<
datadog::ResponseContent<Vec<u8>>,
datadog::Error<BulkExportSecurityMonitoringTerraformResourcesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.bulk_export_security_monitoring_terraform_resources";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.bulk_export_security_monitoring_terraform_resources' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/terraform/{resource_type}/bulk",
local_configuration.get_operation_host(operation_id),
resource_type = datadog::urlencode(resource_type.to_string())
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content.clone(),
entity: Some(local_content.into_bytes()),
})
} else {
let local_entity: Option<BulkExportSecurityMonitoringTerraformResourcesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Cancel a historical job.
pub async fn cancel_historical_job(
&self,
job_id: String,
) -> Result<(), datadog::Error<CancelHistoricalJobError>> {
match self.cancel_historical_job_with_http_info(job_id).await {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Cancel a historical job.
pub async fn cancel_historical_job_with_http_info(
&self,
job_id: String,
) -> Result<datadog::ResponseContent<()>, datadog::Error<CancelHistoricalJobError>> {
let local_configuration = &self.config;
let operation_id = "v2.cancel_historical_job";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.cancel_historical_job' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/siem-historical-detections/jobs/{job_id}/cancel",
local_configuration.get_operation_host(operation_id),
job_id = datadog::urlencode(job_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<CancelHistoricalJobError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Convert an existing rule from JSON to Terraform for Datadog provider
/// resource `datadog_security_monitoring_rule`. You can do so for the following rule types:
/// - App and API Protection
/// - Cloud SIEM (log detection and signal correlation)
/// - Workload Protection
///
/// You can convert Cloud Security configuration rules using Terraform's [Datadog Cloud Configuration Rule resource](<https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/cloud_configuration_rule>).
pub async fn convert_existing_security_monitoring_rule(
&self,
rule_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
datadog::Error<ConvertExistingSecurityMonitoringRuleError>,
> {
match self
.convert_existing_security_monitoring_rule_with_http_info(rule_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Convert an existing rule from JSON to Terraform for Datadog provider
/// resource `datadog_security_monitoring_rule`. You can do so for the following rule types:
/// - App and API Protection
/// - Cloud SIEM (log detection and signal correlation)
/// - Workload Protection
///
/// You can convert Cloud Security configuration rules using Terraform's [Datadog Cloud Configuration Rule resource](<https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/cloud_configuration_rule>).
pub async fn convert_existing_security_monitoring_rule_with_http_info(
&self,
rule_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleConvertResponse>,
datadog::Error<ConvertExistingSecurityMonitoringRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.convert_existing_security_monitoring_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules/{rule_id}/convert",
local_configuration.get_operation_host(operation_id),
rule_id = datadog::urlencode(rule_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ConvertExistingSecurityMonitoringRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Convert a job result to a signal.
pub async fn convert_job_result_to_signal(
&self,
body: crate::datadogV2::model::ConvertJobResultsToSignalsRequest,
) -> Result<(), datadog::Error<ConvertJobResultToSignalError>> {
match self.convert_job_result_to_signal_with_http_info(body).await {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Convert a job result to a signal.
pub async fn convert_job_result_to_signal_with_http_info(
&self,
body: crate::datadogV2::model::ConvertJobResultsToSignalsRequest,
) -> Result<datadog::ResponseContent<()>, datadog::Error<ConvertJobResultToSignalError>> {
let local_configuration = &self.config;
let operation_id = "v2.convert_job_result_to_signal";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.convert_job_result_to_signal' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/siem-historical-detections/jobs/signal_convert",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<ConvertJobResultToSignalError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Convert a rule that doesn't (yet) exist from JSON to Terraform for Datadog provider
/// resource `datadog_security_monitoring_rule`. You can do so for the following rule types:
/// - App and API Protection
/// - Cloud SIEM (log detection and signal correlation)
/// - Workload Protection
///
/// You can convert Cloud Security configuration rules using Terraform's [Datadog Cloud Configuration Rule resource](<https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/cloud_configuration_rule>).
pub async fn convert_security_monitoring_rule_from_json_to_terraform(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleConvertPayload,
) -> Result<
crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
datadog::Error<ConvertSecurityMonitoringRuleFromJSONToTerraformError>,
> {
match self
.convert_security_monitoring_rule_from_json_to_terraform_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Convert a rule that doesn't (yet) exist from JSON to Terraform for Datadog provider
/// resource `datadog_security_monitoring_rule`. You can do so for the following rule types:
/// - App and API Protection
/// - Cloud SIEM (log detection and signal correlation)
/// - Workload Protection
///
/// You can convert Cloud Security configuration rules using Terraform's [Datadog Cloud Configuration Rule resource](<https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/cloud_configuration_rule>).
pub async fn convert_security_monitoring_rule_from_json_to_terraform_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleConvertPayload,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleConvertResponse>,
datadog::Error<ConvertSecurityMonitoringRuleFromJSONToTerraformError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.convert_security_monitoring_rule_from_json_to_terraform";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules/convert",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ConvertSecurityMonitoringRuleFromJSONToTerraformError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Convert a security monitoring resource that doesn't (yet) exist from JSON to Terraform.
/// The `resource_type` path parameter specifies the type of resource to convert
/// and must be one of `suppressions` or `critical_assets`.
pub async fn convert_security_monitoring_terraform_resource(
&self,
resource_type: crate::datadogV2::model::SecurityMonitoringTerraformResourceType,
body: crate::datadogV2::model::SecurityMonitoringTerraformConvertRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringTerraformExportResponse,
datadog::Error<ConvertSecurityMonitoringTerraformResourceError>,
> {
match self
.convert_security_monitoring_terraform_resource_with_http_info(resource_type, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Convert a security monitoring resource that doesn't (yet) exist from JSON to Terraform.
/// The `resource_type` path parameter specifies the type of resource to convert
/// and must be one of `suppressions` or `critical_assets`.
pub async fn convert_security_monitoring_terraform_resource_with_http_info(
&self,
resource_type: crate::datadogV2::model::SecurityMonitoringTerraformResourceType,
body: crate::datadogV2::model::SecurityMonitoringTerraformConvertRequest,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringTerraformExportResponse,
>,
datadog::Error<ConvertSecurityMonitoringTerraformResourceError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.convert_security_monitoring_terraform_resource";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.convert_security_monitoring_terraform_resource' is not enabled"
.to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/terraform/{resource_type}/convert",
local_configuration.get_operation_host(operation_id),
resource_type = datadog::urlencode(resource_type.to_string())
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringTerraformExportResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ConvertSecurityMonitoringTerraformResourceError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Create cases for security findings.
/// You can create up to 50 cases per request and associate up to 50 security findings per case. Security findings that are already attached to another case will be detached from their previous case and attached to the newly created case.
pub async fn create_cases(
&self,
body: crate::datadogV2::model::CreateCaseRequestArray,
) -> Result<crate::datadogV2::model::FindingCaseResponseArray, datadog::Error<CreateCasesError>>
{
match self.create_cases_with_http_info(body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Create cases for security findings.
/// You can create up to 50 cases per request and associate up to 50 security findings per case. Security findings that are already attached to another case will be detached from their previous case and attached to the newly created case.
pub async fn create_cases_with_http_info(
&self,
body: crate::datadogV2::model::CreateCaseRequestArray,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::FindingCaseResponseArray>,
datadog::Error<CreateCasesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.create_cases";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/findings/cases",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::FindingCaseResponseArray>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<CreateCasesError> = serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Create a custom framework.
pub async fn create_custom_framework(
&self,
body: crate::datadogV2::model::CreateCustomFrameworkRequest,
) -> Result<
crate::datadogV2::model::CreateCustomFrameworkResponse,
datadog::Error<CreateCustomFrameworkError>,
> {
match self.create_custom_framework_with_http_info(body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Create a custom framework.
pub async fn create_custom_framework_with_http_info(
&self,
body: crate::datadogV2::model::CreateCustomFrameworkRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::CreateCustomFrameworkResponse>,
datadog::Error<CreateCustomFrameworkError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.create_custom_framework";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/cloud_security_management/custom_frameworks",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::CreateCustomFrameworkResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<CreateCustomFrameworkError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Create Jira issues for security findings.
/// This operation creates a case in Datadog and a Jira issue linked to that case for bidirectional sync between Datadog and Jira. To configure the Jira integration, see [Bidirectional ticket syncing with Jira](<https://docs.datadoghq.com/security/ticketing_integrations/#bidirectional-ticket-syncing-with-jira>). You can create up to 50 Jira issues per request and associate up to 50 security findings per Jira issue. Security findings that are already attached to another Jira issue will be detached from their previous Jira issue and attached to the newly created Jira issue.
pub async fn create_jira_issues(
&self,
body: crate::datadogV2::model::CreateJiraIssueRequestArray,
) -> Result<
crate::datadogV2::model::FindingCaseResponseArray,
datadog::Error<CreateJiraIssuesError>,
> {
match self.create_jira_issues_with_http_info(body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Create Jira issues for security findings.
/// This operation creates a case in Datadog and a Jira issue linked to that case for bidirectional sync between Datadog and Jira. To configure the Jira integration, see [Bidirectional ticket syncing with Jira](<https://docs.datadoghq.com/security/ticketing_integrations/#bidirectional-ticket-syncing-with-jira>). You can create up to 50 Jira issues per request and associate up to 50 security findings per Jira issue. Security findings that are already attached to another Jira issue will be detached from their previous Jira issue and attached to the newly created Jira issue.
pub async fn create_jira_issues_with_http_info(
&self,
body: crate::datadogV2::model::CreateJiraIssueRequestArray,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::FindingCaseResponseArray>,
datadog::Error<CreateJiraIssuesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.create_jira_issues";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/findings/jira_issues",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::FindingCaseResponseArray>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<CreateJiraIssuesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Create a security filter.
///
/// See the [security filter guide](<https://docs.datadoghq.com/security_platform/guide/how-to-setup-security-filters-using-security-monitoring-api/>)
/// for more examples.
pub async fn create_security_filter(
&self,
body: crate::datadogV2::model::SecurityFilterCreateRequest,
) -> Result<
crate::datadogV2::model::SecurityFilterResponse,
datadog::Error<CreateSecurityFilterError>,
> {
match self.create_security_filter_with_http_info(body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Create a security filter.
///
/// See the [security filter guide](<https://docs.datadoghq.com/security_platform/guide/how-to-setup-security-filters-using-security-monitoring-api/>)
/// for more examples.
pub async fn create_security_filter_with_http_info(
&self,
body: crate::datadogV2::model::SecurityFilterCreateRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
datadog::Error<CreateSecurityFilterError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.create_security_filter";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/security_filters",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<CreateSecurityFilterError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Create a new critical asset.
pub async fn create_security_monitoring_critical_asset(
&self,
body: crate::datadogV2::model::SecurityMonitoringCriticalAssetCreateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringCriticalAssetResponse,
datadog::Error<CreateSecurityMonitoringCriticalAssetError>,
> {
match self
.create_security_monitoring_critical_asset_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Create a new critical asset.
pub async fn create_security_monitoring_critical_asset_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringCriticalAssetCreateRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringCriticalAssetResponse>,
datadog::Error<CreateSecurityMonitoringCriticalAssetError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.create_security_monitoring_critical_asset";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/critical_assets",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringCriticalAssetResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<CreateSecurityMonitoringCriticalAssetError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Create a detection rule.
pub async fn create_security_monitoring_rule(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
) -> Result<
crate::datadogV2::model::SecurityMonitoringRuleResponse,
datadog::Error<CreateSecurityMonitoringRuleError>,
> {
match self
.create_security_monitoring_rule_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Create a detection rule.
pub async fn create_security_monitoring_rule_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
datadog::Error<CreateSecurityMonitoringRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.create_security_monitoring_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<CreateSecurityMonitoringRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Create a new suppression rule.
pub async fn create_security_monitoring_suppression(
&self,
body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
datadog::Error<CreateSecurityMonitoringSuppressionError>,
> {
match self
.create_security_monitoring_suppression_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Create a new suppression rule.
pub async fn create_security_monitoring_suppression_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
datadog::Error<CreateSecurityMonitoringSuppressionError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.create_security_monitoring_suppression";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/suppressions",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<CreateSecurityMonitoringSuppressionError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Create a new notification rule for security signals and return the created rule.
pub async fn create_signal_notification_rule(
&self,
body: crate::datadogV2::model::CreateNotificationRuleParameters,
) -> Result<
crate::datadogV2::model::NotificationRuleResponse,
datadog::Error<CreateSignalNotificationRuleError>,
> {
match self
.create_signal_notification_rule_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Create a new notification rule for security signals and return the created rule.
pub async fn create_signal_notification_rule_with_http_info(
&self,
body: crate::datadogV2::model::CreateNotificationRuleParameters,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
datadog::Error<CreateSignalNotificationRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.create_signal_notification_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/signals/notification_rules",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<CreateSignalNotificationRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Create a new notification rule for security vulnerabilities and return the created rule.
pub async fn create_vulnerability_notification_rule(
&self,
body: crate::datadogV2::model::CreateNotificationRuleParameters,
) -> Result<
crate::datadogV2::model::NotificationRuleResponse,
datadog::Error<CreateVulnerabilityNotificationRuleError>,
> {
match self
.create_vulnerability_notification_rule_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Create a new notification rule for security vulnerabilities and return the created rule.
pub async fn create_vulnerability_notification_rule_with_http_info(
&self,
body: crate::datadogV2::model::CreateNotificationRuleParameters,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
datadog::Error<CreateVulnerabilityNotificationRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.create_vulnerability_notification_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/vulnerabilities/notification_rules",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<CreateVulnerabilityNotificationRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Deactivate a Cloud SIEM content pack. This operation removes the content pack's
/// configuration from log filters or security filters and updates the content pack activation state.
pub async fn deactivate_content_pack(
&self,
content_pack_id: String,
) -> Result<(), datadog::Error<DeactivateContentPackError>> {
match self
.deactivate_content_pack_with_http_info(content_pack_id)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Deactivate a Cloud SIEM content pack. This operation removes the content pack's
/// configuration from log filters or security filters and updates the content pack activation state.
pub async fn deactivate_content_pack_with_http_info(
&self,
content_pack_id: String,
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeactivateContentPackError>> {
let local_configuration = &self.config;
let operation_id = "v2.deactivate_content_pack";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.deactivate_content_pack' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/content_packs/{content_pack_id}/deactivate",
local_configuration.get_operation_host(operation_id),
content_pack_id = datadog::urlencode(content_pack_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeactivateContentPackError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Delete a custom framework.
pub async fn delete_custom_framework(
&self,
handle: String,
version: String,
) -> Result<
crate::datadogV2::model::DeleteCustomFrameworkResponse,
datadog::Error<DeleteCustomFrameworkError>,
> {
match self
.delete_custom_framework_with_http_info(handle, version)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Delete a custom framework.
pub async fn delete_custom_framework_with_http_info(
&self,
handle: String,
version: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::DeleteCustomFrameworkResponse>,
datadog::Error<DeleteCustomFrameworkError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.delete_custom_framework";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/cloud_security_management/custom_frameworks/{handle}/{version}",
local_configuration.get_operation_host(operation_id),
handle = datadog::urlencode(handle),
version = datadog::urlencode(version)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::DeleteCustomFrameworkResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<DeleteCustomFrameworkError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Delete an existing job.
pub async fn delete_historical_job(
&self,
job_id: String,
) -> Result<(), datadog::Error<DeleteHistoricalJobError>> {
match self.delete_historical_job_with_http_info(job_id).await {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Delete an existing job.
pub async fn delete_historical_job_with_http_info(
&self,
job_id: String,
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteHistoricalJobError>> {
let local_configuration = &self.config;
let operation_id = "v2.delete_historical_job";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.delete_historical_job' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/siem-historical-detections/jobs/{job_id}",
local_configuration.get_operation_host(operation_id),
job_id = datadog::urlencode(job_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeleteHistoricalJobError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Delete a specific security filter.
pub async fn delete_security_filter(
&self,
security_filter_id: String,
) -> Result<(), datadog::Error<DeleteSecurityFilterError>> {
match self
.delete_security_filter_with_http_info(security_filter_id)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Delete a specific security filter.
pub async fn delete_security_filter_with_http_info(
&self,
security_filter_id: String,
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSecurityFilterError>> {
let local_configuration = &self.config;
let operation_id = "v2.delete_security_filter";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
local_configuration.get_operation_host(operation_id),
security_filter_id = datadog::urlencode(security_filter_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeleteSecurityFilterError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Delete a specific critical asset.
pub async fn delete_security_monitoring_critical_asset(
&self,
critical_asset_id: String,
) -> Result<(), datadog::Error<DeleteSecurityMonitoringCriticalAssetError>> {
match self
.delete_security_monitoring_critical_asset_with_http_info(critical_asset_id)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Delete a specific critical asset.
pub async fn delete_security_monitoring_critical_asset_with_http_info(
&self,
critical_asset_id: String,
) -> Result<
datadog::ResponseContent<()>,
datadog::Error<DeleteSecurityMonitoringCriticalAssetError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.delete_security_monitoring_critical_asset";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/critical_assets/{critical_asset_id}",
local_configuration.get_operation_host(operation_id),
critical_asset_id = datadog::urlencode(critical_asset_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeleteSecurityMonitoringCriticalAssetError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Delete an existing rule. Default rules cannot be deleted.
pub async fn delete_security_monitoring_rule(
&self,
rule_id: String,
) -> Result<(), datadog::Error<DeleteSecurityMonitoringRuleError>> {
match self
.delete_security_monitoring_rule_with_http_info(rule_id)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Delete an existing rule. Default rules cannot be deleted.
pub async fn delete_security_monitoring_rule_with_http_info(
&self,
rule_id: String,
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSecurityMonitoringRuleError>>
{
let local_configuration = &self.config;
let operation_id = "v2.delete_security_monitoring_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules/{rule_id}",
local_configuration.get_operation_host(operation_id),
rule_id = datadog::urlencode(rule_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeleteSecurityMonitoringRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Delete a specific suppression rule.
pub async fn delete_security_monitoring_suppression(
&self,
suppression_id: String,
) -> Result<(), datadog::Error<DeleteSecurityMonitoringSuppressionError>> {
match self
.delete_security_monitoring_suppression_with_http_info(suppression_id)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Delete a specific suppression rule.
pub async fn delete_security_monitoring_suppression_with_http_info(
&self,
suppression_id: String,
) -> Result<
datadog::ResponseContent<()>,
datadog::Error<DeleteSecurityMonitoringSuppressionError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.delete_security_monitoring_suppression";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
local_configuration.get_operation_host(operation_id),
suppression_id = datadog::urlencode(suppression_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeleteSecurityMonitoringSuppressionError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Delete a notification rule for security signals.
pub async fn delete_signal_notification_rule(
&self,
id: String,
) -> Result<(), datadog::Error<DeleteSignalNotificationRuleError>> {
match self
.delete_signal_notification_rule_with_http_info(id)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Delete a notification rule for security signals.
pub async fn delete_signal_notification_rule_with_http_info(
&self,
id: String,
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSignalNotificationRuleError>>
{
let local_configuration = &self.config;
let operation_id = "v2.delete_signal_notification_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/signals/notification_rules/{id}",
local_configuration.get_operation_host(operation_id),
id = datadog::urlencode(id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeleteSignalNotificationRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Delete a notification rule for security vulnerabilities.
pub async fn delete_vulnerability_notification_rule(
&self,
id: String,
) -> Result<(), datadog::Error<DeleteVulnerabilityNotificationRuleError>> {
match self
.delete_vulnerability_notification_rule_with_http_info(id)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Delete a notification rule for security vulnerabilities.
pub async fn delete_vulnerability_notification_rule_with_http_info(
&self,
id: String,
) -> Result<
datadog::ResponseContent<()>,
datadog::Error<DeleteVulnerabilityNotificationRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.delete_vulnerability_notification_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/vulnerabilities/notification_rules/{id}",
local_configuration.get_operation_host(operation_id),
id = datadog::urlencode(id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeleteVulnerabilityNotificationRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Detach security findings from their case.
/// This operation dissociates security findings from their associated cases without deleting the cases themselves. You can detach security findings from multiple different cases in a single request, with a limit of 50 security findings per request. Security findings that are not currently attached to any case will be ignored.
pub async fn detach_case(
&self,
body: crate::datadogV2::model::DetachCaseRequest,
) -> Result<(), datadog::Error<DetachCaseError>> {
match self.detach_case_with_http_info(body).await {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Detach security findings from their case.
/// This operation dissociates security findings from their associated cases without deleting the cases themselves. You can detach security findings from multiple different cases in a single request, with a limit of 50 security findings per request. Security findings that are not currently attached to any case will be ignored.
pub async fn detach_case_with_http_info(
&self,
body: crate::datadogV2::model::DetachCaseRequest,
) -> Result<datadog::ResponseContent<()>, datadog::Error<DetachCaseError>> {
let local_configuration = &self.config;
let operation_id = "v2.detach_case";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/findings/cases",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DetachCaseError> = serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Update the triage state or assignee of a security signal.
pub async fn edit_security_monitoring_signal(
&self,
signal_id: String,
body: crate::datadogV2::model::SecurityMonitoringSignalUpdateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
datadog::Error<EditSecurityMonitoringSignalError>,
> {
match self
.edit_security_monitoring_signal_with_http_info(signal_id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Update the triage state or assignee of a security signal.
pub async fn edit_security_monitoring_signal_with_http_info(
&self,
signal_id: String,
body: crate::datadogV2::model::SecurityMonitoringSignalUpdateRequest,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
>,
datadog::Error<EditSecurityMonitoringSignalError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.edit_security_monitoring_signal";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/{signal_id}/update",
local_configuration.get_operation_host(operation_id),
signal_id = datadog::urlencode(signal_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<EditSecurityMonitoringSignalError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Modify the triage assignee of a security signal.
pub async fn edit_security_monitoring_signal_assignee(
&self,
signal_id: String,
body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
datadog::Error<EditSecurityMonitoringSignalAssigneeError>,
> {
match self
.edit_security_monitoring_signal_assignee_with_http_info(signal_id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Modify the triage assignee of a security signal.
pub async fn edit_security_monitoring_signal_assignee_with_http_info(
&self,
signal_id: String,
body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
>,
datadog::Error<EditSecurityMonitoringSignalAssigneeError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.edit_security_monitoring_signal_assignee";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/{signal_id}/assignee",
local_configuration.get_operation_host(operation_id),
signal_id = datadog::urlencode(signal_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<EditSecurityMonitoringSignalAssigneeError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Change the related incidents for a security signal.
pub async fn edit_security_monitoring_signal_incidents(
&self,
signal_id: String,
body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
datadog::Error<EditSecurityMonitoringSignalIncidentsError>,
> {
match self
.edit_security_monitoring_signal_incidents_with_http_info(signal_id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Change the related incidents for a security signal.
pub async fn edit_security_monitoring_signal_incidents_with_http_info(
&self,
signal_id: String,
body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
>,
datadog::Error<EditSecurityMonitoringSignalIncidentsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.edit_security_monitoring_signal_incidents";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/{signal_id}/incidents",
local_configuration.get_operation_host(operation_id),
signal_id = datadog::urlencode(signal_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<EditSecurityMonitoringSignalIncidentsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Change the triage state of a security signal.
pub async fn edit_security_monitoring_signal_state(
&self,
signal_id: String,
body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
datadog::Error<EditSecurityMonitoringSignalStateError>,
> {
match self
.edit_security_monitoring_signal_state_with_http_info(signal_id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Change the triage state of a security signal.
pub async fn edit_security_monitoring_signal_state_with_http_info(
&self,
signal_id: String,
body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
>,
datadog::Error<EditSecurityMonitoringSignalStateError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.edit_security_monitoring_signal_state";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/{signal_id}/state",
local_configuration.get_operation_host(operation_id),
signal_id = datadog::urlencode(signal_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<EditSecurityMonitoringSignalStateError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Export a security monitoring resource to a Terraform configuration.
/// The `resource_type` path parameter specifies the type of resource to export
/// and must be one of `suppressions` or `critical_assets`.
pub async fn export_security_monitoring_terraform_resource(
&self,
resource_type: crate::datadogV2::model::SecurityMonitoringTerraformResourceType,
resource_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringTerraformExportResponse,
datadog::Error<ExportSecurityMonitoringTerraformResourceError>,
> {
match self
.export_security_monitoring_terraform_resource_with_http_info(
resource_type,
resource_id,
)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Export a security monitoring resource to a Terraform configuration.
/// The `resource_type` path parameter specifies the type of resource to export
/// and must be one of `suppressions` or `critical_assets`.
pub async fn export_security_monitoring_terraform_resource_with_http_info(
&self,
resource_type: crate::datadogV2::model::SecurityMonitoringTerraformResourceType,
resource_id: String,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringTerraformExportResponse,
>,
datadog::Error<ExportSecurityMonitoringTerraformResourceError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.export_security_monitoring_terraform_resource";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.export_security_monitoring_terraform_resource' is not enabled"
.to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/terraform/{resource_type}/{resource_id}",
local_configuration.get_operation_host(operation_id),
resource_type = datadog::urlencode(resource_type.to_string()),
resource_id = datadog::urlencode(resource_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringTerraformExportResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ExportSecurityMonitoringTerraformResourceError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the activation state, integration status, and log collection status
/// for all Cloud SIEM content packs.
pub async fn get_content_packs_states(
&self,
) -> Result<
crate::datadogV2::model::SecurityMonitoringContentPackStatesResponse,
datadog::Error<GetContentPacksStatesError>,
> {
match self.get_content_packs_states_with_http_info().await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the activation state, integration status, and log collection status
/// for all Cloud SIEM content packs.
pub async fn get_content_packs_states_with_http_info(
&self,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringContentPackStatesResponse,
>,
datadog::Error<GetContentPacksStatesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_content_packs_states";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_content_packs_states' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/content_packs/states",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringContentPackStatesResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetContentPacksStatesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the list of critical assets that affect a specific existing rule by the rule's ID.
pub async fn get_critical_assets_affecting_rule(
&self,
rule_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringCriticalAssetsResponse,
datadog::Error<GetCriticalAssetsAffectingRuleError>,
> {
match self
.get_critical_assets_affecting_rule_with_http_info(rule_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the list of critical assets that affect a specific existing rule by the rule's ID.
pub async fn get_critical_assets_affecting_rule_with_http_info(
&self,
rule_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringCriticalAssetsResponse>,
datadog::Error<GetCriticalAssetsAffectingRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_critical_assets_affecting_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/critical_assets/rules/{rule_id}",
local_configuration.get_operation_host(operation_id),
rule_id = datadog::urlencode(rule_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringCriticalAssetsResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetCriticalAssetsAffectingRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a custom framework.
pub async fn get_custom_framework(
&self,
handle: String,
version: String,
) -> Result<
crate::datadogV2::model::GetCustomFrameworkResponse,
datadog::Error<GetCustomFrameworkError>,
> {
match self
.get_custom_framework_with_http_info(handle, version)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a custom framework.
pub async fn get_custom_framework_with_http_info(
&self,
handle: String,
version: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::GetCustomFrameworkResponse>,
datadog::Error<GetCustomFrameworkError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_custom_framework";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/cloud_security_management/custom_frameworks/{handle}/{version}",
local_configuration.get_operation_host(operation_id),
handle = datadog::urlencode(handle),
version = datadog::urlencode(version)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::GetCustomFrameworkResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetCustomFrameworkError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Returns a single finding with message and resource configuration.
pub async fn get_finding(
&self,
finding_id: String,
params: GetFindingOptionalParams,
) -> Result<crate::datadogV2::model::GetFindingResponse, datadog::Error<GetFindingError>> {
match self.get_finding_with_http_info(finding_id, params).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Returns a single finding with message and resource configuration.
pub async fn get_finding_with_http_info(
&self,
finding_id: String,
params: GetFindingOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::GetFindingResponse>,
datadog::Error<GetFindingError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_finding";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_finding' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let snapshot_timestamp = params.snapshot_timestamp;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/posture_management/findings/{finding_id}",
local_configuration.get_operation_host(operation_id),
finding_id = datadog::urlencode(finding_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = snapshot_timestamp {
local_req_builder =
local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::GetFindingResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetFindingError> = serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a job's details.
pub async fn get_historical_job(
&self,
job_id: String,
) -> Result<crate::datadogV2::model::HistoricalJobResponse, datadog::Error<GetHistoricalJobError>>
{
match self.get_historical_job_with_http_info(job_id).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a job's details.
pub async fn get_historical_job_with_http_info(
&self,
job_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::HistoricalJobResponse>,
datadog::Error<GetHistoricalJobError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_historical_job";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_historical_job' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/siem-historical-detections/jobs/{job_id}",
local_configuration.get_operation_host(operation_id),
job_id = datadog::urlencode(job_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::HistoricalJobResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetHistoricalJobError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get detailed information about a specific indicator of compromise (IoC).
pub async fn get_indicator_of_compromise(
&self,
indicator: String,
) -> Result<
crate::datadogV2::model::GetIoCIndicatorResponse,
datadog::Error<GetIndicatorOfCompromiseError>,
> {
match self
.get_indicator_of_compromise_with_http_info(indicator)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get detailed information about a specific indicator of compromise (IoC).
pub async fn get_indicator_of_compromise_with_http_info(
&self,
indicator: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::GetIoCIndicatorResponse>,
datadog::Error<GetIndicatorOfCompromiseError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_indicator_of_compromise";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_indicator_of_compromise' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/siem/ioc-explorer/indicator",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
local_req_builder = local_req_builder.query(&[("indicator", &indicator.to_string())]);
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::GetIoCIndicatorResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetIndicatorOfCompromiseError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the list of investigation log queries available for a given security signal.
pub async fn get_investigation_log_queries_matching_signal(
&self,
signal_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalSuggestedActionsResponse,
datadog::Error<GetInvestigationLogQueriesMatchingSignalError>,
> {
match self
.get_investigation_log_queries_matching_signal_with_http_info(signal_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the list of investigation log queries available for a given security signal.
pub async fn get_investigation_log_queries_matching_signal_with_http_info(
&self,
signal_id: String,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringSignalSuggestedActionsResponse,
>,
datadog::Error<GetInvestigationLogQueriesMatchingSignalError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_investigation_log_queries_matching_signal";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/{signal_id}/investigation_queries",
local_configuration.get_operation_host(operation_id),
signal_id = datadog::urlencode(signal_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalSuggestedActionsResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetInvestigationLogQueriesMatchingSignalError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// List resource filters.
pub async fn get_resource_evaluation_filters(
&self,
params: GetResourceEvaluationFiltersOptionalParams,
) -> Result<
crate::datadogV2::model::GetResourceEvaluationFiltersResponse,
datadog::Error<GetResourceEvaluationFiltersError>,
> {
match self
.get_resource_evaluation_filters_with_http_info(params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// List resource filters.
pub async fn get_resource_evaluation_filters_with_http_info(
&self,
params: GetResourceEvaluationFiltersOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::GetResourceEvaluationFiltersResponse>,
datadog::Error<GetResourceEvaluationFiltersError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_resource_evaluation_filters";
// unbox and build optional parameters
let cloud_provider = params.cloud_provider;
let account_id = params.account_id;
let skip_cache = params.skip_cache;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/cloud_security_management/resource_filters",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = cloud_provider {
local_req_builder =
local_req_builder.query(&[("cloud_provider", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = account_id {
local_req_builder =
local_req_builder.query(&[("account_id", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = skip_cache {
local_req_builder =
local_req_builder.query(&[("skip_cache", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::GetResourceEvaluationFiltersResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetResourceEvaluationFiltersError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a rule's version history.
pub async fn get_rule_version_history(
&self,
rule_id: String,
params: GetRuleVersionHistoryOptionalParams,
) -> Result<
crate::datadogV2::model::GetRuleVersionHistoryResponse,
datadog::Error<GetRuleVersionHistoryError>,
> {
match self
.get_rule_version_history_with_http_info(rule_id, params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a rule's version history.
pub async fn get_rule_version_history_with_http_info(
&self,
rule_id: String,
params: GetRuleVersionHistoryOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::GetRuleVersionHistoryResponse>,
datadog::Error<GetRuleVersionHistoryError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_rule_version_history";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_rule_version_history' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let page_size = params.page_size;
let page_number = params.page_number;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules/{rule_id}/version_history",
local_configuration.get_operation_host(operation_id),
rule_id = datadog::urlencode(rule_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = page_size {
local_req_builder =
local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_number {
local_req_builder =
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::GetRuleVersionHistoryResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetRuleVersionHistoryError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a single SBOM related to an asset by its type and name.
pub async fn get_sbom(
&self,
asset_type: crate::datadogV2::model::AssetType,
filter_asset_name: String,
params: GetSBOMOptionalParams,
) -> Result<crate::datadogV2::model::GetSBOMResponse, datadog::Error<GetSBOMError>> {
match self
.get_sbom_with_http_info(asset_type, filter_asset_name, params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a single SBOM related to an asset by its type and name.
pub async fn get_sbom_with_http_info(
&self,
asset_type: crate::datadogV2::model::AssetType,
filter_asset_name: String,
params: GetSBOMOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::GetSBOMResponse>,
datadog::Error<GetSBOMError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_sbom";
// unbox and build optional parameters
let filter_repo_digest = params.filter_repo_digest;
let ext_format = params.ext_format;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/sboms/{asset_type}",
local_configuration.get_operation_host(operation_id),
asset_type = datadog::urlencode(asset_type.to_string())
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
local_req_builder =
local_req_builder.query(&[("filter[asset_name]", &filter_asset_name.to_string())]);
if let Some(ref local_query_param) = filter_repo_digest {
local_req_builder =
local_req_builder.query(&[("filter[repo_digest]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = ext_format {
local_req_builder =
local_req_builder.query(&[("ext:format", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::GetSBOMResponse>(&local_content) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSBOMError> = serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Returns a list of Secrets rules with ID, Pattern, Description, Priority, and SDS ID.
pub async fn get_secrets_rules(
&self,
) -> Result<crate::datadogV2::model::SecretRuleArray, datadog::Error<GetSecretsRulesError>>
{
match self.get_secrets_rules_with_http_info().await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Returns a list of Secrets rules with ID, Pattern, Description, Priority, and SDS ID.
pub async fn get_secrets_rules_with_http_info(
&self,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecretRuleArray>,
datadog::Error<GetSecretsRulesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_secrets_rules";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_secrets_rules' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/static-analysis/secrets/rules",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecretRuleArray>(&local_content) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSecretsRulesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the details of a specific security filter.
///
/// See the [security filter guide](<https://docs.datadoghq.com/security_platform/guide/how-to-setup-security-filters-using-security-monitoring-api/>)
/// for more examples.
pub async fn get_security_filter(
&self,
security_filter_id: String,
) -> Result<
crate::datadogV2::model::SecurityFilterResponse,
datadog::Error<GetSecurityFilterError>,
> {
match self
.get_security_filter_with_http_info(security_filter_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the details of a specific security filter.
///
/// See the [security filter guide](<https://docs.datadoghq.com/security_platform/guide/how-to-setup-security-filters-using-security-monitoring-api/>)
/// for more examples.
pub async fn get_security_filter_with_http_info(
&self,
security_filter_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
datadog::Error<GetSecurityFilterError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_security_filter";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
local_configuration.get_operation_host(operation_id),
security_filter_id = datadog::urlencode(security_filter_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSecurityFilterError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the details of a specific critical asset.
pub async fn get_security_monitoring_critical_asset(
&self,
critical_asset_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringCriticalAssetResponse,
datadog::Error<GetSecurityMonitoringCriticalAssetError>,
> {
match self
.get_security_monitoring_critical_asset_with_http_info(critical_asset_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the details of a specific critical asset.
pub async fn get_security_monitoring_critical_asset_with_http_info(
&self,
critical_asset_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringCriticalAssetResponse>,
datadog::Error<GetSecurityMonitoringCriticalAssetError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_security_monitoring_critical_asset";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/critical_assets/{critical_asset_id}",
local_configuration.get_operation_host(operation_id),
critical_asset_id = datadog::urlencode(critical_asset_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringCriticalAssetResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSecurityMonitoringCriticalAssetError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a hist signal's details.
pub async fn get_security_monitoring_histsignal(
&self,
histsignal_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalResponse,
datadog::Error<GetSecurityMonitoringHistsignalError>,
> {
match self
.get_security_monitoring_histsignal_with_http_info(histsignal_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a hist signal's details.
pub async fn get_security_monitoring_histsignal_with_http_info(
&self,
histsignal_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalResponse>,
datadog::Error<GetSecurityMonitoringHistsignalError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_security_monitoring_histsignal";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_security_monitoring_histsignal' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/siem-historical-detections/histsignals/{histsignal_id}",
local_configuration.get_operation_host(operation_id),
histsignal_id = datadog::urlencode(histsignal_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringSignalResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSecurityMonitoringHistsignalError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a job's hist signals.
pub async fn get_security_monitoring_histsignals_by_job_id(
&self,
job_id: String,
params: GetSecurityMonitoringHistsignalsByJobIdOptionalParams,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
datadog::Error<GetSecurityMonitoringHistsignalsByJobIdError>,
> {
match self
.get_security_monitoring_histsignals_by_job_id_with_http_info(job_id, params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a job's hist signals.
pub async fn get_security_monitoring_histsignals_by_job_id_with_http_info(
&self,
job_id: String,
params: GetSecurityMonitoringHistsignalsByJobIdOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
datadog::Error<GetSecurityMonitoringHistsignalsByJobIdError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_security_monitoring_histsignals_by_job_id";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_security_monitoring_histsignals_by_job_id' is not enabled"
.to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let filter_query = params.filter_query;
let filter_from = params.filter_from;
let filter_to = params.filter_to;
let sort = params.sort;
let page_cursor = params.page_cursor;
let page_limit = params.page_limit;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/siem-historical-detections/jobs/{job_id}/histsignals",
local_configuration.get_operation_host(operation_id),
job_id = datadog::urlencode(job_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = filter_query {
local_req_builder =
local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_from {
local_req_builder = local_req_builder.query(&[(
"filter[from]",
&local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
)]);
};
if let Some(ref local_query_param) = filter_to {
local_req_builder = local_req_builder.query(&[(
"filter[to]",
&local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
)]);
};
if let Some(ref local_query_param) = sort {
local_req_builder =
local_req_builder.query(&[("sort", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_cursor {
local_req_builder =
local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_limit {
local_req_builder =
local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSecurityMonitoringHistsignalsByJobIdError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a rule's details.
pub async fn get_security_monitoring_rule(
&self,
rule_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringRuleResponse,
datadog::Error<GetSecurityMonitoringRuleError>,
> {
match self
.get_security_monitoring_rule_with_http_info(rule_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a rule's details.
pub async fn get_security_monitoring_rule_with_http_info(
&self,
rule_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
datadog::Error<GetSecurityMonitoringRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_security_monitoring_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules/{rule_id}",
local_configuration.get_operation_host(operation_id),
rule_id = datadog::urlencode(rule_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSecurityMonitoringRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a signal's details.
pub async fn get_security_monitoring_signal(
&self,
signal_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalResponse,
datadog::Error<GetSecurityMonitoringSignalError>,
> {
match self
.get_security_monitoring_signal_with_http_info(signal_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a signal's details.
pub async fn get_security_monitoring_signal_with_http_info(
&self,
signal_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalResponse>,
datadog::Error<GetSecurityMonitoringSignalError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_security_monitoring_signal";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/{signal_id}",
local_configuration.get_operation_host(operation_id),
signal_id = datadog::urlencode(signal_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringSignalResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSecurityMonitoringSignalError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the details of a specific suppression rule.
pub async fn get_security_monitoring_suppression(
&self,
suppression_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
datadog::Error<GetSecurityMonitoringSuppressionError>,
> {
match self
.get_security_monitoring_suppression_with_http_info(suppression_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the details of a specific suppression rule.
pub async fn get_security_monitoring_suppression_with_http_info(
&self,
suppression_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
datadog::Error<GetSecurityMonitoringSuppressionError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_security_monitoring_suppression";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
local_configuration.get_operation_host(operation_id),
suppression_id = datadog::urlencode(suppression_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSecurityMonitoringSuppressionError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the details of a notification rule for security signals.
pub async fn get_signal_notification_rule(
&self,
id: String,
) -> Result<
crate::datadogV2::model::NotificationRuleResponse,
datadog::Error<GetSignalNotificationRuleError>,
> {
match self.get_signal_notification_rule_with_http_info(id).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the details of a notification rule for security signals.
pub async fn get_signal_notification_rule_with_http_info(
&self,
id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
datadog::Error<GetSignalNotificationRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_signal_notification_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/signals/notification_rules/{id}",
local_configuration.get_operation_host(operation_id),
id = datadog::urlencode(id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSignalNotificationRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Returns the list of notification rules for security signals.
pub async fn get_signal_notification_rules(
&self,
) -> Result<
std::collections::BTreeMap<String, serde_json::Value>,
datadog::Error<GetSignalNotificationRulesError>,
> {
match self.get_signal_notification_rules_with_http_info().await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Returns the list of notification rules for security signals.
pub async fn get_signal_notification_rules_with_http_info(
&self,
) -> Result<
datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
datadog::Error<GetSignalNotificationRulesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_signal_notification_rules";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/signals/notification_rules",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSignalNotificationRulesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the list of suggested actions for a given security signal.
pub async fn get_suggested_actions_matching_signal(
&self,
signal_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalSuggestedActionsResponse,
datadog::Error<GetSuggestedActionsMatchingSignalError>,
> {
match self
.get_suggested_actions_matching_signal_with_http_info(signal_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the list of suggested actions for a given security signal.
pub async fn get_suggested_actions_matching_signal_with_http_info(
&self,
signal_id: String,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringSignalSuggestedActionsResponse,
>,
datadog::Error<GetSuggestedActionsMatchingSignalError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_suggested_actions_matching_signal";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/{signal_id}/suggested_actions",
local_configuration.get_operation_host(operation_id),
signal_id = datadog::urlencode(signal_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalSuggestedActionsResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSuggestedActionsMatchingSignalError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a suppression's version history.
pub async fn get_suppression_version_history(
&self,
suppression_id: String,
params: GetSuppressionVersionHistoryOptionalParams,
) -> Result<
crate::datadogV2::model::GetSuppressionVersionHistoryResponse,
datadog::Error<GetSuppressionVersionHistoryError>,
> {
match self
.get_suppression_version_history_with_http_info(suppression_id, params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a suppression's version history.
pub async fn get_suppression_version_history_with_http_info(
&self,
suppression_id: String,
params: GetSuppressionVersionHistoryOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::GetSuppressionVersionHistoryResponse>,
datadog::Error<GetSuppressionVersionHistoryError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_suppression_version_history";
// unbox and build optional parameters
let page_size = params.page_size;
let page_number = params.page_number;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}/version_history",
local_configuration.get_operation_host(operation_id), suppression_id=
datadog::urlencode(suppression_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = page_size {
local_req_builder =
local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_number {
local_req_builder =
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::GetSuppressionVersionHistoryResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSuppressionVersionHistoryError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the list of suppressions that would affect a rule.
pub async fn get_suppressions_affecting_future_rule(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
datadog::Error<GetSuppressionsAffectingFutureRuleError>,
> {
match self
.get_suppressions_affecting_future_rule_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the list of suppressions that would affect a rule.
pub async fn get_suppressions_affecting_future_rule_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionsResponse>,
datadog::Error<GetSuppressionsAffectingFutureRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_suppressions_affecting_future_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/suppressions/rules",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSuppressionsAffectingFutureRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the list of suppressions that affect a specific existing rule by its ID.
pub async fn get_suppressions_affecting_rule(
&self,
rule_id: String,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
datadog::Error<GetSuppressionsAffectingRuleError>,
> {
match self
.get_suppressions_affecting_rule_with_http_info(rule_id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the list of suppressions that affect a specific existing rule by its ID.
pub async fn get_suppressions_affecting_rule_with_http_info(
&self,
rule_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionsResponse>,
datadog::Error<GetSuppressionsAffectingRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_suppressions_affecting_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/suppressions/rules/{rule_id}",
local_configuration.get_operation_host(operation_id),
rule_id = datadog::urlencode(rule_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetSuppressionsAffectingRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the details of a notification rule for security vulnerabilities.
pub async fn get_vulnerability_notification_rule(
&self,
id: String,
) -> Result<
crate::datadogV2::model::NotificationRuleResponse,
datadog::Error<GetVulnerabilityNotificationRuleError>,
> {
match self
.get_vulnerability_notification_rule_with_http_info(id)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the details of a notification rule for security vulnerabilities.
pub async fn get_vulnerability_notification_rule_with_http_info(
&self,
id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
datadog::Error<GetVulnerabilityNotificationRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_vulnerability_notification_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/vulnerabilities/notification_rules/{id}",
local_configuration.get_operation_host(operation_id),
id = datadog::urlencode(id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetVulnerabilityNotificationRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Returns the list of notification rules for security vulnerabilities.
pub async fn get_vulnerability_notification_rules(
&self,
) -> Result<
std::collections::BTreeMap<String, serde_json::Value>,
datadog::Error<GetVulnerabilityNotificationRulesError>,
> {
match self
.get_vulnerability_notification_rules_with_http_info()
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Returns the list of notification rules for security vulnerabilities.
pub async fn get_vulnerability_notification_rules_with_http_info(
&self,
) -> Result<
datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
datadog::Error<GetVulnerabilityNotificationRulesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_vulnerability_notification_rules";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/vulnerabilities/notification_rules",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<GetVulnerabilityNotificationRulesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a list of assets SBOMs for an organization.
///
/// ### Pagination
///
/// Please review the [Pagination section](#pagination) for the "List Vulnerabilities" endpoint.
///
/// ### Filtering
///
/// Please review the [Filtering section](#filtering) for the "List Vulnerabilities" endpoint.
///
/// ### Metadata
///
/// Please review the [Metadata section](#metadata) for the "List Vulnerabilities" endpoint.
pub async fn list_assets_sbo_ms(
&self,
params: ListAssetsSBOMsOptionalParams,
) -> Result<
crate::datadogV2::model::ListAssetsSBOMsResponse,
datadog::Error<ListAssetsSBOMsError>,
> {
match self.list_assets_sbo_ms_with_http_info(params).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a list of assets SBOMs for an organization.
///
/// ### Pagination
///
/// Please review the [Pagination section](#pagination) for the "List Vulnerabilities" endpoint.
///
/// ### Filtering
///
/// Please review the [Filtering section](#filtering) for the "List Vulnerabilities" endpoint.
///
/// ### Metadata
///
/// Please review the [Metadata section](#metadata) for the "List Vulnerabilities" endpoint.
pub async fn list_assets_sbo_ms_with_http_info(
&self,
params: ListAssetsSBOMsOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::ListAssetsSBOMsResponse>,
datadog::Error<ListAssetsSBOMsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_assets_sbo_ms";
// unbox and build optional parameters
let page_token = params.page_token;
let page_number = params.page_number;
let filter_asset_type = params.filter_asset_type;
let filter_asset_name = params.filter_asset_name;
let filter_package_name = params.filter_package_name;
let filter_package_version = params.filter_package_version;
let filter_license_name = params.filter_license_name;
let filter_license_type = params.filter_license_type;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/sboms",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = page_token {
local_req_builder =
local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_number {
local_req_builder =
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_type {
local_req_builder =
local_req_builder.query(&[("filter[asset_type]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_name {
local_req_builder =
local_req_builder.query(&[("filter[asset_name]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_package_name {
local_req_builder = local_req_builder
.query(&[("filter[package_name]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_package_version {
local_req_builder = local_req_builder
.query(&[("filter[package_version]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_license_name {
local_req_builder = local_req_builder
.query(&[("filter[license_name]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_license_type {
local_req_builder = local_req_builder
.query(&[("filter[license_type]", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::ListAssetsSBOMsResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListAssetsSBOMsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a list of findings. These include both misconfigurations and identity risks.
///
/// **Note**: To filter and return only identity risks, add the following query parameter: `?filter[tags]=dd_rule_type:ciem`
///
/// ### Filtering
///
/// Filters can be applied by appending query parameters to the URL.
///
/// - Using a single filter: `?filter[attribute_key]=attribute_value`
/// - Chaining filters: `?filter[attribute_key]=attribute_value&filter[attribute_key]=attribute_value...`
/// - Filtering on tags: `?filter[tags]=tag_key:tag_value&filter[tags]=tag_key_2:tag_value_2`
///
/// Here, `attribute_key` can be any of the filter keys described further below.
///
/// 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`.
///
/// You can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*` to filter for any non-AWS resources.
///
/// 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`.
///
/// 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.
///
/// ### Additional extension fields
///
/// Additional extension fields are available for some findings.
///
/// The data is available when you include the query parameter `?detailed_findings=true` in the request.
///
/// The following fields are available for findings:
/// - `external_id`: The resource external ID related to the finding.
/// - `description`: The description and remediation steps for the finding.
/// - `datadog_link`: The Datadog relative link for the finding.
/// - `ip_addresses`: The list of private IP addresses for the resource related to the finding.
///
/// ### Response
///
/// The response includes an array of finding objects, pagination metadata, and a count of items that match the query.
///
/// Each finding object contains the following:
///
/// - The finding ID that can be used in a `GetFinding` request to retrieve the full finding details.
/// - Core attributes, including status, evaluation, high-level resource details, muted state, and rule details.
/// - `evaluation_changed_at` and `resource_discovery_date` time stamps.
/// - An array of associated tags.
pub async fn list_findings(
&self,
params: ListFindingsOptionalParams,
) -> Result<crate::datadogV2::model::ListFindingsResponse, datadog::Error<ListFindingsError>>
{
match self.list_findings_with_http_info(params).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
pub fn list_findings_with_pagination(
&self,
mut params: ListFindingsOptionalParams,
) -> impl Stream<
Item = Result<crate::datadogV2::model::Finding, datadog::Error<ListFindingsError>>,
> + '_ {
try_stream! {
let mut page_size: i64 = 100;
if params.page_limit.is_none() {
params.page_limit = Some(page_size);
} else {
page_size = params.page_limit.unwrap().clone();
}
loop {
let resp = self.list_findings(params.clone()).await?;
let r = resp.data;
let count = r.len();
for team in r {
yield team;
}
if count < page_size as usize {
break;
}
let Some(page) = resp.meta.page else { break };
let Some(cursor) = page.cursor else { break };
params.page_cursor = Some(cursor);
}
}
}
/// Get a list of findings. These include both misconfigurations and identity risks.
///
/// **Note**: To filter and return only identity risks, add the following query parameter: `?filter[tags]=dd_rule_type:ciem`
///
/// ### Filtering
///
/// Filters can be applied by appending query parameters to the URL.
///
/// - Using a single filter: `?filter[attribute_key]=attribute_value`
/// - Chaining filters: `?filter[attribute_key]=attribute_value&filter[attribute_key]=attribute_value...`
/// - Filtering on tags: `?filter[tags]=tag_key:tag_value&filter[tags]=tag_key_2:tag_value_2`
///
/// Here, `attribute_key` can be any of the filter keys described further below.
///
/// 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`.
///
/// You can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*` to filter for any non-AWS resources.
///
/// 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`.
///
/// 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.
///
/// ### Additional extension fields
///
/// Additional extension fields are available for some findings.
///
/// The data is available when you include the query parameter `?detailed_findings=true` in the request.
///
/// The following fields are available for findings:
/// - `external_id`: The resource external ID related to the finding.
/// - `description`: The description and remediation steps for the finding.
/// - `datadog_link`: The Datadog relative link for the finding.
/// - `ip_addresses`: The list of private IP addresses for the resource related to the finding.
///
/// ### Response
///
/// The response includes an array of finding objects, pagination metadata, and a count of items that match the query.
///
/// Each finding object contains the following:
///
/// - The finding ID that can be used in a `GetFinding` request to retrieve the full finding details.
/// - Core attributes, including status, evaluation, high-level resource details, muted state, and rule details.
/// - `evaluation_changed_at` and `resource_discovery_date` time stamps.
/// - An array of associated tags.
pub async fn list_findings_with_http_info(
&self,
params: ListFindingsOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::ListFindingsResponse>,
datadog::Error<ListFindingsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_findings";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_findings' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let page_limit = params.page_limit;
let snapshot_timestamp = params.snapshot_timestamp;
let page_cursor = params.page_cursor;
let filter_tags = params.filter_tags;
let filter_evaluation_changed_at = params.filter_evaluation_changed_at;
let filter_muted = params.filter_muted;
let filter_rule_id = params.filter_rule_id;
let filter_rule_name = params.filter_rule_name;
let filter_resource_type = params.filter_resource_type;
let filter_resource_id = params.filter_resource_id;
let filter_discovery_timestamp = params.filter_discovery_timestamp;
let filter_evaluation = params.filter_evaluation;
let filter_status = params.filter_status;
let filter_vulnerability_type = params.filter_vulnerability_type;
let detailed_findings = params.detailed_findings;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/posture_management/findings",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = page_limit {
local_req_builder =
local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = snapshot_timestamp {
local_req_builder =
local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_cursor {
local_req_builder =
local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_tags {
local_req_builder =
local_req_builder.query(&[("filter[tags]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_evaluation_changed_at {
local_req_builder = local_req_builder.query(&[(
"filter[evaluation_changed_at]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_muted {
local_req_builder =
local_req_builder.query(&[("filter[muted]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_rule_id {
local_req_builder =
local_req_builder.query(&[("filter[rule_id]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_rule_name {
local_req_builder =
local_req_builder.query(&[("filter[rule_name]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_resource_type {
local_req_builder = local_req_builder
.query(&[("filter[resource_type]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_resource_id {
local_req_builder = local_req_builder
.query(&[("filter[@resource_id]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_discovery_timestamp {
local_req_builder = local_req_builder.query(&[(
"filter[discovery_timestamp]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_evaluation {
local_req_builder =
local_req_builder.query(&[("filter[evaluation]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_status {
local_req_builder =
local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]);
};
if let Some(ref local) = filter_vulnerability_type {
for param in local {
local_req_builder =
local_req_builder.query(&[("filter[vulnerability_type]", ¶m.to_string())]);
}
};
if let Some(ref local_query_param) = detailed_findings {
local_req_builder =
local_req_builder.query(&[("detailed_findings", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::ListFindingsResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListFindingsError> = serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// List historical jobs.
pub async fn list_historical_jobs(
&self,
params: ListHistoricalJobsOptionalParams,
) -> Result<
crate::datadogV2::model::ListHistoricalJobsResponse,
datadog::Error<ListHistoricalJobsError>,
> {
match self.list_historical_jobs_with_http_info(params).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// List historical jobs.
pub async fn list_historical_jobs_with_http_info(
&self,
params: ListHistoricalJobsOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::ListHistoricalJobsResponse>,
datadog::Error<ListHistoricalJobsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_historical_jobs";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_historical_jobs' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let page_size = params.page_size;
let page_number = params.page_number;
let sort = params.sort;
let filter_query = params.filter_query;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/siem-historical-detections/jobs",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = page_size {
local_req_builder =
local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_number {
local_req_builder =
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = sort {
local_req_builder =
local_req_builder.query(&[("sort", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_query {
local_req_builder =
local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::ListHistoricalJobsResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListHistoricalJobsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a list of indicators of compromise (IoCs) matching the specified filters.
pub async fn list_indicators_of_compromise(
&self,
params: ListIndicatorsOfCompromiseOptionalParams,
) -> Result<
crate::datadogV2::model::IoCExplorerListResponse,
datadog::Error<ListIndicatorsOfCompromiseError>,
> {
match self
.list_indicators_of_compromise_with_http_info(params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a list of indicators of compromise (IoCs) matching the specified filters.
pub async fn list_indicators_of_compromise_with_http_info(
&self,
params: ListIndicatorsOfCompromiseOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::IoCExplorerListResponse>,
datadog::Error<ListIndicatorsOfCompromiseError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_indicators_of_compromise";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_indicators_of_compromise' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let limit = params.limit;
let offset = params.offset;
let query = params.query;
let sort_column = params.sort_column;
let sort_order = params.sort_order;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/siem/ioc-explorer",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = limit {
local_req_builder =
local_req_builder.query(&[("limit", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = offset {
local_req_builder =
local_req_builder.query(&[("offset", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = query {
local_req_builder =
local_req_builder.query(&[("query", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = sort_column {
local_req_builder =
local_req_builder.query(&[("sort[column]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = sort_order {
local_req_builder =
local_req_builder.query(&[("sort[order]", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::IoCExplorerListResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListIndicatorsOfCompromiseError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get rules for multiple rulesets in batch.
pub async fn list_multiple_rulesets(
&self,
body: crate::datadogV2::model::GetMultipleRulesetsRequest,
) -> Result<
crate::datadogV2::model::GetMultipleRulesetsResponse,
datadog::Error<ListMultipleRulesetsError>,
> {
match self.list_multiple_rulesets_with_http_info(body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get rules for multiple rulesets in batch.
pub async fn list_multiple_rulesets_with_http_info(
&self,
body: crate::datadogV2::model::GetMultipleRulesetsRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::GetMultipleRulesetsResponse>,
datadog::Error<ListMultipleRulesetsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_multiple_rulesets";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_multiple_rulesets' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/static-analysis/rulesets",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::GetMultipleRulesetsResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListMultipleRulesetsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a list of security scanned assets metadata for an organization.
///
/// ### Pagination
///
/// For the "List Vulnerabilities" endpoint, see the [Pagination section](#pagination).
///
/// ### Filtering
///
/// For the "List Vulnerabilities" endpoint, see the [Filtering section](#filtering).
///
/// ### Metadata
///
/// For the "List Vulnerabilities" endpoint, see the [Metadata section](#metadata).
///
/// ### Related endpoints
///
/// This endpoint returns additional metadata for cloud resources that is not available from the standard resource endpoints. To access a richer dataset, call this endpoint together with the relevant resource endpoint(s) and merge (join) their results using the resource identifier.
///
/// **Hosts**
///
/// To enrich host data, join the response from the [Hosts](<https://docs.datadoghq.com/api/latest/hosts/>) endpoint with the response from the scanned-assets-metadata endpoint on the following key fields:
///
/// | ENDPOINT | JOIN KEY | TYPE |
/// | --- | --- | --- |
/// | [/api/v1/hosts](<https://docs.datadoghq.com/api/latest/hosts/>) | host_list.host_name | string |
/// | /api/v2/security/scanned-assets-metadata | data.attributes.asset.name | string |
///
/// **Host Images**
///
/// To enrich host image data, join the response from the [Hosts](<https://docs.datadoghq.com/api/latest/hosts/>) endpoint with the response from the scanned-assets-metadata endpoint on the following key fields:
///
/// | ENDPOINT | JOIN KEY | TYPE |
/// | --- | --- | --- |
/// | [/api/v1/hosts](<https://docs.datadoghq.com/api/latest/hosts/>) | host_list.tags_by_source["Amazon Web Services"]["image"] | string |
/// | /api/v2/security/scanned-assets-metadata | data.attributes.asset.name | string |
///
/// **Container Images**
///
/// To enrich container image data, join the response from the [Container Images](<https://docs.datadoghq.com/api/latest/container-images/>) endpoint with the response from the scanned-assets-metadata endpoint on the following key fields:
///
/// | ENDPOINT | JOIN KEY | TYPE |
/// | --- | --- | --- |
/// | [/api/v2/container_images](<https://docs.datadoghq.com/api/latest/container-images/>) | `data.attributes.name`@`data.attributes.repo_digest` | string |
/// | /api/v2/security/scanned-assets-metadata | data.attributes.asset.name | string |
pub async fn list_scanned_assets_metadata(
&self,
params: ListScannedAssetsMetadataOptionalParams,
) -> Result<
crate::datadogV2::model::ScannedAssetsMetadata,
datadog::Error<ListScannedAssetsMetadataError>,
> {
match self
.list_scanned_assets_metadata_with_http_info(params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a list of security scanned assets metadata for an organization.
///
/// ### Pagination
///
/// For the "List Vulnerabilities" endpoint, see the [Pagination section](#pagination).
///
/// ### Filtering
///
/// For the "List Vulnerabilities" endpoint, see the [Filtering section](#filtering).
///
/// ### Metadata
///
/// For the "List Vulnerabilities" endpoint, see the [Metadata section](#metadata).
///
/// ### Related endpoints
///
/// This endpoint returns additional metadata for cloud resources that is not available from the standard resource endpoints. To access a richer dataset, call this endpoint together with the relevant resource endpoint(s) and merge (join) their results using the resource identifier.
///
/// **Hosts**
///
/// To enrich host data, join the response from the [Hosts](<https://docs.datadoghq.com/api/latest/hosts/>) endpoint with the response from the scanned-assets-metadata endpoint on the following key fields:
///
/// | ENDPOINT | JOIN KEY | TYPE |
/// | --- | --- | --- |
/// | [/api/v1/hosts](<https://docs.datadoghq.com/api/latest/hosts/>) | host_list.host_name | string |
/// | /api/v2/security/scanned-assets-metadata | data.attributes.asset.name | string |
///
/// **Host Images**
///
/// To enrich host image data, join the response from the [Hosts](<https://docs.datadoghq.com/api/latest/hosts/>) endpoint with the response from the scanned-assets-metadata endpoint on the following key fields:
///
/// | ENDPOINT | JOIN KEY | TYPE |
/// | --- | --- | --- |
/// | [/api/v1/hosts](<https://docs.datadoghq.com/api/latest/hosts/>) | host_list.tags_by_source["Amazon Web Services"]["image"] | string |
/// | /api/v2/security/scanned-assets-metadata | data.attributes.asset.name | string |
///
/// **Container Images**
///
/// To enrich container image data, join the response from the [Container Images](<https://docs.datadoghq.com/api/latest/container-images/>) endpoint with the response from the scanned-assets-metadata endpoint on the following key fields:
///
/// | ENDPOINT | JOIN KEY | TYPE |
/// | --- | --- | --- |
/// | [/api/v2/container_images](<https://docs.datadoghq.com/api/latest/container-images/>) | `data.attributes.name`@`data.attributes.repo_digest` | string |
/// | /api/v2/security/scanned-assets-metadata | data.attributes.asset.name | string |
pub async fn list_scanned_assets_metadata_with_http_info(
&self,
params: ListScannedAssetsMetadataOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::ScannedAssetsMetadata>,
datadog::Error<ListScannedAssetsMetadataError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_scanned_assets_metadata";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_scanned_assets_metadata' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let page_token = params.page_token;
let page_number = params.page_number;
let filter_asset_type = params.filter_asset_type;
let filter_asset_name = params.filter_asset_name;
let filter_last_success_origin = params.filter_last_success_origin;
let filter_last_success_env = params.filter_last_success_env;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/scanned-assets-metadata",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = page_token {
local_req_builder =
local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_number {
local_req_builder =
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_type {
local_req_builder =
local_req_builder.query(&[("filter[asset.type]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_name {
local_req_builder =
local_req_builder.query(&[("filter[asset.name]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_last_success_origin {
local_req_builder = local_req_builder.query(&[(
"filter[last_success.origin]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_last_success_env {
local_req_builder = local_req_builder
.query(&[("filter[last_success.env]", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::ScannedAssetsMetadata>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListScannedAssetsMetadataError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the list of configured security filters with their definitions.
pub async fn list_security_filters(
&self,
) -> Result<
crate::datadogV2::model::SecurityFiltersResponse,
datadog::Error<ListSecurityFiltersError>,
> {
match self.list_security_filters_with_http_info().await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the list of configured security filters with their definitions.
pub async fn list_security_filters_with_http_info(
&self,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityFiltersResponse>,
datadog::Error<ListSecurityFiltersError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_security_filters";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/security_filters",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityFiltersResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListSecurityFiltersError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a list of security findings that match a search query. [See the schema for security findings](<https://docs.datadoghq.com/security/guide/findings-schema/>).
///
/// ### Query Syntax
///
/// This endpoint uses the logs query syntax. Findings attributes (living in the attributes.attributes. namespace) are prefixed by @ when queried. Tags are queried without a prefix.
///
/// Example: `@severity:(critical OR high) @status:open team:platform`
pub async fn list_security_findings(
&self,
params: ListSecurityFindingsOptionalParams,
) -> Result<
crate::datadogV2::model::ListSecurityFindingsResponse,
datadog::Error<ListSecurityFindingsError>,
> {
match self.list_security_findings_with_http_info(params).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
pub fn list_security_findings_with_pagination(
&self,
mut params: ListSecurityFindingsOptionalParams,
) -> impl Stream<
Item = Result<
crate::datadogV2::model::SecurityFindingsData,
datadog::Error<ListSecurityFindingsError>,
>,
> + '_ {
try_stream! {
let mut page_size: i64 = 10;
if params.page_limit.is_none() {
params.page_limit = Some(page_size);
} else {
page_size = params.page_limit.unwrap().clone();
}
loop {
let resp = self.list_security_findings(params.clone()).await?;
let Some(data) = resp.data else { break };
let r = data;
let count = r.len();
for team in r {
yield team;
}
if count < page_size as usize {
break;
}
let Some(meta) = resp.meta else { break };
let Some(page) = meta.page else { break };
let Some(after) = page.after else { break };
params.page_cursor = Some(after);
}
}
}
/// Get a list of security findings that match a search query. [See the schema for security findings](<https://docs.datadoghq.com/security/guide/findings-schema/>).
///
/// ### Query Syntax
///
/// This endpoint uses the logs query syntax. Findings attributes (living in the attributes.attributes. namespace) are prefixed by @ when queried. Tags are queried without a prefix.
///
/// Example: `@severity:(critical OR high) @status:open team:platform`
pub async fn list_security_findings_with_http_info(
&self,
params: ListSecurityFindingsOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::ListSecurityFindingsResponse>,
datadog::Error<ListSecurityFindingsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_security_findings";
// unbox and build optional parameters
let filter_query = params.filter_query;
let page_cursor = params.page_cursor;
let page_limit = params.page_limit;
let sort = params.sort;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/findings",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = filter_query {
local_req_builder =
local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_cursor {
local_req_builder =
local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_limit {
local_req_builder =
local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = sort {
local_req_builder =
local_req_builder.query(&[("sort", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::ListSecurityFindingsResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListSecurityFindingsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the list of all critical assets.
pub async fn list_security_monitoring_critical_assets(
&self,
) -> Result<
crate::datadogV2::model::SecurityMonitoringCriticalAssetsResponse,
datadog::Error<ListSecurityMonitoringCriticalAssetsError>,
> {
match self
.list_security_monitoring_critical_assets_with_http_info()
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the list of all critical assets.
pub async fn list_security_monitoring_critical_assets_with_http_info(
&self,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringCriticalAssetsResponse>,
datadog::Error<ListSecurityMonitoringCriticalAssetsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_security_monitoring_critical_assets";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/critical_assets",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringCriticalAssetsResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListSecurityMonitoringCriticalAssetsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// List hist signals.
pub async fn list_security_monitoring_histsignals(
&self,
params: ListSecurityMonitoringHistsignalsOptionalParams,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
datadog::Error<ListSecurityMonitoringHistsignalsError>,
> {
match self
.list_security_monitoring_histsignals_with_http_info(params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// List hist signals.
pub async fn list_security_monitoring_histsignals_with_http_info(
&self,
params: ListSecurityMonitoringHistsignalsOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
datadog::Error<ListSecurityMonitoringHistsignalsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_security_monitoring_histsignals";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_security_monitoring_histsignals' is not enabled"
.to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let filter_query = params.filter_query;
let filter_from = params.filter_from;
let filter_to = params.filter_to;
let sort = params.sort;
let page_cursor = params.page_cursor;
let page_limit = params.page_limit;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/siem-historical-detections/histsignals",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = filter_query {
local_req_builder =
local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_from {
local_req_builder = local_req_builder.query(&[(
"filter[from]",
&local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
)]);
};
if let Some(ref local_query_param) = filter_to {
local_req_builder = local_req_builder.query(&[(
"filter[to]",
&local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
)]);
};
if let Some(ref local_query_param) = sort {
local_req_builder =
local_req_builder.query(&[("sort", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_cursor {
local_req_builder =
local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_limit {
local_req_builder =
local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListSecurityMonitoringHistsignalsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// List rules.
pub async fn list_security_monitoring_rules(
&self,
params: ListSecurityMonitoringRulesOptionalParams,
) -> Result<
crate::datadogV2::model::SecurityMonitoringListRulesResponse,
datadog::Error<ListSecurityMonitoringRulesError>,
> {
match self
.list_security_monitoring_rules_with_http_info(params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// List rules.
pub async fn list_security_monitoring_rules_with_http_info(
&self,
params: ListSecurityMonitoringRulesOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringListRulesResponse>,
datadog::Error<ListSecurityMonitoringRulesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_security_monitoring_rules";
// unbox and build optional parameters
let page_size = params.page_size;
let page_number = params.page_number;
let query = params.query;
let sort = params.sort;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = page_size {
local_req_builder =
local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_number {
local_req_builder =
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = query {
local_req_builder =
local_req_builder.query(&[("query", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = sort {
local_req_builder =
local_req_builder.query(&[("sort", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringListRulesResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListSecurityMonitoringRulesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// The list endpoint returns security signals that match a search query.
/// Both this endpoint and the POST endpoint can be used interchangeably when listing
/// security signals.
pub async fn list_security_monitoring_signals(
&self,
params: ListSecurityMonitoringSignalsOptionalParams,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
datadog::Error<ListSecurityMonitoringSignalsError>,
> {
match self
.list_security_monitoring_signals_with_http_info(params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
pub fn list_security_monitoring_signals_with_pagination(
&self,
mut params: ListSecurityMonitoringSignalsOptionalParams,
) -> impl Stream<
Item = Result<
crate::datadogV2::model::SecurityMonitoringSignal,
datadog::Error<ListSecurityMonitoringSignalsError>,
>,
> + '_ {
try_stream! {
let mut page_size: i32 = 10;
if params.page_limit.is_none() {
params.page_limit = Some(page_size);
} else {
page_size = params.page_limit.unwrap().clone();
}
loop {
let resp = self.list_security_monitoring_signals(params.clone()).await?;
let Some(data) = resp.data else { break };
let r = data;
let count = r.len();
for team in r {
yield team;
}
if count < page_size as usize {
break;
}
let Some(meta) = resp.meta else { break };
let Some(page) = meta.page else { break };
let Some(after) = page.after else { break };
params.page_cursor = Some(after);
}
}
}
/// The list endpoint returns security signals that match a search query.
/// Both this endpoint and the POST endpoint can be used interchangeably when listing
/// security signals.
pub async fn list_security_monitoring_signals_with_http_info(
&self,
params: ListSecurityMonitoringSignalsOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
datadog::Error<ListSecurityMonitoringSignalsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_security_monitoring_signals";
// unbox and build optional parameters
let filter_query = params.filter_query;
let filter_from = params.filter_from;
let filter_to = params.filter_to;
let sort = params.sort;
let page_cursor = params.page_cursor;
let page_limit = params.page_limit;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = filter_query {
local_req_builder =
local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_from {
local_req_builder = local_req_builder.query(&[(
"filter[from]",
&local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
)]);
};
if let Some(ref local_query_param) = filter_to {
local_req_builder = local_req_builder.query(&[(
"filter[to]",
&local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
)]);
};
if let Some(ref local_query_param) = sort {
local_req_builder =
local_req_builder.query(&[("sort", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_cursor {
local_req_builder =
local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_limit {
local_req_builder =
local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListSecurityMonitoringSignalsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get the list of all suppression rules.
pub async fn list_security_monitoring_suppressions(
&self,
params: ListSecurityMonitoringSuppressionsOptionalParams,
) -> Result<
crate::datadogV2::model::SecurityMonitoringPaginatedSuppressionsResponse,
datadog::Error<ListSecurityMonitoringSuppressionsError>,
> {
match self
.list_security_monitoring_suppressions_with_http_info(params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get the list of all suppression rules.
pub async fn list_security_monitoring_suppressions_with_http_info(
&self,
params: ListSecurityMonitoringSuppressionsOptionalParams,
) -> Result<
datadog::ResponseContent<
crate::datadogV2::model::SecurityMonitoringPaginatedSuppressionsResponse,
>,
datadog::Error<ListSecurityMonitoringSuppressionsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_security_monitoring_suppressions";
// unbox and build optional parameters
let query = params.query;
let sort = params.sort;
let page_size = params.page_size;
let page_number = params.page_number;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/suppressions",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = query {
local_req_builder =
local_req_builder.query(&[("query", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = sort {
local_req_builder =
local_req_builder.query(&[("sort", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_size {
local_req_builder =
local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_number {
local_req_builder =
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringPaginatedSuppressionsResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListSecurityMonitoringSuppressionsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a list of vulnerabilities.
///
/// ### Pagination
///
/// 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.
///
/// This endpoint will return paginated responses. The pages are stored in the links section of the response:
///
/// ```JSON
/// {
/// "data": [...],
/// "meta": {...},
/// "links": {
/// "self": "<https://.../api/v2/security/vulnerabilities",>
/// "first": "<https://.../api/v2/security/vulnerabilities?page[number]=1&page[token]=abc",>
/// "last": "<https://.../api/v2/security/vulnerabilities?page[number]=43&page[token]=abc",>
/// "next": "<https://.../api/v2/security/vulnerabilities?page[number]=2&page[token]=abc">
/// }
/// }
/// ```
///
///
/// - `links.previous` is empty if the first page is requested.
/// - `links.next` is empty if the last page is requested.
///
/// #### Token
///
/// Vulnerabilities can be created, updated or deleted at any point in time.
///
/// Upon the first request, a token is created to ensure consistency across subsequent paginated requests.
///
/// A token is valid only for 24 hours.
///
/// #### First request
///
/// We consider a request to be the first request when there is no `page[token]` parameter.
///
/// The response of this first request contains the newly created token in the `links` section.
///
/// This token can then be used in the subsequent paginated requests.
///
/// *Note: The first request may take longer to complete than subsequent requests.*
///
/// #### Subsequent requests
///
/// Any request containing valid `page[token]` and `page[number]` parameters will be considered a subsequent request.
///
/// If the `token` is invalid, a `404` response will be returned.
///
/// If the page `number` is invalid, a `400` response will be returned.
///
/// The returned `token` is valid for all requests in the pagination sequence. To send paginated requests in parallel, reuse the same `token` and change only the `page[number]` parameter.
///
/// ### Filtering
///
/// 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.
///
/// 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`.
///
/// String filters are case sensitive.
///
/// Boolean filters accept `true` or `false` as values.
///
/// 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`.
///
/// Available operators are: `eq` (==), `lt` (<), `lte` (<=), `gt` (>) and `gte` (>=).
///
/// ### Metadata
///
/// Following [JSON:API format](<https://jsonapi.org/format/#document-meta>), object including non-standard meta-information.
///
/// 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.
///
/// ```JSON
/// {
/// "data": [...],
/// "meta": {
/// "total": 1500,
/// "count": 18732,
/// "token": "some_token"
/// },
/// "links": {...}
/// }
/// ```
/// ### Extensions
///
/// Requests may include extensions to modify the behavior of the requested endpoint. The filter parameters follow the [JSON:API format](<https://jsonapi.org/extensions/#extensions>) format: `ext:$extension_name`, where `extension_name` is the name of the modifier that is being applied.
///
/// Extensions can only include one value: `ext:modifier=value`.
pub async fn list_vulnerabilities(
&self,
params: ListVulnerabilitiesOptionalParams,
) -> Result<
crate::datadogV2::model::ListVulnerabilitiesResponse,
datadog::Error<ListVulnerabilitiesError>,
> {
match self.list_vulnerabilities_with_http_info(params).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a list of vulnerabilities.
///
/// ### Pagination
///
/// 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.
///
/// This endpoint will return paginated responses. The pages are stored in the links section of the response:
///
/// ```JSON
/// {
/// "data": [...],
/// "meta": {...},
/// "links": {
/// "self": "<https://.../api/v2/security/vulnerabilities",>
/// "first": "<https://.../api/v2/security/vulnerabilities?page[number]=1&page[token]=abc",>
/// "last": "<https://.../api/v2/security/vulnerabilities?page[number]=43&page[token]=abc",>
/// "next": "<https://.../api/v2/security/vulnerabilities?page[number]=2&page[token]=abc">
/// }
/// }
/// ```
///
///
/// - `links.previous` is empty if the first page is requested.
/// - `links.next` is empty if the last page is requested.
///
/// #### Token
///
/// Vulnerabilities can be created, updated or deleted at any point in time.
///
/// Upon the first request, a token is created to ensure consistency across subsequent paginated requests.
///
/// A token is valid only for 24 hours.
///
/// #### First request
///
/// We consider a request to be the first request when there is no `page[token]` parameter.
///
/// The response of this first request contains the newly created token in the `links` section.
///
/// This token can then be used in the subsequent paginated requests.
///
/// *Note: The first request may take longer to complete than subsequent requests.*
///
/// #### Subsequent requests
///
/// Any request containing valid `page[token]` and `page[number]` parameters will be considered a subsequent request.
///
/// If the `token` is invalid, a `404` response will be returned.
///
/// If the page `number` is invalid, a `400` response will be returned.
///
/// The returned `token` is valid for all requests in the pagination sequence. To send paginated requests in parallel, reuse the same `token` and change only the `page[number]` parameter.
///
/// ### Filtering
///
/// 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.
///
/// 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`.
///
/// String filters are case sensitive.
///
/// Boolean filters accept `true` or `false` as values.
///
/// 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`.
///
/// Available operators are: `eq` (==), `lt` (<), `lte` (<=), `gt` (>) and `gte` (>=).
///
/// ### Metadata
///
/// Following [JSON:API format](<https://jsonapi.org/format/#document-meta>), object including non-standard meta-information.
///
/// 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.
///
/// ```JSON
/// {
/// "data": [...],
/// "meta": {
/// "total": 1500,
/// "count": 18732,
/// "token": "some_token"
/// },
/// "links": {...}
/// }
/// ```
/// ### Extensions
///
/// Requests may include extensions to modify the behavior of the requested endpoint. The filter parameters follow the [JSON:API format](<https://jsonapi.org/extensions/#extensions>) format: `ext:$extension_name`, where `extension_name` is the name of the modifier that is being applied.
///
/// Extensions can only include one value: `ext:modifier=value`.
pub async fn list_vulnerabilities_with_http_info(
&self,
params: ListVulnerabilitiesOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::ListVulnerabilitiesResponse>,
datadog::Error<ListVulnerabilitiesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_vulnerabilities";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_vulnerabilities' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let page_token = params.page_token;
let page_number = params.page_number;
let filter_type = params.filter_type;
let filter_cvss_base_score_op = params.filter_cvss_base_score_op;
let filter_cvss_base_severity = params.filter_cvss_base_severity;
let filter_cvss_base_vector = params.filter_cvss_base_vector;
let filter_cvss_datadog_score_op = params.filter_cvss_datadog_score_op;
let filter_cvss_datadog_severity = params.filter_cvss_datadog_severity;
let filter_cvss_datadog_vector = params.filter_cvss_datadog_vector;
let filter_status = params.filter_status;
let filter_tool = params.filter_tool;
let filter_library_name = params.filter_library_name;
let filter_library_version = params.filter_library_version;
let filter_advisory_id = params.filter_advisory_id;
let filter_risks_exploitation_probability = params.filter_risks_exploitation_probability;
let filter_risks_poc_exploit_available = params.filter_risks_poc_exploit_available;
let filter_risks_exploit_available = params.filter_risks_exploit_available;
let filter_risks_epss_score_op = params.filter_risks_epss_score_op;
let filter_risks_epss_severity = params.filter_risks_epss_severity;
let filter_language = params.filter_language;
let filter_ecosystem = params.filter_ecosystem;
let filter_code_location_location = params.filter_code_location_location;
let filter_code_location_file_path = params.filter_code_location_file_path;
let filter_code_location_method = params.filter_code_location_method;
let filter_fix_available = params.filter_fix_available;
let filter_repo_digests = params.filter_repo_digests;
let filter_origin = params.filter_origin;
let filter_running_kernel = params.filter_running_kernel;
let filter_asset_name = params.filter_asset_name;
let filter_asset_type = params.filter_asset_type;
let filter_asset_version_first = params.filter_asset_version_first;
let filter_asset_version_last = params.filter_asset_version_last;
let filter_asset_repository_url = params.filter_asset_repository_url;
let filter_asset_risks_in_production = params.filter_asset_risks_in_production;
let filter_asset_risks_under_attack = params.filter_asset_risks_under_attack;
let filter_asset_risks_is_publicly_accessible =
params.filter_asset_risks_is_publicly_accessible;
let filter_asset_risks_has_privileged_access =
params.filter_asset_risks_has_privileged_access;
let filter_asset_risks_has_access_to_sensitive_data =
params.filter_asset_risks_has_access_to_sensitive_data;
let filter_asset_environments = params.filter_asset_environments;
let filter_asset_teams = params.filter_asset_teams;
let filter_asset_arch = params.filter_asset_arch;
let filter_asset_operating_system_name = params.filter_asset_operating_system_name;
let filter_asset_operating_system_version = params.filter_asset_operating_system_version;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/vulnerabilities",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = page_token {
local_req_builder =
local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_number {
local_req_builder =
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_type {
local_req_builder =
local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_cvss_base_score_op {
local_req_builder = local_req_builder.query(&[(
"filter[cvss.base.score][`$op`]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_cvss_base_severity {
local_req_builder = local_req_builder
.query(&[("filter[cvss.base.severity]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_cvss_base_vector {
local_req_builder = local_req_builder
.query(&[("filter[cvss.base.vector]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_cvss_datadog_score_op {
local_req_builder = local_req_builder.query(&[(
"filter[cvss.datadog.score][`$op`]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_cvss_datadog_severity {
local_req_builder = local_req_builder.query(&[(
"filter[cvss.datadog.severity]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_cvss_datadog_vector {
local_req_builder = local_req_builder.query(&[(
"filter[cvss.datadog.vector]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_status {
local_req_builder =
local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_tool {
local_req_builder =
local_req_builder.query(&[("filter[tool]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_library_name {
local_req_builder = local_req_builder
.query(&[("filter[library.name]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_library_version {
local_req_builder = local_req_builder
.query(&[("filter[library.version]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_advisory_id {
local_req_builder =
local_req_builder.query(&[("filter[advisory.id]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_risks_exploitation_probability {
local_req_builder = local_req_builder.query(&[(
"filter[risks.exploitation_probability]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_risks_poc_exploit_available {
local_req_builder = local_req_builder.query(&[(
"filter[risks.poc_exploit_available]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_risks_exploit_available {
local_req_builder = local_req_builder.query(&[(
"filter[risks.exploit_available]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_risks_epss_score_op {
local_req_builder = local_req_builder.query(&[(
"filter[risks.epss.score][`$op`]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_risks_epss_severity {
local_req_builder = local_req_builder.query(&[(
"filter[risks.epss.severity]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_language {
local_req_builder =
local_req_builder.query(&[("filter[language]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_ecosystem {
local_req_builder =
local_req_builder.query(&[("filter[ecosystem]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_code_location_location {
local_req_builder = local_req_builder.query(&[(
"filter[code_location.location]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_code_location_file_path {
local_req_builder = local_req_builder.query(&[(
"filter[code_location.file_path]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_code_location_method {
local_req_builder = local_req_builder.query(&[(
"filter[code_location.method]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_fix_available {
local_req_builder = local_req_builder
.query(&[("filter[fix_available]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_repo_digests {
local_req_builder = local_req_builder
.query(&[("filter[repo_digests]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_origin {
local_req_builder =
local_req_builder.query(&[("filter[origin]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_running_kernel {
local_req_builder = local_req_builder
.query(&[("filter[running_kernel]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_name {
local_req_builder =
local_req_builder.query(&[("filter[asset.name]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_type {
local_req_builder =
local_req_builder.query(&[("filter[asset.type]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_version_first {
local_req_builder = local_req_builder.query(&[(
"filter[asset.version.first]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_asset_version_last {
local_req_builder = local_req_builder
.query(&[("filter[asset.version.last]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_repository_url {
local_req_builder = local_req_builder.query(&[(
"filter[asset.repository_url]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_asset_risks_in_production {
local_req_builder = local_req_builder.query(&[(
"filter[asset.risks.in_production]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_asset_risks_under_attack {
local_req_builder = local_req_builder.query(&[(
"filter[asset.risks.under_attack]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_asset_risks_is_publicly_accessible {
local_req_builder = local_req_builder.query(&[(
"filter[asset.risks.is_publicly_accessible]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_asset_risks_has_privileged_access {
local_req_builder = local_req_builder.query(&[(
"filter[asset.risks.has_privileged_access]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_asset_risks_has_access_to_sensitive_data {
local_req_builder = local_req_builder.query(&[(
"filter[asset.risks.has_access_to_sensitive_data]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_asset_environments {
local_req_builder = local_req_builder
.query(&[("filter[asset.environments]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_teams {
local_req_builder =
local_req_builder.query(&[("filter[asset.teams]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_arch {
local_req_builder =
local_req_builder.query(&[("filter[asset.arch]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_asset_operating_system_name {
local_req_builder = local_req_builder.query(&[(
"filter[asset.operating_system.name]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_asset_operating_system_version {
local_req_builder = local_req_builder.query(&[(
"filter[asset.operating_system.version]",
&local_query_param.to_string(),
)]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::ListVulnerabilitiesResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListVulnerabilitiesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a list of vulnerable assets.
///
/// ### Pagination
///
/// Please review the [Pagination section for the "List Vulnerabilities"](#pagination) endpoint.
///
/// ### Filtering
///
/// Please review the [Filtering section for the "List Vulnerabilities"](#filtering) endpoint.
///
/// ### Metadata
///
/// Please review the [Metadata section for the "List Vulnerabilities"](#metadata) endpoint.
pub async fn list_vulnerable_assets(
&self,
params: ListVulnerableAssetsOptionalParams,
) -> Result<
crate::datadogV2::model::ListVulnerableAssetsResponse,
datadog::Error<ListVulnerableAssetsError>,
> {
match self.list_vulnerable_assets_with_http_info(params).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Get a list of vulnerable assets.
///
/// ### Pagination
///
/// Please review the [Pagination section for the "List Vulnerabilities"](#pagination) endpoint.
///
/// ### Filtering
///
/// Please review the [Filtering section for the "List Vulnerabilities"](#filtering) endpoint.
///
/// ### Metadata
///
/// Please review the [Metadata section for the "List Vulnerabilities"](#metadata) endpoint.
pub async fn list_vulnerable_assets_with_http_info(
&self,
params: ListVulnerableAssetsOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::ListVulnerableAssetsResponse>,
datadog::Error<ListVulnerableAssetsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_vulnerable_assets";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_vulnerable_assets' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let page_token = params.page_token;
let page_number = params.page_number;
let filter_name = params.filter_name;
let filter_type = params.filter_type;
let filter_version_first = params.filter_version_first;
let filter_version_last = params.filter_version_last;
let filter_repository_url = params.filter_repository_url;
let filter_risks_in_production = params.filter_risks_in_production;
let filter_risks_under_attack = params.filter_risks_under_attack;
let filter_risks_is_publicly_accessible = params.filter_risks_is_publicly_accessible;
let filter_risks_has_privileged_access = params.filter_risks_has_privileged_access;
let filter_risks_has_access_to_sensitive_data =
params.filter_risks_has_access_to_sensitive_data;
let filter_environments = params.filter_environments;
let filter_teams = params.filter_teams;
let filter_arch = params.filter_arch;
let filter_operating_system_name = params.filter_operating_system_name;
let filter_operating_system_version = params.filter_operating_system_version;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/vulnerable-assets",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
if let Some(ref local_query_param) = page_token {
local_req_builder =
local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_number {
local_req_builder =
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_name {
local_req_builder =
local_req_builder.query(&[("filter[name]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_type {
local_req_builder =
local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_version_first {
local_req_builder = local_req_builder
.query(&[("filter[version.first]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_version_last {
local_req_builder = local_req_builder
.query(&[("filter[version.last]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_repository_url {
local_req_builder = local_req_builder
.query(&[("filter[repository_url]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_risks_in_production {
local_req_builder = local_req_builder.query(&[(
"filter[risks.in_production]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_risks_under_attack {
local_req_builder = local_req_builder
.query(&[("filter[risks.under_attack]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_risks_is_publicly_accessible {
local_req_builder = local_req_builder.query(&[(
"filter[risks.is_publicly_accessible]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_risks_has_privileged_access {
local_req_builder = local_req_builder.query(&[(
"filter[risks.has_privileged_access]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_risks_has_access_to_sensitive_data {
local_req_builder = local_req_builder.query(&[(
"filter[risks.has_access_to_sensitive_data]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_environments {
local_req_builder = local_req_builder
.query(&[("filter[environments]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_teams {
local_req_builder =
local_req_builder.query(&[("filter[teams]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_arch {
local_req_builder =
local_req_builder.query(&[("filter[arch]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = filter_operating_system_name {
local_req_builder = local_req_builder.query(&[(
"filter[operating_system.name]",
&local_query_param.to_string(),
)]);
};
if let Some(ref local_query_param) = filter_operating_system_version {
local_req_builder = local_req_builder.query(&[(
"filter[operating_system.version]",
&local_query_param.to_string(),
)]);
};
// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::ListVulnerableAssetsResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListVulnerableAssetsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Mute or unmute findings.
pub async fn mute_findings(
&self,
body: crate::datadogV2::model::BulkMuteFindingsRequest,
) -> Result<crate::datadogV2::model::BulkMuteFindingsResponse, datadog::Error<MuteFindingsError>>
{
match self.mute_findings_with_http_info(body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Mute or unmute findings.
pub async fn mute_findings_with_http_info(
&self,
body: crate::datadogV2::model::BulkMuteFindingsRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::BulkMuteFindingsResponse>,
datadog::Error<MuteFindingsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.mute_findings";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.mute_findings' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/posture_management/findings",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::BulkMuteFindingsResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<MuteFindingsError> = serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated.
pub async fn patch_signal_notification_rule(
&self,
id: String,
body: crate::datadogV2::model::PatchNotificationRuleParameters,
) -> Result<
crate::datadogV2::model::NotificationRuleResponse,
datadog::Error<PatchSignalNotificationRuleError>,
> {
match self
.patch_signal_notification_rule_with_http_info(id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated.
pub async fn patch_signal_notification_rule_with_http_info(
&self,
id: String,
body: crate::datadogV2::model::PatchNotificationRuleParameters,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
datadog::Error<PatchSignalNotificationRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.patch_signal_notification_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/signals/notification_rules/{id}",
local_configuration.get_operation_host(operation_id),
id = datadog::urlencode(id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<PatchSignalNotificationRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated.
pub async fn patch_vulnerability_notification_rule(
&self,
id: String,
body: crate::datadogV2::model::PatchNotificationRuleParameters,
) -> Result<
crate::datadogV2::model::NotificationRuleResponse,
datadog::Error<PatchVulnerabilityNotificationRuleError>,
> {
match self
.patch_vulnerability_notification_rule_with_http_info(id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated.
pub async fn patch_vulnerability_notification_rule_with_http_info(
&self,
id: String,
body: crate::datadogV2::model::PatchNotificationRuleParameters,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
datadog::Error<PatchVulnerabilityNotificationRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.patch_vulnerability_notification_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/vulnerabilities/notification_rules/{id}",
local_configuration.get_operation_host(operation_id),
id = datadog::urlencode(id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<PatchVulnerabilityNotificationRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Run a historical job.
pub async fn run_historical_job(
&self,
body: crate::datadogV2::model::RunHistoricalJobRequest,
) -> Result<crate::datadogV2::model::JobCreateResponse, datadog::Error<RunHistoricalJobError>>
{
match self.run_historical_job_with_http_info(body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Run a historical job.
pub async fn run_historical_job_with_http_info(
&self,
body: crate::datadogV2::model::RunHistoricalJobRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::JobCreateResponse>,
datadog::Error<RunHistoricalJobError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.run_historical_job";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.run_historical_job' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/siem-historical-detections/jobs",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::JobCreateResponse>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<RunHistoricalJobError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Get a list of security findings that match a search query. [See the schema for security findings](<https://docs.datadoghq.com/security/guide/findings-schema/>).
///
/// ### Query Syntax
///
/// The API uses the logs query syntax. Findings attributes (living in the attributes.attributes. namespace) are prefixed by @ when queried. Tags are queried without a prefix.
///
/// Example: `@severity:(critical OR high) @status:open team:platform`
pub async fn search_security_findings(
&self,
body: crate::datadogV2::model::SecurityFindingsSearchRequest,
) -> Result<
crate::datadogV2::model::ListSecurityFindingsResponse,
datadog::Error<SearchSecurityFindingsError>,
> {
match self.search_security_findings_with_http_info(body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
pub fn search_security_findings_with_pagination(
&self,
mut body: crate::datadogV2::model::SecurityFindingsSearchRequest,
) -> impl Stream<
Item = Result<
crate::datadogV2::model::SecurityFindingsData,
datadog::Error<SearchSecurityFindingsError>,
>,
> + '_ {
try_stream! {
let mut page_size: i64 = 10;
if body.data.is_none() {
body.data = Some(crate::datadogV2::model::SecurityFindingsSearchRequestData::new());
}
if body.data.as_ref().unwrap().attributes.is_none() {
body.data.as_mut().unwrap().attributes = Some(crate::datadogV2::model::SecurityFindingsSearchRequestDataAttributes::new());
}
if body.data.as_ref().unwrap().attributes.as_ref().unwrap().page.is_none() {
body.data.as_mut().unwrap().attributes.as_mut().unwrap().page = Some(crate::datadogV2::model::SecurityFindingsSearchRequestPage::new());
}
if body.data.as_ref().unwrap().attributes.as_ref().unwrap().page.as_ref().unwrap().limit.is_none() {
body.data.as_mut().unwrap().attributes.as_mut().unwrap().page.as_mut().unwrap().limit = Some(page_size);
} else {
page_size = body.data.as_ref().unwrap().attributes.as_ref().unwrap().page.as_ref().unwrap().limit.unwrap().clone();
}
loop {
let resp = self.search_security_findings( body.clone(),).await?;
let Some(data) = resp.data else { break };
let r = data;
let count = r.len();
for team in r {
yield team;
}
if count < page_size as usize {
break;
}
let Some(meta) = resp.meta else { break };
let Some(page) = meta.page else { break };
let Some(after) = page.after else { break };
body.data.as_mut().unwrap().attributes.as_mut().unwrap().page.as_mut().unwrap().cursor = Some(after);
}
}
}
/// Get a list of security findings that match a search query. [See the schema for security findings](<https://docs.datadoghq.com/security/guide/findings-schema/>).
///
/// ### Query Syntax
///
/// The API uses the logs query syntax. Findings attributes (living in the attributes.attributes. namespace) are prefixed by @ when queried. Tags are queried without a prefix.
///
/// Example: `@severity:(critical OR high) @status:open team:platform`
pub async fn search_security_findings_with_http_info(
&self,
body: crate::datadogV2::model::SecurityFindingsSearchRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::ListSecurityFindingsResponse>,
datadog::Error<SearchSecurityFindingsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.search_security_findings";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security/findings/search",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::ListSecurityFindingsResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<SearchSecurityFindingsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Search hist signals.
pub async fn search_security_monitoring_histsignals(
&self,
params: SearchSecurityMonitoringHistsignalsOptionalParams,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
datadog::Error<SearchSecurityMonitoringHistsignalsError>,
> {
match self
.search_security_monitoring_histsignals_with_http_info(params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Search hist signals.
pub async fn search_security_monitoring_histsignals_with_http_info(
&self,
params: SearchSecurityMonitoringHistsignalsOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
datadog::Error<SearchSecurityMonitoringHistsignalsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.search_security_monitoring_histsignals";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.search_security_monitoring_histsignals' is not enabled"
.to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}
// unbox and build optional parameters
let body = params.body;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/siem-historical-detections/histsignals/search",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<SearchSecurityMonitoringHistsignalsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Returns security signals that match a search query.
/// Both this endpoint and the GET endpoint can be used interchangeably for listing
/// security signals.
pub async fn search_security_monitoring_signals(
&self,
params: SearchSecurityMonitoringSignalsOptionalParams,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
datadog::Error<SearchSecurityMonitoringSignalsError>,
> {
match self
.search_security_monitoring_signals_with_http_info(params)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
pub fn search_security_monitoring_signals_with_pagination(
&self,
mut params: SearchSecurityMonitoringSignalsOptionalParams,
) -> impl Stream<
Item = Result<
crate::datadogV2::model::SecurityMonitoringSignal,
datadog::Error<SearchSecurityMonitoringSignalsError>,
>,
> + '_ {
try_stream! {
let mut page_size: i32 = 10;
if params.body.is_none() {
params.body = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequest::new());
}
if params.body.as_ref().unwrap().page.is_none() {
params.body.as_mut().unwrap().page = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequestPage::new());
}
if params.body.as_ref().unwrap().page.as_ref().unwrap().limit.is_none() {
params.body.as_mut().unwrap().page.as_mut().unwrap().limit = Some(page_size);
} else {
page_size = params.body.as_ref().unwrap().page.as_ref().unwrap().limit.unwrap().clone();
}
loop {
let resp = self.search_security_monitoring_signals(params.clone()).await?;
let Some(data) = resp.data else { break };
let r = data;
let count = r.len();
for team in r {
yield team;
}
if count < page_size as usize {
break;
}
let Some(meta) = resp.meta else { break };
let Some(page) = meta.page else { break };
let Some(after) = page.after else { break };
params.body.as_mut().unwrap().page.as_mut().unwrap().cursor = Some(after);
}
}
}
/// Returns security signals that match a search query.
/// Both this endpoint and the GET endpoint can be used interchangeably for listing
/// security signals.
pub async fn search_security_monitoring_signals_with_http_info(
&self,
params: SearchSecurityMonitoringSignalsOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
datadog::Error<SearchSecurityMonitoringSignalsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.search_security_monitoring_signals";
// unbox and build optional parameters
let body = params.body;
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/signals/search",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<SearchSecurityMonitoringSignalsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Test an existing rule.
pub async fn test_existing_security_monitoring_rule(
&self,
rule_id: String,
body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringRuleTestResponse,
datadog::Error<TestExistingSecurityMonitoringRuleError>,
> {
match self
.test_existing_security_monitoring_rule_with_http_info(rule_id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Test an existing rule.
pub async fn test_existing_security_monitoring_rule_with_http_info(
&self,
rule_id: String,
body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>,
datadog::Error<TestExistingSecurityMonitoringRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.test_existing_security_monitoring_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules/{rule_id}/test",
local_configuration.get_operation_host(operation_id),
rule_id = datadog::urlencode(rule_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<TestExistingSecurityMonitoringRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Test a rule.
pub async fn test_security_monitoring_rule(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringRuleTestResponse,
datadog::Error<TestSecurityMonitoringRuleError>,
> {
match self
.test_security_monitoring_rule_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Test a rule.
pub async fn test_security_monitoring_rule_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>,
datadog::Error<TestSecurityMonitoringRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.test_security_monitoring_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules/test",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<TestSecurityMonitoringRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Update a custom framework.
pub async fn update_custom_framework(
&self,
handle: String,
version: String,
body: crate::datadogV2::model::UpdateCustomFrameworkRequest,
) -> Result<
crate::datadogV2::model::UpdateCustomFrameworkResponse,
datadog::Error<UpdateCustomFrameworkError>,
> {
match self
.update_custom_framework_with_http_info(handle, version, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Update a custom framework.
pub async fn update_custom_framework_with_http_info(
&self,
handle: String,
version: String,
body: crate::datadogV2::model::UpdateCustomFrameworkRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::UpdateCustomFrameworkResponse>,
datadog::Error<UpdateCustomFrameworkError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.update_custom_framework";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/cloud_security_management/custom_frameworks/{handle}/{version}",
local_configuration.get_operation_host(operation_id),
handle = datadog::urlencode(handle),
version = datadog::urlencode(version)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::UpdateCustomFrameworkResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<UpdateCustomFrameworkError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Update resource filters.
pub async fn update_resource_evaluation_filters(
&self,
body: crate::datadogV2::model::UpdateResourceEvaluationFiltersRequest,
) -> Result<
crate::datadogV2::model::UpdateResourceEvaluationFiltersResponse,
datadog::Error<UpdateResourceEvaluationFiltersError>,
> {
match self
.update_resource_evaluation_filters_with_http_info(body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Update resource filters.
pub async fn update_resource_evaluation_filters_with_http_info(
&self,
body: crate::datadogV2::model::UpdateResourceEvaluationFiltersRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::UpdateResourceEvaluationFiltersResponse>,
datadog::Error<UpdateResourceEvaluationFiltersError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.update_resource_evaluation_filters";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/cloud_security_management/resource_filters",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::UpdateResourceEvaluationFiltersResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<UpdateResourceEvaluationFiltersError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Update a specific security filter.
/// Returns the security filter object when the request is successful.
pub async fn update_security_filter(
&self,
security_filter_id: String,
body: crate::datadogV2::model::SecurityFilterUpdateRequest,
) -> Result<
crate::datadogV2::model::SecurityFilterResponse,
datadog::Error<UpdateSecurityFilterError>,
> {
match self
.update_security_filter_with_http_info(security_filter_id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Update a specific security filter.
/// Returns the security filter object when the request is successful.
pub async fn update_security_filter_with_http_info(
&self,
security_filter_id: String,
body: crate::datadogV2::model::SecurityFilterUpdateRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
datadog::Error<UpdateSecurityFilterError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.update_security_filter";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
local_configuration.get_operation_host(operation_id),
security_filter_id = datadog::urlencode(security_filter_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<UpdateSecurityFilterError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Update a specific critical asset.
pub async fn update_security_monitoring_critical_asset(
&self,
critical_asset_id: String,
body: crate::datadogV2::model::SecurityMonitoringCriticalAssetUpdateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringCriticalAssetResponse,
datadog::Error<UpdateSecurityMonitoringCriticalAssetError>,
> {
match self
.update_security_monitoring_critical_asset_with_http_info(critical_asset_id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Update a specific critical asset.
pub async fn update_security_monitoring_critical_asset_with_http_info(
&self,
critical_asset_id: String,
body: crate::datadogV2::model::SecurityMonitoringCriticalAssetUpdateRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringCriticalAssetResponse>,
datadog::Error<UpdateSecurityMonitoringCriticalAssetError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.update_security_monitoring_critical_asset";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/critical_assets/{critical_asset_id}",
local_configuration.get_operation_host(operation_id),
critical_asset_id = datadog::urlencode(critical_asset_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringCriticalAssetResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<UpdateSecurityMonitoringCriticalAssetError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Update an existing rule. When updating `cases`, `queries` or `options`, the whole field
/// must be included. For example, when modifying a query all queries must be included.
/// Default rules can only be updated to be enabled, to change notifications, or to update
/// the tags (default tags cannot be removed).
pub async fn update_security_monitoring_rule(
&self,
rule_id: String,
body: crate::datadogV2::model::SecurityMonitoringRuleUpdatePayload,
) -> Result<
crate::datadogV2::model::SecurityMonitoringRuleResponse,
datadog::Error<UpdateSecurityMonitoringRuleError>,
> {
match self
.update_security_monitoring_rule_with_http_info(rule_id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Update an existing rule. When updating `cases`, `queries` or `options`, the whole field
/// must be included. For example, when modifying a query all queries must be included.
/// Default rules can only be updated to be enabled, to change notifications, or to update
/// the tags (default tags cannot be removed).
pub async fn update_security_monitoring_rule_with_http_info(
&self,
rule_id: String,
body: crate::datadogV2::model::SecurityMonitoringRuleUpdatePayload,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
datadog::Error<UpdateSecurityMonitoringRuleError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.update_security_monitoring_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules/{rule_id}",
local_configuration.get_operation_host(operation_id),
rule_id = datadog::urlencode(rule_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<UpdateSecurityMonitoringRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Update a specific suppression rule.
pub async fn update_security_monitoring_suppression(
&self,
suppression_id: String,
body: crate::datadogV2::model::SecurityMonitoringSuppressionUpdateRequest,
) -> Result<
crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
datadog::Error<UpdateSecurityMonitoringSuppressionError>,
> {
match self
.update_security_monitoring_suppression_with_http_info(suppression_id, body)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}
/// Update a specific suppression rule.
pub async fn update_security_monitoring_suppression_with_http_info(
&self,
suppression_id: String,
body: crate::datadogV2::model::SecurityMonitoringSuppressionUpdateRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
datadog::Error<UpdateSecurityMonitoringSuppressionError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.update_security_monitoring_suppression";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
local_configuration.get_operation_host(operation_id),
suppression_id = datadog::urlencode(suppression_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<
crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
>(&local_content)
{
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<UpdateSecurityMonitoringSuppressionError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Validate a detection rule.
pub async fn validate_security_monitoring_rule(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleValidatePayload,
) -> Result<(), datadog::Error<ValidateSecurityMonitoringRuleError>> {
match self
.validate_security_monitoring_rule_with_http_info(body)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Validate a detection rule.
pub async fn validate_security_monitoring_rule_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringRuleValidatePayload,
) -> Result<datadog::ResponseContent<()>, datadog::Error<ValidateSecurityMonitoringRuleError>>
{
let local_configuration = &self.config;
let operation_id = "v2.validate_security_monitoring_rule";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/rules/validation",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<ValidateSecurityMonitoringRuleError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
/// Validate a suppression rule.
pub async fn validate_security_monitoring_suppression(
&self,
body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
) -> Result<(), datadog::Error<ValidateSecurityMonitoringSuppressionError>> {
match self
.validate_security_monitoring_suppression_with_http_info(body)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
/// Validate a suppression rule.
pub async fn validate_security_monitoring_suppression_with_http_info(
&self,
body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
) -> Result<
datadog::ResponseContent<()>,
datadog::Error<ValidateSecurityMonitoringSuppressionError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.validate_security_monitoring_suppression";
let local_client = &self.client;
let local_uri_str = format!(
"{}/api/v2/security_monitoring/configuration/suppressions/validation",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("*/*"));
// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};
// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};
// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
#[cfg(feature = "zstd")]
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;
let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);
if !local_status.is_client_error() && !local_status.is_server_error() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<ValidateSecurityMonitoringSuppressionError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}
}