Skip to content

Commit fdd5014

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 15c0cf6c of spec repo
1 parent 7efd62b commit fdd5014

19 files changed

+1279
-4
lines changed

.apigentools-info

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-02-12 15:28:26.243068",
8-
"spec_repo_commit": "b56263de"
7+
"regenerated": "2025-02-12 17:30:27.592678",
8+
"spec_repo_commit": "15c0cf6c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-02-12 15:28:26.258871",
13-
"spec_repo_commit": "b56263de"
12+
"regenerated": "2025-02-12 17:30:27.607748",
13+
"spec_repo_commit": "15c0cf6c"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

+111
Original file line numberDiff line numberDiff line change
@@ -12683,6 +12683,30 @@ components:
1268312683
$ref: '#/components/schemas/GetInterfacesData'
1268412684
type: array
1268512685
type: object
12686+
GetRuleVersionHistoryData:
12687+
description: Data for the rule version history.
12688+
properties:
12689+
attributes:
12690+
$ref: '#/components/schemas/RuleVersionHistory'
12691+
id:
12692+
description: ID of the rule.
12693+
type: string
12694+
type:
12695+
$ref: '#/components/schemas/GetRuleVersionHistoryDataType'
12696+
type: object
12697+
GetRuleVersionHistoryDataType:
12698+
description: Type of data.
12699+
enum:
12700+
- GetRuleVersionHistoryResponse
12701+
type: string
12702+
x-enum-varnames:
12703+
- GETRULEVERSIONHISTORYRESPONSE
12704+
GetRuleVersionHistoryResponse:
12705+
description: Response for getting the rule version history.
12706+
properties:
12707+
data:
12708+
$ref: '#/components/schemas/GetRuleVersionHistoryData'
12709+
type: object
1268612710
GetSBOMResponse:
1268712711
description: The expected response schema when getting an SBOM.
1268812712
properties:
@@ -23254,6 +23278,57 @@ components:
2325423278
example: John Doe
2325523279
type: string
2325623280
type: object
23281+
RuleVersionHistory:
23282+
description: Response object containing the version history of a rule.
23283+
properties:
23284+
count:
23285+
description: The number of rule versions.
23286+
format: int32
23287+
maximum: 2147483647
23288+
type: integer
23289+
data:
23290+
additionalProperties:
23291+
$ref: '#/components/schemas/RuleVersions'
23292+
description: A rule version with a list of updates.
23293+
description: The `RuleVersionHistory` `data`.
23294+
type: object
23295+
type: object
23296+
RuleVersionUpdate:
23297+
description: A change in a rule version.
23298+
properties:
23299+
change:
23300+
description: The new value of the field.
23301+
example: cloud_provider:aws
23302+
type: string
23303+
field:
23304+
description: The field that was changed.
23305+
example: Tags
23306+
type: string
23307+
type:
23308+
$ref: '#/components/schemas/RuleVersionUpdateType'
23309+
type: object
23310+
RuleVersionUpdateType:
23311+
description: The type of change.
23312+
enum:
23313+
- create
23314+
- update
23315+
- delete
23316+
type: string
23317+
x-enum-varnames:
23318+
- CREATE
23319+
- UPDATE
23320+
- DELETE
23321+
RuleVersions:
23322+
description: A rule version with a list of updates.
23323+
properties:
23324+
changes:
23325+
description: A list of changes.
23326+
items:
23327+
$ref: '#/components/schemas/RuleVersionUpdate'
23328+
type: array
23329+
rule:
23330+
$ref: '#/components/schemas/SecurityMonitoringRuleResponse'
23331+
type: object
2325723332
RumMetricCompute:
2325823333
description: The compute rule to compute the rum-based metric.
2325923334
properties:
@@ -45723,6 +45798,42 @@ paths:
4572345798
operator: OR
4572445799
permissions:
4572545800
- security_monitoring_rules_write
45801+
/api/v2/security_monitoring/rules/{rule_id}/version_history:
45802+
get:
45803+
description: Get a rule's version history.
45804+
operationId: GetRuleVersionHistory
45805+
parameters:
45806+
- $ref: '#/components/parameters/SecurityMonitoringRuleID'
45807+
- $ref: '#/components/parameters/PageSize'
45808+
- $ref: '#/components/parameters/PageNumber'
45809+
responses:
45810+
'200':
45811+
content:
45812+
application/json:
45813+
schema:
45814+
$ref: '#/components/schemas/GetRuleVersionHistoryResponse'
45815+
description: OK
45816+
'400':
45817+
$ref: '#/components/responses/BadRequestResponse'
45818+
'403':
45819+
$ref: '#/components/responses/NotAuthorizedResponse'
45820+
'404':
45821+
$ref: '#/components/responses/NotFoundResponse'
45822+
'429':
45823+
$ref: '#/components/responses/TooManyRequestsResponse'
45824+
security:
45825+
- apiKeyAuth: []
45826+
appKeyAuth: []
45827+
- AuthZ:
45828+
- security_monitoring_rules_read
45829+
summary: Get a rule's version history
45830+
tags:
45831+
- Security Monitoring
45832+
x-permission:
45833+
operator: OR
45834+
permissions:
45835+
- security_monitoring_rules_read
45836+
x-unstable: '**Note**: This endpoint is in beta and may be subject to changes.'
4572645837
/api/v2/security_monitoring/signals:
4572745838
get:
4572845839
description: 'The list endpoint returns security signals that match a search
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Get a rule's version history returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_security_monitoring::GetRuleVersionHistoryOptionalParams;
4+
use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI;
5+
6+
#[tokio::main]
7+
async fn main() {
8+
let mut configuration = datadog::Configuration::new();
9+
configuration.set_unstable_operation_enabled("v2.GetRuleVersionHistory", true);
10+
let api = SecurityMonitoringAPI::with_config(configuration);
11+
let resp = api
12+
.get_rule_version_history(
13+
"rule_id".to_string(),
14+
GetRuleVersionHistoryOptionalParams::default(),
15+
)
16+
.await;
17+
if let Ok(value) = resp {
18+
println!("{:#?}", value);
19+
} else {
20+
println!("{:#?}", resp.unwrap_err());
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Get rule version history returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_security_monitoring::GetRuleVersionHistoryOptionalParams;
4+
use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI;
5+
6+
#[tokio::main]
7+
async fn main() {
8+
// there is a valid "security_rule" in the system
9+
let security_rule_id = std::env::var("SECURITY_RULE_ID").unwrap();
10+
let mut configuration = datadog::Configuration::new();
11+
configuration.set_unstable_operation_enabled("v2.GetRuleVersionHistory", true);
12+
let api = SecurityMonitoringAPI::with_config(configuration);
13+
let resp = api
14+
.get_rule_version_history(
15+
security_rule_id.clone(),
16+
GetRuleVersionHistoryOptionalParams::default(),
17+
)
18+
.await;
19+
if let Ok(value) = resp {
20+
println!("{:#?}", value);
21+
} else {
22+
println!("{:#?}", resp.unwrap_err());
23+
}
24+
}

src/datadog/configuration.rs

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ impl Default for Configuration {
183183
("v2.delete_historical_job".to_owned(), false),
184184
("v2.get_finding".to_owned(), false),
185185
("v2.get_historical_job".to_owned(), false),
186+
("v2.get_rule_version_history".to_owned(), false),
186187
("v2.list_findings".to_owned(), false),
187188
("v2.list_historical_jobs".to_owned(), false),
188189
("v2.mute_findings".to_owned(), false),

src/datadogV2/api/api_security_monitoring.rs

+166
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,29 @@ impl GetFindingOptionalParams {
2929
}
3030
}
3131

32+
/// GetRuleVersionHistoryOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_rule_version_history`]
33+
#[non_exhaustive]
34+
#[derive(Clone, Default, Debug)]
35+
pub struct GetRuleVersionHistoryOptionalParams {
36+
/// Size for a given page. The maximum allowed value is 100.
37+
pub page_size: Option<i64>,
38+
/// Specific page number to return.
39+
pub page_number: Option<i64>,
40+
}
41+
42+
impl GetRuleVersionHistoryOptionalParams {
43+
/// Size for a given page. The maximum allowed value is 100.
44+
pub fn page_size(mut self, value: i64) -> Self {
45+
self.page_size = Some(value);
46+
self
47+
}
48+
/// Specific page number to return.
49+
pub fn page_number(mut self, value: i64) -> Self {
50+
self.page_number = Some(value);
51+
self
52+
}
53+
}
54+
3255
/// GetSBOMOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_sbom`]
3356
#[non_exhaustive]
3457
#[derive(Clone, Default, Debug)]
@@ -858,6 +881,14 @@ pub enum GetHistoricalJobError {
858881
UnknownValue(serde_json::Value),
859882
}
860883

884+
/// GetRuleVersionHistoryError is a struct for typed errors of method [`SecurityMonitoringAPI::get_rule_version_history`]
885+
#[derive(Debug, Clone, Serialize, Deserialize)]
886+
#[serde(untagged)]
887+
pub enum GetRuleVersionHistoryError {
888+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
889+
UnknownValue(serde_json::Value),
890+
}
891+
861892
/// GetSBOMError is a struct for typed errors of method [`SecurityMonitoringAPI::get_sbom`]
862893
#[derive(Debug, Clone, Serialize, Deserialize)]
863894
#[serde(untagged)]
@@ -3739,6 +3770,141 @@ impl SecurityMonitoringAPI {
37393770
}
37403771
}
37413772

3773+
/// Get a rule's version history.
3774+
pub async fn get_rule_version_history(
3775+
&self,
3776+
rule_id: String,
3777+
params: GetRuleVersionHistoryOptionalParams,
3778+
) -> Result<
3779+
crate::datadogV2::model::GetRuleVersionHistoryResponse,
3780+
datadog::Error<GetRuleVersionHistoryError>,
3781+
> {
3782+
match self
3783+
.get_rule_version_history_with_http_info(rule_id, params)
3784+
.await
3785+
{
3786+
Ok(response_content) => {
3787+
if let Some(e) = response_content.entity {
3788+
Ok(e)
3789+
} else {
3790+
Err(datadog::Error::Serde(serde::de::Error::custom(
3791+
"response content was None",
3792+
)))
3793+
}
3794+
}
3795+
Err(err) => Err(err),
3796+
}
3797+
}
3798+
3799+
/// Get a rule's version history.
3800+
pub async fn get_rule_version_history_with_http_info(
3801+
&self,
3802+
rule_id: String,
3803+
params: GetRuleVersionHistoryOptionalParams,
3804+
) -> Result<
3805+
datadog::ResponseContent<crate::datadogV2::model::GetRuleVersionHistoryResponse>,
3806+
datadog::Error<GetRuleVersionHistoryError>,
3807+
> {
3808+
let local_configuration = &self.config;
3809+
let operation_id = "v2.get_rule_version_history";
3810+
if local_configuration.is_unstable_operation_enabled(operation_id) {
3811+
warn!("Using unstable operation {operation_id}");
3812+
} else {
3813+
let local_error = datadog::UnstableOperationDisabledError {
3814+
msg: "Operation 'v2.get_rule_version_history' is not enabled".to_string(),
3815+
};
3816+
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3817+
}
3818+
3819+
// unbox and build optional parameters
3820+
let page_size = params.page_size;
3821+
let page_number = params.page_number;
3822+
3823+
let local_client = &self.client;
3824+
3825+
let local_uri_str = format!(
3826+
"{}/api/v2/security_monitoring/rules/{rule_id}/version_history",
3827+
local_configuration.get_operation_host(operation_id),
3828+
rule_id = datadog::urlencode(rule_id)
3829+
);
3830+
let mut local_req_builder =
3831+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3832+
3833+
if let Some(ref local_query_param) = page_size {
3834+
local_req_builder =
3835+
local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
3836+
};
3837+
if let Some(ref local_query_param) = page_number {
3838+
local_req_builder =
3839+
local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
3840+
};
3841+
3842+
// build headers
3843+
let mut headers = HeaderMap::new();
3844+
headers.insert("Accept", HeaderValue::from_static("application/json"));
3845+
3846+
// build user agent
3847+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3848+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3849+
Err(e) => {
3850+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
3851+
headers.insert(
3852+
reqwest::header::USER_AGENT,
3853+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3854+
)
3855+
}
3856+
};
3857+
3858+
// build auth
3859+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3860+
headers.insert(
3861+
"DD-API-KEY",
3862+
HeaderValue::from_str(local_key.key.as_str())
3863+
.expect("failed to parse DD-API-KEY header"),
3864+
);
3865+
};
3866+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3867+
headers.insert(
3868+
"DD-APPLICATION-KEY",
3869+
HeaderValue::from_str(local_key.key.as_str())
3870+
.expect("failed to parse DD-APPLICATION-KEY header"),
3871+
);
3872+
};
3873+
3874+
local_req_builder = local_req_builder.headers(headers);
3875+
let local_req = local_req_builder.build()?;
3876+
log::debug!("request content: {:?}", local_req.body());
3877+
let local_resp = local_client.execute(local_req).await?;
3878+
3879+
let local_status = local_resp.status();
3880+
let local_content = local_resp.text().await?;
3881+
log::debug!("response content: {}", local_content);
3882+
3883+
if !local_status.is_client_error() && !local_status.is_server_error() {
3884+
match serde_json::from_str::<crate::datadogV2::model::GetRuleVersionHistoryResponse>(
3885+
&local_content,
3886+
) {
3887+
Ok(e) => {
3888+
return Ok(datadog::ResponseContent {
3889+
status: local_status,
3890+
content: local_content,
3891+
entity: Some(e),
3892+
})
3893+
}
3894+
Err(e) => return Err(datadog::Error::Serde(e)),
3895+
};
3896+
} else {
3897+
let local_entity: Option<GetRuleVersionHistoryError> =
3898+
serde_json::from_str(&local_content).ok();
3899+
let local_error = datadog::ResponseContent {
3900+
status: local_status,
3901+
content: local_content,
3902+
entity: local_entity,
3903+
};
3904+
Err(datadog::Error::ResponseError(local_error))
3905+
}
3906+
}
3907+
37423908
/// Get a single SBOM related to an asset by its type and name.
37433909
///
37443910
pub async fn get_sbom(

0 commit comments

Comments
 (0)