Skip to content

Commit 5f1702e

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit a989199 of spec repo
1 parent 37d739b commit 5f1702e

19 files changed

+1084
-52
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 105 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23526,6 +23526,30 @@ components:
2352623526
required:
2352723527
- data
2352823528
type: object
23529+
GetSuppressionVersionHistoryData:
23530+
description: Data for the suppression version history.
23531+
properties:
23532+
attributes:
23533+
$ref: '#/components/schemas/SuppressionVersionHistory'
23534+
id:
23535+
description: ID of the suppression.
23536+
type: string
23537+
type:
23538+
$ref: '#/components/schemas/GetSuppressionVersionHistoryDataType'
23539+
type: object
23540+
GetSuppressionVersionHistoryDataType:
23541+
description: Type of data.
23542+
enum:
23543+
- suppression_version_history
23544+
type: string
23545+
x-enum-varnames:
23546+
- SUPPRESSIONVERSIONHISTORY
23547+
GetSuppressionVersionHistoryResponse:
23548+
description: Response for getting the suppression version history.
23549+
properties:
23550+
data:
23551+
$ref: '#/components/schemas/GetSuppressionVersionHistoryData'
23552+
type: object
2352923553
GetTeamMembershipsSort:
2353023554
description: Specifies the order of returned team memberships
2353123555
enum:
@@ -42745,38 +42769,13 @@ components:
4274542769
description: The `RuleVersionHistory` `data`.
4274642770
type: object
4274742771
type: object
42748-
RuleVersionUpdate:
42749-
description: A change in a rule version.
42750-
properties:
42751-
change:
42752-
description: The new value of the field.
42753-
example: cloud_provider:aws
42754-
type: string
42755-
field:
42756-
description: The field that was changed.
42757-
example: Tags
42758-
type: string
42759-
type:
42760-
$ref: '#/components/schemas/RuleVersionUpdateType'
42761-
type: object
42762-
RuleVersionUpdateType:
42763-
description: The type of change.
42764-
enum:
42765-
- create
42766-
- update
42767-
- delete
42768-
type: string
42769-
x-enum-varnames:
42770-
- CREATE
42771-
- UPDATE
42772-
- DELETE
4277342772
RuleVersions:
4277442773
description: A rule version with a list of updates.
4277542774
properties:
4277642775
changes:
4277742776
description: A list of changes.
4277842777
items:
42779-
$ref: '#/components/schemas/RuleVersionUpdate'
42778+
$ref: '#/components/schemas/VersionHistoryUpdate'
4278042779
type: array
4278142780
rule:
4278242781
$ref: '#/components/schemas/SecurityMonitoringRuleResponse'
@@ -51322,6 +51321,32 @@ components:
5132251321
format: double
5132351322
type: number
5132451323
type: object
51324+
SuppressionVersionHistory:
51325+
description: Response object containing the version history of a suppression.
51326+
properties:
51327+
count:
51328+
description: The number of suppression versions.
51329+
format: int32
51330+
maximum: 2147483647
51331+
type: integer
51332+
data:
51333+
additionalProperties:
51334+
$ref: '#/components/schemas/SuppressionVersions'
51335+
description: A suppression version with a list of updates.
51336+
description: The `SuppressionVersionHistory` `data`.
51337+
type: object
51338+
type: object
51339+
SuppressionVersions:
51340+
description: A suppression version with a list of updates.
51341+
properties:
51342+
changes:
51343+
description: A list of changes.
51344+
items:
51345+
$ref: '#/components/schemas/VersionHistoryUpdate'
51346+
type: array
51347+
suppression:
51348+
$ref: '#/components/schemas/SecurityMonitoringSuppressionAttributes'
51349+
type: object
5132551350
TableResultV2:
5132651351
description: A reference table resource containing its full configuration and
5132751352
state.
@@ -55372,6 +55397,31 @@ components:
5537255397
example: 1
5537355398
format: int64
5537455399
type: integer
55400+
VersionHistoryUpdate:
55401+
description: A change in a rule version.
55402+
properties:
55403+
change:
55404+
description: The new value of the field.
55405+
example: cloud_provider:aws
55406+
type: string
55407+
field:
55408+
description: The field that was changed.
55409+
example: Tags
55410+
type: string
55411+
type:
55412+
$ref: '#/components/schemas/VersionHistoryUpdateType'
55413+
type: object
55414+
VersionHistoryUpdateType:
55415+
description: The type of change.
55416+
enum:
55417+
- create
55418+
- update
55419+
- delete
55420+
type: string
55421+
x-enum-varnames:
55422+
- CREATE
55423+
- UPDATE
55424+
- DELETE
5537555425
VirusTotalAPIKey:
5537655426
description: The definition of the `VirusTotalAPIKey` object.
5537755427
properties:
@@ -79065,6 +79115,35 @@ paths:
7906579115
summary: Update a suppression rule
7906679116
tags:
7906779117
- Security Monitoring
79118+
/api/v2/security_monitoring/configuration/suppressions/{suppression_id}/version_history:
79119+
get:
79120+
description: Get a suppression's version history.
79121+
operationId: GetSuppressionVersionHistory
79122+
parameters:
79123+
- $ref: '#/components/parameters/SecurityMonitoringSuppressionID'
79124+
- $ref: '#/components/parameters/PageSize'
79125+
- $ref: '#/components/parameters/PageNumber'
79126+
responses:
79127+
'200':
79128+
content:
79129+
application/json:
79130+
schema:
79131+
$ref: '#/components/schemas/GetSuppressionVersionHistoryResponse'
79132+
description: OK
79133+
'403':
79134+
$ref: '#/components/responses/NotAuthorizedResponse'
79135+
'404':
79136+
$ref: '#/components/responses/NotFoundResponse'
79137+
'429':
79138+
$ref: '#/components/responses/TooManyRequestsResponse'
79139+
security:
79140+
- apiKeyAuth: []
79141+
appKeyAuth: []
79142+
- AuthZ:
79143+
- security_monitoring_suppressions_read
79144+
summary: Get a suppression's version history
79145+
tags:
79146+
- Security Monitoring
7906879147
/api/v2/security_monitoring/rules:
7906979148
get:
7907079149
description: List rules.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Get a suppression's version history returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_security_monitoring::GetSuppressionVersionHistoryOptionalParams;
4+
use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI;
5+
6+
#[tokio::main]
7+
async fn main() {
8+
// there is a valid "suppression" in the system
9+
let suppression_data_id = std::env::var("SUPPRESSION_DATA_ID").unwrap();
10+
let configuration = datadog::Configuration::new();
11+
let api = SecurityMonitoringAPI::with_config(configuration);
12+
let resp = api
13+
.get_suppression_version_history(
14+
suppression_data_id.clone(),
15+
GetSuppressionVersionHistoryOptionalParams::default(),
16+
)
17+
.await;
18+
if let Ok(value) = resp {
19+
println!("{:#?}", value);
20+
} else {
21+
println!("{:#?}", resp.unwrap_err());
22+
}
23+
}

src/datadogV2/api/api_security_monitoring.rs

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,29 @@ impl GetSecurityMonitoringHistsignalsByJobIdOptionalParams {
156156
}
157157
}
158158

159+
/// GetSuppressionVersionHistoryOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_suppression_version_history`]
160+
#[non_exhaustive]
161+
#[derive(Clone, Default, Debug)]
162+
pub struct GetSuppressionVersionHistoryOptionalParams {
163+
/// Size for a given page. The maximum allowed value is 100.
164+
pub page_size: Option<i64>,
165+
/// Specific page number to return.
166+
pub page_number: Option<i64>,
167+
}
168+
169+
impl GetSuppressionVersionHistoryOptionalParams {
170+
/// Size for a given page. The maximum allowed value is 100.
171+
pub fn page_size(mut self, value: i64) -> Self {
172+
self.page_size = Some(value);
173+
self
174+
}
175+
/// Specific page number to return.
176+
pub fn page_number(mut self, value: i64) -> Self {
177+
self.page_number = Some(value);
178+
self
179+
}
180+
}
181+
159182
/// ListAssetsSBOMsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_assets_sbo_ms`]
160183
#[non_exhaustive]
161184
#[derive(Clone, Default, Debug)]
@@ -1320,6 +1343,14 @@ pub enum GetSignalNotificationRulesError {
13201343
UnknownValue(serde_json::Value),
13211344
}
13221345

1346+
/// GetSuppressionVersionHistoryError is a struct for typed errors of method [`SecurityMonitoringAPI::get_suppression_version_history`]
1347+
#[derive(Debug, Clone, Serialize, Deserialize)]
1348+
#[serde(untagged)]
1349+
pub enum GetSuppressionVersionHistoryError {
1350+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1351+
UnknownValue(serde_json::Value),
1352+
}
1353+
13231354
/// GetSuppressionsAffectingFutureRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_suppressions_affecting_future_rule`]
13241355
#[derive(Debug, Clone, Serialize, Deserialize)]
13251356
#[serde(untagged)]
@@ -5982,6 +6013,134 @@ impl SecurityMonitoringAPI {
59826013
}
59836014
}
59846015

6016+
/// Get a suppression's version history.
6017+
pub async fn get_suppression_version_history(
6018+
&self,
6019+
suppression_id: String,
6020+
params: GetSuppressionVersionHistoryOptionalParams,
6021+
) -> Result<
6022+
crate::datadogV2::model::GetSuppressionVersionHistoryResponse,
6023+
datadog::Error<GetSuppressionVersionHistoryError>,
6024+
> {
6025+
match self
6026+
.get_suppression_version_history_with_http_info(suppression_id, params)
6027+
.await
6028+
{
6029+
Ok(response_content) => {
6030+
if let Some(e) = response_content.entity {
6031+
Ok(e)
6032+
} else {
6033+
Err(datadog::Error::Serde(serde::de::Error::custom(
6034+
"response content was None",
6035+
)))
6036+
}
6037+
}
6038+
Err(err) => Err(err),
6039+
}
6040+
}
6041+
6042+
/// Get a suppression's version history.
6043+
pub async fn get_suppression_version_history_with_http_info(
6044+
&self,
6045+
suppression_id: String,
6046+
params: GetSuppressionVersionHistoryOptionalParams,
6047+
) -> Result<
6048+
datadog::ResponseContent<crate::datadogV2::model::GetSuppressionVersionHistoryResponse>,
6049+
datadog::Error<GetSuppressionVersionHistoryError>,
6050+
> {
6051+
let local_configuration = &self.config;
6052+
let operation_id = "v2.get_suppression_version_history";
6053+
6054+
// unbox and build optional parameters
6055+
let page_size = params.page_size;
6056+
let page_number = params.page_number;
6057+
6058+
let local_client = &self.client;
6059+
6060+
let local_uri_str = format!(
6061+
"{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}/version_history",
6062+
local_configuration.get_operation_host(operation_id), suppression_id=
6063+
datadog::urlencode(suppression_id)
6064+
);
6065+
let mut local_req_builder =
6066+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6067+
6068+
if let Some(ref local_query_param) = page_size {
6069+
local_req_builder =
6070+
local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
6071+
};
6072+
if let Some(ref local_query_param) = page_number {
6073+
local_req_builder =
6074+
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
6075+
};
6076+
6077+
// build headers
6078+
let mut headers = HeaderMap::new();
6079+
headers.insert("Accept", HeaderValue::from_static("application/json"));
6080+
6081+
// build user agent
6082+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6083+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6084+
Err(e) => {
6085+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
6086+
headers.insert(
6087+
reqwest::header::USER_AGENT,
6088+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6089+
)
6090+
}
6091+
};
6092+
6093+
// build auth
6094+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6095+
headers.insert(
6096+
"DD-API-KEY",
6097+
HeaderValue::from_str(local_key.key.as_str())
6098+
.expect("failed to parse DD-API-KEY header"),
6099+
);
6100+
};
6101+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6102+
headers.insert(
6103+
"DD-APPLICATION-KEY",
6104+
HeaderValue::from_str(local_key.key.as_str())
6105+
.expect("failed to parse DD-APPLICATION-KEY header"),
6106+
);
6107+
};
6108+
6109+
local_req_builder = local_req_builder.headers(headers);
6110+
let local_req = local_req_builder.build()?;
6111+
log::debug!("request content: {:?}", local_req.body());
6112+
let local_resp = local_client.execute(local_req).await?;
6113+
6114+
let local_status = local_resp.status();
6115+
let local_content = local_resp.text().await?;
6116+
log::debug!("response content: {}", local_content);
6117+
6118+
if !local_status.is_client_error() && !local_status.is_server_error() {
6119+
match serde_json::from_str::<
6120+
crate::datadogV2::model::GetSuppressionVersionHistoryResponse,
6121+
>(&local_content)
6122+
{
6123+
Ok(e) => {
6124+
return Ok(datadog::ResponseContent {
6125+
status: local_status,
6126+
content: local_content,
6127+
entity: Some(e),
6128+
})
6129+
}
6130+
Err(e) => return Err(datadog::Error::Serde(e)),
6131+
};
6132+
} else {
6133+
let local_entity: Option<GetSuppressionVersionHistoryError> =
6134+
serde_json::from_str(&local_content).ok();
6135+
let local_error = datadog::ResponseContent {
6136+
status: local_status,
6137+
content: local_content,
6138+
entity: local_entity,
6139+
};
6140+
Err(datadog::Error::ResponseError(local_error))
6141+
}
6142+
}
6143+
59856144
/// Get the list of suppressions that would affect a rule.
59866145
pub async fn get_suppressions_affecting_future_rule(
59876146
&self,

0 commit comments

Comments
 (0)