Skip to content

Commit 32b1dbd

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 5ce72e4 of spec repo
1 parent 4a6253b commit 32b1dbd

13 files changed

Lines changed: 1461 additions & 0 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 384 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Get Application Security details for a service returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_application_security::ApplicationSecurityAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let mut configuration = datadog::Configuration::new();
8+
configuration.set_unstable_operation_enabled("v2.GetAsmServiceByName", true);
9+
let api = ApplicationSecurityAPI::with_config(configuration);
10+
let resp = api
11+
.get_asm_service_by_name("service_filter".to_string())
12+
.await;
13+
if let Ok(value) = resp {
14+
println!("{:#?}", value);
15+
} else {
16+
println!("{:#?}", resp.unwrap_err());
17+
}
18+
}

src/datadog/configuration.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ impl Default for Configuration {
590590
("v2.update_connection".to_owned(), false),
591591
("v2.get_pruned_trace_by_id".to_owned(), false),
592592
("v2.get_trace_by_id".to_owned(), false),
593+
("v2.get_asm_service_by_name".to_owned(), false),
593594
("v2.query_aggregated_long_tasks".to_owned(), false),
594595
("v2.query_aggregated_signals_problems".to_owned(), false),
595596
("v2.query_aggregated_waterfall".to_owned(), false),

src/datadogV2/api/api_application_security.rs

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use flate2::{
66
write::{GzEncoder, ZlibEncoder},
77
Compression,
88
};
9+
use log::warn;
910
use reqwest::header::{HeaderMap, HeaderValue};
1011
use serde::{Deserialize, Serialize};
1112
use std::io::Write;
@@ -82,6 +83,14 @@ pub enum GetApplicationSecurityWafPolicyError {
8283
UnknownValue(serde_json::Value),
8384
}
8485

86+
/// GetAsmServiceByNameError is a struct for typed errors of method [`ApplicationSecurityAPI::get_asm_service_by_name`]
87+
#[derive(Debug, Clone, Serialize, Deserialize)]
88+
#[serde(untagged)]
89+
pub enum GetAsmServiceByNameError {
90+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
91+
UnknownValue(serde_json::Value),
92+
}
93+
8594
/// ListApplicationSecurityWAFCustomRulesError is a struct for typed errors of method [`ApplicationSecurityAPI::list_application_security_waf_custom_rules`]
8695
#[derive(Debug, Clone, Serialize, Deserialize)]
8796
#[serde(untagged)]
@@ -1313,6 +1322,132 @@ impl ApplicationSecurityAPI {
13131322
}
13141323
}
13151324

1325+
/// Retrieve Application Security details for services matching the given name.
1326+
/// Returns Application Security activation, compatibility, and product enablement
1327+
/// information for each matching `(service, environment)` pair, along with a count
1328+
/// of services that have Application Security Management (Threats) enabled.
1329+
pub async fn get_asm_service_by_name(
1330+
&self,
1331+
service_filter: String,
1332+
) -> Result<
1333+
crate::datadogV2::model::ApplicationSecurityServicesResponse,
1334+
datadog::Error<GetAsmServiceByNameError>,
1335+
> {
1336+
match self
1337+
.get_asm_service_by_name_with_http_info(service_filter)
1338+
.await
1339+
{
1340+
Ok(response_content) => {
1341+
if let Some(e) = response_content.entity {
1342+
Ok(e)
1343+
} else {
1344+
Err(datadog::Error::Serde(serde::de::Error::custom(
1345+
"response content was None",
1346+
)))
1347+
}
1348+
}
1349+
Err(err) => Err(err),
1350+
}
1351+
}
1352+
1353+
/// Retrieve Application Security details for services matching the given name.
1354+
/// Returns Application Security activation, compatibility, and product enablement
1355+
/// information for each matching `(service, environment)` pair, along with a count
1356+
/// of services that have Application Security Management (Threats) enabled.
1357+
pub async fn get_asm_service_by_name_with_http_info(
1358+
&self,
1359+
service_filter: String,
1360+
) -> Result<
1361+
datadog::ResponseContent<crate::datadogV2::model::ApplicationSecurityServicesResponse>,
1362+
datadog::Error<GetAsmServiceByNameError>,
1363+
> {
1364+
let local_configuration = &self.config;
1365+
let operation_id = "v2.get_asm_service_by_name";
1366+
if local_configuration.is_unstable_operation_enabled(operation_id) {
1367+
warn!("Using unstable operation {operation_id}");
1368+
} else {
1369+
let local_error = datadog::UnstableOperationDisabledError {
1370+
msg: "Operation 'v2.get_asm_service_by_name' is not enabled".to_string(),
1371+
};
1372+
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1373+
}
1374+
1375+
let local_client = &self.client;
1376+
1377+
let local_uri_str = format!(
1378+
"{}/api/v2/security/asm/services/{service_filter}",
1379+
local_configuration.get_operation_host(operation_id),
1380+
service_filter = datadog::urlencode(service_filter)
1381+
);
1382+
let mut local_req_builder =
1383+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1384+
1385+
// build headers
1386+
let mut headers = HeaderMap::new();
1387+
headers.insert("Accept", HeaderValue::from_static("application/json"));
1388+
1389+
// build user agent
1390+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1391+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1392+
Err(e) => {
1393+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
1394+
headers.insert(
1395+
reqwest::header::USER_AGENT,
1396+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1397+
)
1398+
}
1399+
};
1400+
1401+
// build auth
1402+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1403+
headers.insert(
1404+
"DD-API-KEY",
1405+
HeaderValue::from_str(local_key.key.as_str())
1406+
.expect("failed to parse DD-API-KEY header"),
1407+
);
1408+
};
1409+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1410+
headers.insert(
1411+
"DD-APPLICATION-KEY",
1412+
HeaderValue::from_str(local_key.key.as_str())
1413+
.expect("failed to parse DD-APPLICATION-KEY header"),
1414+
);
1415+
};
1416+
1417+
local_req_builder = local_req_builder.headers(headers);
1418+
let local_req = local_req_builder.build()?;
1419+
log::debug!("request content: {:?}", local_req.body());
1420+
let local_resp = local_client.execute(local_req).await?;
1421+
1422+
let local_status = local_resp.status();
1423+
let local_content = local_resp.text().await?;
1424+
log::debug!("response content: {}", local_content);
1425+
1426+
if !local_status.is_client_error() && !local_status.is_server_error() {
1427+
match serde_json::from_str::<crate::datadogV2::model::ApplicationSecurityServicesResponse>(
1428+
&local_content,
1429+
) {
1430+
Ok(e) => {
1431+
return Ok(datadog::ResponseContent {
1432+
status: local_status,
1433+
content: local_content,
1434+
entity: Some(e),
1435+
})
1436+
}
1437+
Err(e) => return Err(datadog::Error::Serde(e)),
1438+
};
1439+
} else {
1440+
let local_entity: Option<GetAsmServiceByNameError> =
1441+
serde_json::from_str(&local_content).ok();
1442+
let local_error = datadog::ResponseContent {
1443+
status: local_status,
1444+
content: local_content,
1445+
entity: local_entity,
1446+
};
1447+
Err(datadog::Error::ResponseError(local_error))
1448+
}
1449+
}
1450+
13161451
/// Retrieve a list of WAF custom rule.
13171452
pub async fn list_application_security_waf_custom_rules(
13181453
&self,

src/datadogV2/model/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9086,6 +9086,16 @@ pub mod model_security_entity_risk_scores_meta;
90869086
pub use self::model_security_entity_risk_scores_meta::SecurityEntityRiskScoresMeta;
90879087
pub mod model_security_entity_risk_score_response;
90889088
pub use self::model_security_entity_risk_score_response::SecurityEntityRiskScoreResponse;
9089+
pub mod model_application_security_services_response;
9090+
pub use self::model_application_security_services_response::ApplicationSecurityServicesResponse;
9091+
pub mod model_application_security_service_resource;
9092+
pub use self::model_application_security_service_resource::ApplicationSecurityServiceResource;
9093+
pub mod model_application_security_service_attributes;
9094+
pub use self::model_application_security_service_attributes::ApplicationSecurityServiceAttributes;
9095+
pub mod model_application_security_service_type;
9096+
pub use self::model_application_security_service_type::ApplicationSecurityServiceType;
9097+
pub mod model_application_security_services_metadata;
9098+
pub use self::model_application_security_services_metadata::ApplicationSecurityServicesMetadata;
90899099
pub mod model_security_findings_sort;
90909100
pub use self::model_security_findings_sort::SecurityFindingsSort;
90919101
pub mod model_list_security_findings_response;

0 commit comments

Comments
 (0)