Skip to content

Commit ab6ef7a

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit f045128 of spec repo
1 parent f64424f commit ab6ef7a

17 files changed

Lines changed: 1167 additions & 4 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23283,6 +23283,8 @@ components:
2328323283
$ref: "#/components/schemas/Enabled"
2328423284
name:
2328523285
$ref: "#/components/schemas/RuleName"
23286+
routing:
23287+
$ref: "#/components/schemas/NotificationRuleRouting"
2328623288
selectors:
2328723289
$ref: "#/components/schemas/Selectors"
2328823290
targets:
@@ -57809,6 +57811,72 @@ components:
5780957811
- targets
5781057812
- version
5781157813
type: object
57814+
NotificationRulePreviewNotificationStatus:
57815+
description: The notification status for the given rule type. `SUCCESS` means a matching event was found and the notification was sent successfully. `DEFAULT` means no matching event was found and a default placeholder notification was sent instead. `ERROR` means an error occurred while sending the notification.
57816+
enum:
57817+
- SUCCESS
57818+
- DEFAULT
57819+
- ERROR
57820+
example: SUCCESS
57821+
type: string
57822+
x-enum-varnames:
57823+
- SUCCESS
57824+
- DEFAULT
57825+
- ERROR
57826+
NotificationRulePreviewResponse:
57827+
description: Response from the notification preview request.
57828+
properties:
57829+
data:
57830+
$ref: "#/components/schemas/NotificationRulePreviewResponseData"
57831+
required:
57832+
- data
57833+
type: object
57834+
NotificationRulePreviewResponseAttributes:
57835+
description: Attributes of the notification preview response.
57836+
properties:
57837+
preview_results:
57838+
$ref: "#/components/schemas/NotificationRulePreviewResults"
57839+
required:
57840+
- preview_results
57841+
type: object
57842+
NotificationRulePreviewResponseData:
57843+
description: The notification preview response data.
57844+
properties:
57845+
attributes:
57846+
$ref: "#/components/schemas/NotificationRulePreviewResponseAttributes"
57847+
type:
57848+
$ref: "#/components/schemas/NotificationRulePreviewResponseType"
57849+
required:
57850+
- type
57851+
- attributes
57852+
type: object
57853+
NotificationRulePreviewResponseType:
57854+
description: The type of the notification preview response.
57855+
enum:
57856+
- notification_preview_response
57857+
example: notification_preview_response
57858+
type: string
57859+
x-enum-varnames:
57860+
- NOTIFICATION_PREVIEW_RESPONSE
57861+
NotificationRulePreviewResult:
57862+
description: The preview result for a single rule type.
57863+
properties:
57864+
notification_status:
57865+
$ref: "#/components/schemas/NotificationRulePreviewNotificationStatus"
57866+
rule_type:
57867+
$ref: "#/components/schemas/RuleTypesItems"
57868+
required:
57869+
- rule_type
57870+
- notification_status
57871+
type: object
57872+
NotificationRulePreviewResults:
57873+
description: List of preview results for each rule type matched by the notification rule.
57874+
example:
57875+
- notification_status: DEFAULT
57876+
rule_type: log_detection
57877+
items:
57878+
$ref: "#/components/schemas/NotificationRulePreviewResult"
57879+
type: array
5781257880
NotificationRuleQuery:
5781357881
description: The query is composed of one or several key:value pairs, which can be used to filter security issues on tags and attributes.
5781457882
example: (source:production_service OR env:prod)
@@ -57819,6 +57887,22 @@ components:
5781957887
data:
5782057888
$ref: "#/components/schemas/NotificationRule"
5782157889
type: object
57890+
NotificationRuleRouting:
57891+
description: Routing configuration for the notification rule.
57892+
properties:
57893+
mode:
57894+
$ref: "#/components/schemas/NotificationRuleRoutingMode"
57895+
required:
57896+
- mode
57897+
type: object
57898+
NotificationRuleRoutingMode:
57899+
description: The routing mode for the notification rule. `manual` sends notifications to the configured targets.
57900+
enum:
57901+
- manual
57902+
example: manual
57903+
type: string
57904+
x-enum-varnames:
57905+
- MANUAL
5782257906
NotificationRulesType:
5782357907
description: The rule type associated to notification rules.
5782457908
enum:
@@ -67052,6 +67136,8 @@ components:
6705267136
$ref: "#/components/schemas/Enabled"
6705367137
name:
6705467138
$ref: "#/components/schemas/RuleName"
67139+
routing:
67140+
$ref: "#/components/schemas/NotificationRuleRouting"
6705567141
selectors:
6705667142
$ref: "#/components/schemas/Selectors"
6705767143
targets:
@@ -73361,6 +73447,7 @@ components:
7336173447
- iac_misconfiguration
7336273448
- sast_vulnerability
7336373449
- secret_vulnerability
73450+
example: log_detection
7336473451
type: string
7336573452
x-enum-varnames:
7336673453
- APPLICATION_SECURITY
@@ -159547,6 +159634,72 @@ paths:
159547159634
x-unstable: |-
159548159635
**Note**: This endpoint is in preview and is subject to change.
159549159636
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
159637+
/api/v2/security_monitoring/configuration/notification_rules/send_notification_preview:
159638+
post:
159639+
description: Send a notification preview to test that a notification rule's targets are properly configured.
159640+
operationId: SendSecurityMonitoringNotificationPreview
159641+
requestBody:
159642+
content:
159643+
application/json:
159644+
examples:
159645+
default:
159646+
value:
159647+
data:
159648+
attributes:
159649+
enabled: true
159650+
name: Rule 1
159651+
selectors:
159652+
query: env:prod
159653+
rule_types:
159654+
- log_detection
159655+
severities:
159656+
- critical
159657+
trigger_source: security_signals
159658+
targets:
159659+
- "@john.doe@email.com"
159660+
type: notification_rules
159661+
schema:
159662+
$ref: "#/components/schemas/CreateNotificationRuleParameters"
159663+
required: true
159664+
responses:
159665+
"200":
159666+
content:
159667+
application/json:
159668+
examples:
159669+
default:
159670+
value:
159671+
data:
159672+
attributes:
159673+
preview_results:
159674+
- notification_status: DEFAULT
159675+
rule_type: log_detection
159676+
type: notification_preview_response
159677+
schema:
159678+
$ref: "#/components/schemas/NotificationRulePreviewResponse"
159679+
description: OK
159680+
"400":
159681+
content:
159682+
application/json:
159683+
schema:
159684+
$ref: "#/components/schemas/JSONAPIErrorResponse"
159685+
description: Bad Request
159686+
"403":
159687+
$ref: "#/components/responses/NotAuthorizedResponse"
159688+
"429":
159689+
$ref: "#/components/responses/TooManyRequestsResponse"
159690+
security:
159691+
- apiKeyAuth: []
159692+
appKeyAuth: []
159693+
- AuthZ:
159694+
- security_monitoring_notification_profiles_read
159695+
summary: Test a notification rule
159696+
tags:
159697+
- Security Monitoring
159698+
x-codegen-request-body-name: body
159699+
"x-permission":
159700+
operator: OR
159701+
permissions:
159702+
- security_monitoring_notification_profiles_read
159550159703
/api/v2/security_monitoring/configuration/security_filters:
159551159704
get:
159552159705
description: Get the list of configured security filters with their definitions.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Test a notification rule returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI;
4+
use datadog_api_client::datadogV2::model::CreateNotificationRuleParameters;
5+
use datadog_api_client::datadogV2::model::CreateNotificationRuleParametersData;
6+
use datadog_api_client::datadogV2::model::CreateNotificationRuleParametersDataAttributes;
7+
use datadog_api_client::datadogV2::model::NotificationRuleRouting;
8+
use datadog_api_client::datadogV2::model::NotificationRuleRoutingMode;
9+
use datadog_api_client::datadogV2::model::NotificationRulesType;
10+
use datadog_api_client::datadogV2::model::RuleSeverity;
11+
use datadog_api_client::datadogV2::model::RuleTypesItems;
12+
use datadog_api_client::datadogV2::model::Selectors;
13+
use datadog_api_client::datadogV2::model::TriggerSource;
14+
15+
#[tokio::main]
16+
async fn main() {
17+
let body =
18+
CreateNotificationRuleParameters::new().data(CreateNotificationRuleParametersData::new(
19+
CreateNotificationRuleParametersDataAttributes::new(
20+
"Rule 1".to_string(),
21+
Selectors::new(TriggerSource::SECURITY_FINDINGS)
22+
.query("(source:production_service OR env:prod)".to_string())
23+
.rule_types(vec![
24+
RuleTypesItems::MISCONFIGURATION,
25+
RuleTypesItems::ATTACK_PATH,
26+
])
27+
.severities(vec![RuleSeverity::CRITICAL]),
28+
vec!["@john.doe@email.com".to_string()],
29+
)
30+
.enabled(true)
31+
.routing(NotificationRuleRouting::new(
32+
NotificationRuleRoutingMode::MANUAL,
33+
))
34+
.time_aggregation(86400),
35+
NotificationRulesType::NOTIFICATION_RULES,
36+
));
37+
let configuration = datadog::Configuration::new();
38+
let api = SecurityMonitoringAPI::with_config(configuration);
39+
let resp = api
40+
.send_security_monitoring_notification_preview(body)
41+
.await;
42+
if let Ok(value) = resp {
43+
println!("{:#?}", value);
44+
} else {
45+
println!("{:#?}", resp.unwrap_err());
46+
}
47+
}

0 commit comments

Comments
 (0)