Skip to content

Commit f7253f2

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Regenerate client from commit 19949fa of spec repo (#3652)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent c9060ae commit f7253f2

19 files changed

Lines changed: 745 additions & 4 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23518,6 +23518,8 @@ components:
2351823518
$ref: "#/components/schemas/Enabled"
2351923519
name:
2352023520
$ref: "#/components/schemas/RuleName"
23521+
routing:
23522+
$ref: "#/components/schemas/NotificationRuleRouting"
2352123523
selectors:
2352223524
$ref: "#/components/schemas/Selectors"
2352323525
targets:
@@ -59051,6 +59053,76 @@ components:
5905159053
- targets
5905259054
- version
5905359055
type: object
59056+
NotificationRulePreviewNotificationStatus:
59057+
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.
59058+
enum:
59059+
- SUCCESS
59060+
- DEFAULT
59061+
- ERROR
59062+
example: SUCCESS
59063+
type: string
59064+
x-enum-varnames:
59065+
- SUCCESS
59066+
- DEFAULT
59067+
- ERROR
59068+
NotificationRulePreviewResponse:
59069+
description: Response from the notification preview request.
59070+
properties:
59071+
data:
59072+
$ref: "#/components/schemas/NotificationRulePreviewResponseData"
59073+
required:
59074+
- data
59075+
type: object
59076+
NotificationRulePreviewResponseAttributes:
59077+
description: Attributes of the notification preview response.
59078+
properties:
59079+
preview_results:
59080+
$ref: "#/components/schemas/NotificationRulePreviewResults"
59081+
required:
59082+
- preview_results
59083+
type: object
59084+
NotificationRulePreviewResponseData:
59085+
description: The notification preview response data.
59086+
properties:
59087+
attributes:
59088+
$ref: "#/components/schemas/NotificationRulePreviewResponseAttributes"
59089+
id:
59090+
description: The ID of the notification preview response.
59091+
example: rka-loa-zwu
59092+
type: string
59093+
type:
59094+
$ref: "#/components/schemas/NotificationRulePreviewResponseType"
59095+
required:
59096+
- type
59097+
- attributes
59098+
type: object
59099+
NotificationRulePreviewResponseType:
59100+
description: The type of the notification preview response.
59101+
enum:
59102+
- notification_preview_response
59103+
example: notification_preview_response
59104+
type: string
59105+
x-enum-varnames:
59106+
- NOTIFICATION_PREVIEW_RESPONSE
59107+
NotificationRulePreviewResult:
59108+
description: The preview result for a single rule type.
59109+
properties:
59110+
notification_status:
59111+
$ref: "#/components/schemas/NotificationRulePreviewNotificationStatus"
59112+
rule_type:
59113+
$ref: "#/components/schemas/RuleTypesItems"
59114+
required:
59115+
- rule_type
59116+
- notification_status
59117+
type: object
59118+
NotificationRulePreviewResults:
59119+
description: List of preview results for each rule type matched by the notification rule.
59120+
example:
59121+
- notification_status: DEFAULT
59122+
rule_type: log_detection
59123+
items:
59124+
$ref: "#/components/schemas/NotificationRulePreviewResult"
59125+
type: array
5905459126
NotificationRuleQuery:
5905559127
description: The query is composed of one or several key:value pairs, which can be used to filter security issues on tags and attributes.
5905659128
example: (source:production_service OR env:prod)
@@ -59061,6 +59133,22 @@ components:
5906159133
data:
5906259134
$ref: "#/components/schemas/NotificationRule"
5906359135
type: object
59136+
NotificationRuleRouting:
59137+
description: Routing configuration for the notification rule.
59138+
properties:
59139+
mode:
59140+
$ref: "#/components/schemas/NotificationRuleRoutingMode"
59141+
required:
59142+
- mode
59143+
type: object
59144+
NotificationRuleRoutingMode:
59145+
description: The routing mode for the notification rule. `manual` sends notifications to the configured targets.
59146+
enum:
59147+
- manual
59148+
example: manual
59149+
type: string
59150+
x-enum-varnames:
59151+
- MANUAL
5906459152
NotificationRulesListResponse:
5906559153
description: The list of notification rules.
5906659154
properties:
@@ -68865,6 +68953,8 @@ components:
6886568953
$ref: "#/components/schemas/Enabled"
6886668954
name:
6886768955
$ref: "#/components/schemas/RuleName"
68956+
routing:
68957+
$ref: "#/components/schemas/NotificationRuleRouting"
6886868958
selectors:
6886968959
$ref: "#/components/schemas/Selectors"
6887068960
targets:
@@ -75597,6 +75687,7 @@ components:
7559775687
- iac_misconfiguration
7559875688
- sast_vulnerability
7559975689
- secret_vulnerability
75690+
example: log_detection
7560075691
type: string
7560175692
x-enum-varnames:
7560275693
- APPLICATION_SECURITY
@@ -164667,6 +164758,73 @@ paths:
164667164758
x-unstable: |-
164668164759
**Note**: This endpoint is in preview and is subject to change.
164669164760
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
164761+
/api/v2/security_monitoring/configuration/notification_rules/send_notification_preview:
164762+
post:
164763+
description: Send a notification preview to test that a notification rule's targets are properly configured.
164764+
operationId: SendSecurityMonitoringNotificationPreview
164765+
requestBody:
164766+
content:
164767+
application/json:
164768+
examples:
164769+
default:
164770+
value:
164771+
data:
164772+
attributes:
164773+
enabled: true
164774+
name: Rule 1
164775+
selectors:
164776+
query: env:prod
164777+
rule_types:
164778+
- log_detection
164779+
severities:
164780+
- critical
164781+
trigger_source: security_signals
164782+
targets:
164783+
- "@john.doe@email.com"
164784+
type: notification_rules
164785+
schema:
164786+
$ref: "#/components/schemas/CreateNotificationRuleParameters"
164787+
required: true
164788+
responses:
164789+
"200":
164790+
content:
164791+
application/json:
164792+
examples:
164793+
default:
164794+
value:
164795+
data:
164796+
attributes:
164797+
preview_results:
164798+
- notification_status: DEFAULT
164799+
rule_type: log_detection
164800+
id: rka-loa-zwu
164801+
type: notification_preview_response
164802+
schema:
164803+
$ref: "#/components/schemas/NotificationRulePreviewResponse"
164804+
description: OK
164805+
"400":
164806+
content:
164807+
application/json:
164808+
schema:
164809+
$ref: "#/components/schemas/JSONAPIErrorResponse"
164810+
description: Bad Request
164811+
"403":
164812+
$ref: "#/components/responses/NotAuthorizedResponse"
164813+
"429":
164814+
$ref: "#/components/responses/TooManyRequestsResponse"
164815+
security:
164816+
- apiKeyAuth: []
164817+
appKeyAuth: []
164818+
- AuthZ:
164819+
- security_monitoring_notification_profiles_write
164820+
summary: Test a notification rule
164821+
tags:
164822+
- Security Monitoring
164823+
x-codegen-request-body-name: body
164824+
"x-permission":
164825+
operator: OR
164826+
permissions:
164827+
- security_monitoring_notification_profiles_write
164670164828
/api/v2/security_monitoring/configuration/security_filters:
164671164829
get:
164672164830
description: Get the list of configured security filters with their definitions.

docs/datadog_api_client.v2.model.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24819,13 +24819,69 @@ datadog\_api\_client.v2.model.notification\_rule\_attributes module
2481924819
:members:
2482024820
:show-inheritance:
2482124821

24822+
datadog\_api\_client.v2.model.notification\_rule\_preview\_notification\_status module
24823+
--------------------------------------------------------------------------------------
24824+
24825+
.. automodule:: datadog_api_client.v2.model.notification_rule_preview_notification_status
24826+
:members:
24827+
:show-inheritance:
24828+
24829+
datadog\_api\_client.v2.model.notification\_rule\_preview\_response module
24830+
--------------------------------------------------------------------------
24831+
24832+
.. automodule:: datadog_api_client.v2.model.notification_rule_preview_response
24833+
:members:
24834+
:show-inheritance:
24835+
24836+
datadog\_api\_client.v2.model.notification\_rule\_preview\_response\_attributes module
24837+
--------------------------------------------------------------------------------------
24838+
24839+
.. automodule:: datadog_api_client.v2.model.notification_rule_preview_response_attributes
24840+
:members:
24841+
:show-inheritance:
24842+
24843+
datadog\_api\_client.v2.model.notification\_rule\_preview\_response\_data module
24844+
--------------------------------------------------------------------------------
24845+
24846+
.. automodule:: datadog_api_client.v2.model.notification_rule_preview_response_data
24847+
:members:
24848+
:show-inheritance:
24849+
24850+
datadog\_api\_client.v2.model.notification\_rule\_preview\_response\_type module
24851+
--------------------------------------------------------------------------------
24852+
24853+
.. automodule:: datadog_api_client.v2.model.notification_rule_preview_response_type
24854+
:members:
24855+
:show-inheritance:
24856+
24857+
datadog\_api\_client.v2.model.notification\_rule\_preview\_result module
24858+
------------------------------------------------------------------------
24859+
24860+
.. automodule:: datadog_api_client.v2.model.notification_rule_preview_result
24861+
:members:
24862+
:show-inheritance:
24863+
2482224864
datadog\_api\_client.v2.model.notification\_rule\_response module
2482324865
-----------------------------------------------------------------
2482424866

2482524867
.. automodule:: datadog_api_client.v2.model.notification_rule_response
2482624868
:members:
2482724869
:show-inheritance:
2482824870

24871+
datadog\_api\_client.v2.model.notification\_rule\_routing module
24872+
----------------------------------------------------------------
24873+
24874+
.. automodule:: datadog_api_client.v2.model.notification_rule_routing
24875+
:members:
24876+
:show-inheritance:
24877+
24878+
datadog\_api\_client.v2.model.notification\_rule\_routing\_mode module
24879+
----------------------------------------------------------------------
24880+
24881+
.. automodule:: datadog_api_client.v2.model.notification_rule_routing_mode
24882+
:members:
24883+
:show-inheritance:
24884+
2482924885
datadog\_api\_client.v2.model.notification\_rules\_list\_response module
2483024886
------------------------------------------------------------------------
2483124887

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""
2+
Test a notification rule returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.security_monitoring_api import SecurityMonitoringApi
7+
from datadog_api_client.v2.model.create_notification_rule_parameters import CreateNotificationRuleParameters
8+
from datadog_api_client.v2.model.create_notification_rule_parameters_data import CreateNotificationRuleParametersData
9+
from datadog_api_client.v2.model.create_notification_rule_parameters_data_attributes import (
10+
CreateNotificationRuleParametersDataAttributes,
11+
)
12+
from datadog_api_client.v2.model.notification_rules_type import NotificationRulesType
13+
from datadog_api_client.v2.model.rule_severity import RuleSeverity
14+
from datadog_api_client.v2.model.rule_types_items import RuleTypesItems
15+
from datadog_api_client.v2.model.selectors import Selectors
16+
from datadog_api_client.v2.model.trigger_source import TriggerSource
17+
18+
body = CreateNotificationRuleParameters(
19+
data=CreateNotificationRuleParametersData(
20+
attributes=CreateNotificationRuleParametersDataAttributes(
21+
enabled=True,
22+
name="Rule 1",
23+
selectors=Selectors(
24+
query="env:prod",
25+
rule_types=[
26+
RuleTypesItems.LOG_DETECTION,
27+
],
28+
severities=[
29+
RuleSeverity.CRITICAL,
30+
],
31+
trigger_source=TriggerSource.SECURITY_SIGNALS,
32+
),
33+
targets=[
34+
"@john.doe@email.com",
35+
],
36+
),
37+
type=NotificationRulesType.NOTIFICATION_RULES,
38+
),
39+
)
40+
41+
configuration = Configuration()
42+
with ApiClient(configuration) as api_client:
43+
api_instance = SecurityMonitoringApi(api_client)
44+
response = api_instance.send_security_monitoring_notification_preview(body=body)
45+
46+
print(response)

src/datadog_api_client/v2/api/security_monitoring_api.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
from datadog_api_client.v2.model.security_monitoring_integration_config_update_request import (
104104
SecurityMonitoringIntegrationConfigUpdateRequest,
105105
)
106+
from datadog_api_client.v2.model.notification_rule_preview_response import NotificationRulePreviewResponse
106107
from datadog_api_client.v2.model.security_filters_response import SecurityFiltersResponse
107108
from datadog_api_client.v2.model.security_filter_response import SecurityFilterResponse
108109
from datadog_api_client.v2.model.security_filter_create_request import SecurityFilterCreateRequest
@@ -3548,6 +3549,26 @@ def __init__(self, api_client=None):
35483549
api_client=api_client,
35493550
)
35503551

3552+
self._send_security_monitoring_notification_preview_endpoint = _Endpoint(
3553+
settings={
3554+
"response_type": (NotificationRulePreviewResponse,),
3555+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
3556+
"endpoint_path": "/api/v2/security_monitoring/configuration/notification_rules/send_notification_preview",
3557+
"operation_id": "send_security_monitoring_notification_preview",
3558+
"http_method": "POST",
3559+
"version": "v2",
3560+
},
3561+
params_map={
3562+
"body": {
3563+
"required": True,
3564+
"openapi_types": (CreateNotificationRuleParameters,),
3565+
"location": "body",
3566+
},
3567+
},
3568+
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
3569+
api_client=api_client,
3570+
)
3571+
35513572
self._test_existing_security_monitoring_rule_endpoint = _Endpoint(
35523573
settings={
35533574
"response_type": (SecurityMonitoringRuleTestResponse,),
@@ -7403,6 +7424,22 @@ def search_security_monitoring_signals_with_pagination(
74037424
}
74047425
return endpoint.call_with_http_info_paginated(pagination)
74057426

7427+
def send_security_monitoring_notification_preview(
7428+
self,
7429+
body: CreateNotificationRuleParameters,
7430+
) -> NotificationRulePreviewResponse:
7431+
"""Test a notification rule.
7432+
7433+
Send a notification preview to test that a notification rule's targets are properly configured.
7434+
7435+
:type body: CreateNotificationRuleParameters
7436+
:rtype: NotificationRulePreviewResponse
7437+
"""
7438+
kwargs: Dict[str, Any] = {}
7439+
kwargs["body"] = body
7440+
7441+
return self._send_security_monitoring_notification_preview_endpoint.call_with_http_info(**kwargs)
7442+
74067443
def test_existing_security_monitoring_rule(
74077444
self,
74087445
rule_id: str,

0 commit comments

Comments
 (0)