Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 105 additions & 26 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23526,6 +23526,30 @@ components:
required:
- data
type: object
GetSuppressionVersionHistoryData:
description: Data for the suppression version history.
properties:
attributes:
$ref: '#/components/schemas/SuppressionVersionHistory'
id:
description: ID of the suppression.
type: string
type:
$ref: '#/components/schemas/GetSuppressionVersionHistoryDataType'
type: object
GetSuppressionVersionHistoryDataType:
description: Type of data.
enum:
- suppression_version_history
type: string
x-enum-varnames:
- SUPPRESSIONVERSIONHISTORY
GetSuppressionVersionHistoryResponse:
description: Response for getting the suppression version history.
properties:
data:
$ref: '#/components/schemas/GetSuppressionVersionHistoryData'
type: object
GetTeamMembershipsSort:
description: Specifies the order of returned team memberships
enum:
Expand Down Expand Up @@ -42745,38 +42769,13 @@ components:
description: The `RuleVersionHistory` `data`.
type: object
type: object
RuleVersionUpdate:
description: A change in a rule version.
properties:
change:
description: The new value of the field.
example: cloud_provider:aws
type: string
field:
description: The field that was changed.
example: Tags
type: string
type:
$ref: '#/components/schemas/RuleVersionUpdateType'
type: object
RuleVersionUpdateType:
description: The type of change.
enum:
- create
- update
- delete
type: string
x-enum-varnames:
- CREATE
- UPDATE
- DELETE
RuleVersions:
description: A rule version with a list of updates.
properties:
changes:
description: A list of changes.
items:
$ref: '#/components/schemas/RuleVersionUpdate'
$ref: '#/components/schemas/VersionHistoryUpdate'
type: array
rule:
$ref: '#/components/schemas/SecurityMonitoringRuleResponse'
Expand Down Expand Up @@ -51322,6 +51321,32 @@ components:
format: double
type: number
type: object
SuppressionVersionHistory:
description: Response object containing the version history of a suppression.
properties:
count:
description: The number of suppression versions.
format: int32
maximum: 2147483647
type: integer
data:
additionalProperties:
$ref: '#/components/schemas/SuppressionVersions'
description: A suppression version with a list of updates.
description: The version history of a suppression.
type: object
type: object
SuppressionVersions:
description: A suppression version with a list of updates.
properties:
changes:
description: A list of changes.
items:
$ref: '#/components/schemas/VersionHistoryUpdate'
type: array
suppression:
$ref: '#/components/schemas/SecurityMonitoringSuppressionAttributes'
type: object
TableResultV2:
description: A reference table resource containing its full configuration and
state.
Expand Down Expand Up @@ -55372,6 +55397,31 @@ components:
example: 1
format: int64
type: integer
VersionHistoryUpdate:
description: A change in a rule version.
properties:
change:
description: The new value of the field.
example: cloud_provider:aws
type: string
field:
description: The field that was changed.
example: Tags
type: string
type:
$ref: '#/components/schemas/VersionHistoryUpdateType'
type: object
VersionHistoryUpdateType:
description: The type of change.
enum:
- create
- update
- delete
type: string
x-enum-varnames:
- CREATE
- UPDATE
- DELETE
VirusTotalAPIKey:
description: The definition of the `VirusTotalAPIKey` object.
properties:
Expand Down Expand Up @@ -79065,6 +79115,35 @@ paths:
summary: Update a suppression rule
tags:
- Security Monitoring
/api/v2/security_monitoring/configuration/suppressions/{suppression_id}/version_history:
get:
description: Get a suppression's version history.
operationId: GetSuppressionVersionHistory
parameters:
- $ref: '#/components/parameters/SecurityMonitoringSuppressionID'
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/PageNumber'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/GetSuppressionVersionHistoryResponse'
description: OK
'403':
$ref: '#/components/responses/NotAuthorizedResponse'
'404':
$ref: '#/components/responses/NotFoundResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- security_monitoring_suppressions_read
summary: Get a suppression's version history
tags:
- Security Monitoring
/api/v2/security_monitoring/rules:
get:
description: List rules.
Expand Down
23 changes: 23 additions & 0 deletions examples/v2_security-monitoring_GetSuppressionVersionHistory.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Get a suppression's version history returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_security_monitoring::GetSuppressionVersionHistoryOptionalParams;
use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI;

#[tokio::main]
async fn main() {
// there is a valid "suppression" in the system
let suppression_data_id = std::env::var("SUPPRESSION_DATA_ID").unwrap();
let configuration = datadog::Configuration::new();
let api = SecurityMonitoringAPI::with_config(configuration);
let resp = api
.get_suppression_version_history(
suppression_data_id.clone(),
GetSuppressionVersionHistoryOptionalParams::default(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
159 changes: 159 additions & 0 deletions src/datadogV2/api/api_security_monitoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,29 @@ impl GetSecurityMonitoringHistsignalsByJobIdOptionalParams {
}
}

/// 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)]
Expand Down Expand Up @@ -1320,6 +1343,14 @@ pub enum GetSignalNotificationRulesError {
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)]
Expand Down Expand Up @@ -5982,6 +6013,134 @@ impl SecurityMonitoringAPI {
}
}

/// 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,
Expand Down
Loading