@@ -1221,6 +1221,14 @@ pub enum AttachJiraIssueError {
12211221 UnknownValue(serde_json::Value),
12221222}
12231223
1224+ /// BulkDeleteSecurityMonitoringRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::bulk_delete_security_monitoring_rules`]
1225+ #[derive(Debug, Clone, Serialize, Deserialize)]
1226+ #[serde(untagged)]
1227+ pub enum BulkDeleteSecurityMonitoringRulesError {
1228+ APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1229+ UnknownValue(serde_json::Value),
1230+ }
1231+
12241232/// BulkEditSecurityMonitoringSignalsError is a struct for typed errors of method [`SecurityMonitoringAPI::bulk_edit_security_monitoring_signals`]
12251233#[derive(Debug, Clone, Serialize, Deserialize)]
12261234#[serde(untagged)]
@@ -2467,6 +2475,165 @@ impl SecurityMonitoringAPI {
24672475 }
24682476 }
24692477
2478+ /// Delete multiple security monitoring rules in a single request. Default rules cannot be deleted.
2479+ pub async fn bulk_delete_security_monitoring_rules(
2480+ &self,
2481+ body: crate::datadogV2::model::SecurityMonitoringRuleBulkDeletePayload,
2482+ ) -> Result<
2483+ crate::datadogV2::model::SecurityMonitoringRuleBulkDeleteResponse,
2484+ datadog::Error<BulkDeleteSecurityMonitoringRulesError>,
2485+ > {
2486+ match self
2487+ .bulk_delete_security_monitoring_rules_with_http_info(body)
2488+ .await
2489+ {
2490+ Ok(response_content) => {
2491+ if let Some(e) = response_content.entity {
2492+ Ok(e)
2493+ } else {
2494+ Err(datadog::Error::Serde(serde::de::Error::custom(
2495+ "response content was None",
2496+ )))
2497+ }
2498+ }
2499+ Err(err) => Err(err),
2500+ }
2501+ }
2502+
2503+ /// Delete multiple security monitoring rules in a single request. Default rules cannot be deleted.
2504+ pub async fn bulk_delete_security_monitoring_rules_with_http_info(
2505+ &self,
2506+ body: crate::datadogV2::model::SecurityMonitoringRuleBulkDeletePayload,
2507+ ) -> Result<
2508+ datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleBulkDeleteResponse>,
2509+ datadog::Error<BulkDeleteSecurityMonitoringRulesError>,
2510+ > {
2511+ let local_configuration = &self.config;
2512+ let operation_id = "v2.bulk_delete_security_monitoring_rules";
2513+
2514+ let local_client = &self.client;
2515+
2516+ let local_uri_str = format!(
2517+ "{}/api/v2/security_monitoring/rules/bulk_delete",
2518+ local_configuration.get_operation_host(operation_id)
2519+ );
2520+ let mut local_req_builder =
2521+ local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2522+
2523+ // build headers
2524+ let mut headers = HeaderMap::new();
2525+ headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2526+ headers.insert("Accept", HeaderValue::from_static("application/json"));
2527+
2528+ // build user agent
2529+ match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2530+ Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2531+ Err(e) => {
2532+ log::warn!("Failed to parse user agent header: {e}, falling back to default");
2533+ headers.insert(
2534+ reqwest::header::USER_AGENT,
2535+ HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2536+ )
2537+ }
2538+ };
2539+
2540+ // build auth
2541+ if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2542+ headers.insert(
2543+ "DD-API-KEY",
2544+ HeaderValue::from_str(local_key.key.as_str())
2545+ .expect("failed to parse DD-API-KEY header"),
2546+ );
2547+ };
2548+ if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2549+ headers.insert(
2550+ "DD-APPLICATION-KEY",
2551+ HeaderValue::from_str(local_key.key.as_str())
2552+ .expect("failed to parse DD-APPLICATION-KEY header"),
2553+ );
2554+ };
2555+
2556+ // build body parameters
2557+ let output = Vec::new();
2558+ let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2559+ if body.serialize(&mut ser).is_ok() {
2560+ if let Some(content_encoding) = headers.get("Content-Encoding") {
2561+ match content_encoding.to_str().unwrap_or_default() {
2562+ "gzip" => {
2563+ let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2564+ let _ = enc.write_all(ser.into_inner().as_slice());
2565+ match enc.finish() {
2566+ Ok(buf) => {
2567+ local_req_builder = local_req_builder.body(buf);
2568+ }
2569+ Err(e) => return Err(datadog::Error::Io(e)),
2570+ }
2571+ }
2572+ "deflate" => {
2573+ let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2574+ let _ = enc.write_all(ser.into_inner().as_slice());
2575+ match enc.finish() {
2576+ Ok(buf) => {
2577+ local_req_builder = local_req_builder.body(buf);
2578+ }
2579+ Err(e) => return Err(datadog::Error::Io(e)),
2580+ }
2581+ }
2582+ #[cfg(feature = "zstd")]
2583+ "zstd1" => {
2584+ let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2585+ let _ = enc.write_all(ser.into_inner().as_slice());
2586+ match enc.finish() {
2587+ Ok(buf) => {
2588+ local_req_builder = local_req_builder.body(buf);
2589+ }
2590+ Err(e) => return Err(datadog::Error::Io(e)),
2591+ }
2592+ }
2593+ _ => {
2594+ local_req_builder = local_req_builder.body(ser.into_inner());
2595+ }
2596+ }
2597+ } else {
2598+ local_req_builder = local_req_builder.body(ser.into_inner());
2599+ }
2600+ }
2601+
2602+ local_req_builder = local_req_builder.headers(headers);
2603+ let local_req = local_req_builder.build()?;
2604+ log::debug!("request content: {:?}", local_req.body());
2605+ let local_resp = local_client.execute(local_req).await?;
2606+
2607+ let local_status = local_resp.status();
2608+ let local_content = local_resp.text().await?;
2609+ log::debug!("response content: {}", local_content);
2610+
2611+ if !local_status.is_client_error() && !local_status.is_server_error() {
2612+ match serde_json::from_str::<
2613+ crate::datadogV2::model::SecurityMonitoringRuleBulkDeleteResponse,
2614+ >(&local_content)
2615+ {
2616+ Ok(e) => {
2617+ return Ok(datadog::ResponseContent {
2618+ status: local_status,
2619+ content: local_content,
2620+ entity: Some(e),
2621+ })
2622+ }
2623+ Err(e) => return Err(datadog::Error::Serde(e)),
2624+ };
2625+ } else {
2626+ let local_entity: Option<BulkDeleteSecurityMonitoringRulesError> =
2627+ serde_json::from_str(&local_content).ok();
2628+ let local_error = datadog::ResponseContent {
2629+ status: local_status,
2630+ content: local_content,
2631+ entity: local_entity,
2632+ };
2633+ Err(datadog::Error::ResponseError(local_error))
2634+ }
2635+ }
2636+
24702637 /// Update the triage state or assignee of multiple security signals at once.
24712638 /// The maximum number of signals that can be updated in a single request is 199.
24722639 pub async fn bulk_edit_security_monitoring_signals(
0 commit comments