Skip to content

Support Cloud SIEM scheduled rules in API client #2725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .generated-info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"spec_repo_commit": "b308db8",
"generated": "2025-08-04 15:40:21.840"
"spec_repo_commit": "18f6524",
"generated": "2025-08-05 08:44:07.096"
}
69 changes: 69 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36257,6 +36257,12 @@ components:
SecurityMonitoringRuleUpdatePayload:
description: Update an existing rule.
properties:
calculatedFields:
description: Calculated fields. Only allowed for scheduled rules - in other
words, when schedulingOptions is also defined.
items:
$ref: '#/components/schemas/CalculatedField'
type: array
cases:
description: Cases for generating signals.
items:
Expand Down Expand Up @@ -36313,6 +36319,8 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
type: array
schedulingOptions:
$ref: '#/components/schemas/SecurityMonitoringSchedulingOptions'
tags:
description: Tags for generated signals.
items:
Expand All @@ -36339,6 +36347,27 @@ components:
- $ref: '#/components/schemas/SecurityMonitoringStandardRulePayload'
- $ref: '#/components/schemas/SecurityMonitoringSignalRulePayload'
- $ref: '#/components/schemas/CloudConfigurationRulePayload'
SecurityMonitoringSchedulingOptions:
description: Options for scheduled rules. When this field is present, the rule
runs based on the schedule. When absent, it runs real-time on ingested logs.
nullable: true
properties:
rrule:
description: Schedule for the rule queries, written in RRULE syntax. See
[RFC](https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html)
for syntax reference.
example: FREQ=HOURLY;INTERVAL=1;
type: string
start:
description: Start date for the schedule, in ISO 8601 format without timezone.
example: '2025-07-14T12:00:00'
type: string
timezone:
description: Time zone of the start date, in the [tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
format.
example: America/New_York
type: string
type: object
SecurityMonitoringSignal:
description: Object description of a security signal.
properties:
Expand Down Expand Up @@ -37017,6 +37046,12 @@ components:
SecurityMonitoringStandardRuleCreatePayload:
description: Create a new rule.
properties:
calculatedFields:
description: Calculated fields. Only allowed for scheduled rules - in other
words, when schedulingOptions is also defined.
items:
$ref: '#/components/schemas/CalculatedField'
type: array
cases:
description: Cases for generating signals.
example: []
Expand Down Expand Up @@ -37069,6 +37104,8 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
type: array
schedulingOptions:
$ref: '#/components/schemas/SecurityMonitoringSchedulingOptions'
tags:
description: Tags for generated signals.
example:
Expand Down Expand Up @@ -37098,6 +37135,12 @@ components:
SecurityMonitoringStandardRulePayload:
description: The payload of a rule.
properties:
calculatedFields:
description: Calculated fields. Only allowed for scheduled rules - in other
words, when schedulingOptions is also defined.
items:
$ref: '#/components/schemas/CalculatedField'
type: array
cases:
description: Cases for generating signals.
example: []
Expand Down Expand Up @@ -37158,6 +37201,8 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
type: array
schedulingOptions:
$ref: '#/components/schemas/SecurityMonitoringSchedulingOptions'
tags:
description: Tags for generated signals.
example:
Expand Down Expand Up @@ -37214,6 +37259,14 @@ components:
example: false
readOnly: true
type: boolean
index:
description: '**This field is currently unstable and might be removed in
a minor version upgrade.**

The index to run the query on, if the `dataSource` is `logs`. Only used
for scheduled rules - in other words, when the `schedulingOptions` field
is present in the rule payload.'
type: string
metric:
deprecated: true
description: '(Deprecated) The target field to aggregate over when using
Expand Down Expand Up @@ -37241,6 +37294,12 @@ components:
SecurityMonitoringStandardRuleResponse:
description: Rule.
properties:
calculatedFields:
description: Calculated fields. Only allowed for scheduled rules - in other
words, when schedulingOptions is also defined.
items:
$ref: '#/components/schemas/CalculatedField'
type: array
cases:
description: Cases for generating signals.
items:
Expand Down Expand Up @@ -37326,6 +37385,8 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
type: array
schedulingOptions:
$ref: '#/components/schemas/SecurityMonitoringSchedulingOptions'
tags:
description: Tags for generated signals.
items:
Expand Down Expand Up @@ -37357,6 +37418,12 @@ components:
SecurityMonitoringStandardRuleTestPayload:
description: The payload of a rule to test
properties:
calculatedFields:
description: Calculated fields. Only allowed for scheduled rules - in other
words, when schedulingOptions is also defined.
items:
$ref: '#/components/schemas/CalculatedField'
type: array
cases:
description: Cases for generating signals.
example: []
Expand Down Expand Up @@ -37409,6 +37476,8 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
type: array
schedulingOptions:
$ref: '#/components/schemas/SecurityMonitoringSchedulingOptions'
tags:
description: Tags for generated signals.
example:
Expand Down
7 changes: 7 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16216,6 +16216,13 @@ datadog\_api\_client.v2.model.security\_monitoring\_rule\_validate\_payload modu
:members:
:show-inheritance:

datadog\_api\_client.v2.model.security\_monitoring\_scheduling\_options module
------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.security_monitoring_scheduling_options
:members:
:show-inheritance:

datadog\_api\_client.v2.model.security\_monitoring\_signal module
-----------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
Create a scheduled detection rule returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.security_monitoring_api import SecurityMonitoringApi
from datadog_api_client.v2.model.security_monitoring_rule_case_create import SecurityMonitoringRuleCaseCreate
from datadog_api_client.v2.model.security_monitoring_rule_evaluation_window import (
SecurityMonitoringRuleEvaluationWindow,
)
from datadog_api_client.v2.model.security_monitoring_rule_keep_alive import SecurityMonitoringRuleKeepAlive
from datadog_api_client.v2.model.security_monitoring_rule_max_signal_duration import (
SecurityMonitoringRuleMaxSignalDuration,
)
from datadog_api_client.v2.model.security_monitoring_rule_options import SecurityMonitoringRuleOptions
from datadog_api_client.v2.model.security_monitoring_rule_query_aggregation import (
SecurityMonitoringRuleQueryAggregation,
)
from datadog_api_client.v2.model.security_monitoring_rule_severity import SecurityMonitoringRuleSeverity
from datadog_api_client.v2.model.security_monitoring_rule_type_create import SecurityMonitoringRuleTypeCreate
from datadog_api_client.v2.model.security_monitoring_scheduling_options import SecurityMonitoringSchedulingOptions
from datadog_api_client.v2.model.security_monitoring_standard_rule_create_payload import (
SecurityMonitoringStandardRuleCreatePayload,
)
from datadog_api_client.v2.model.security_monitoring_standard_rule_query import SecurityMonitoringStandardRuleQuery

body = SecurityMonitoringStandardRuleCreatePayload(
name="Example-Security-Monitoring",
queries=[
SecurityMonitoringStandardRuleQuery(
query="@test:true",
aggregation=SecurityMonitoringRuleQueryAggregation.COUNT,
group_by_fields=[],
distinct_fields=[],
index="main",
),
],
filters=[],
cases=[
SecurityMonitoringRuleCaseCreate(
name="",
status=SecurityMonitoringRuleSeverity.INFO,
condition="a > 0",
notifications=[],
),
],
options=SecurityMonitoringRuleOptions(
evaluation_window=SecurityMonitoringRuleEvaluationWindow.FIFTEEN_MINUTES,
keep_alive=SecurityMonitoringRuleKeepAlive.ONE_HOUR,
max_signal_duration=SecurityMonitoringRuleMaxSignalDuration.ONE_DAY,
),
message="Test rule",
tags=[],
is_enabled=True,
type=SecurityMonitoringRuleTypeCreate.LOG_DETECTION,
scheduling_options=SecurityMonitoringSchedulingOptions(
rrule="FREQ=HOURLY;INTERVAL=2;",
start="2025-06-18T12:00:00",
timezone="Europe/Paris",
),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = SecurityMonitoringApi(api_client)
response = api_instance.create_security_monitoring_rule(body=body)

print(response)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, **kwargs):
"""
Convert a rule from JSON to Terraform.

:param calculated_fields: Calculated fields. Only allowed for scheduled rules - in other words, when schedulingOptions is also defined.
:type calculated_fields: [CalculatedField], optional

:param cases: Cases for generating signals.
:type cases: [SecurityMonitoringRuleCaseCreate]

Expand Down Expand Up @@ -51,6 +54,9 @@ def __init__(self, **kwargs):
:param reference_tables: Reference tables for the rule.
:type reference_tables: [SecurityMonitoringReferenceTable], optional

:param scheduling_options: Options for scheduled rules. When this field is present, the rule runs based on the schedule. When absent, it runs real-time on ingested logs.
:type scheduling_options: SecurityMonitoringSchedulingOptions, none_type, optional

:param tags: Tags for generated signals.
:type tags: [str], optional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, **kwargs):
"""
Create a new rule.

:param calculated_fields: Calculated fields. Only allowed for scheduled rules - in other words, when schedulingOptions is also defined.
:type calculated_fields: [CalculatedField], optional

:param cases: Cases for generating signals.
:type cases: [SecurityMonitoringRuleCaseCreate]

Expand Down Expand Up @@ -45,6 +48,9 @@ def __init__(self, **kwargs):
:param reference_tables: Reference tables for the rule.
:type reference_tables: [SecurityMonitoringReferenceTable], optional

:param scheduling_options: Options for scheduled rules. When this field is present, the rule runs based on the schedule. When absent, it runs real-time on ingested logs.
:type scheduling_options: SecurityMonitoringSchedulingOptions, none_type, optional

:param tags: Tags for generated signals.
:type tags: [str], optional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def __init__(self, **kwargs):
:param has_optional_group_by_fields: When false, events without a group-by value are ignored by the rule. When true, events with missing group-by fields are processed with `N/A`, replacing the missing values.
:type has_optional_group_by_fields: bool, optional

:param index: **This field is currently unstable and might be removed in a minor version upgrade.**
The index to run the query on, if the `dataSource` is `logs`. Only used for scheduled rules - in other words, when the `schedulingOptions` field is present in the rule payload.
:type index: str, optional

:param metric: (Deprecated) The target field to aggregate over when using the sum or max
aggregations. `metrics` field should be used instead.
:type metric: str, optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, **kwargs):
"""
Create a new rule.

:param calculated_fields: Calculated fields. Only allowed for scheduled rules - in other words, when schedulingOptions is also defined.
:type calculated_fields: [CalculatedField], optional

:param cases: Cases for generating signals.
:type cases: [SecurityMonitoringRuleCase], optional

Expand Down Expand Up @@ -75,6 +78,9 @@ def __init__(self, **kwargs):
:param reference_tables: Reference tables for the rule.
:type reference_tables: [SecurityMonitoringReferenceTable], optional

:param scheduling_options: Options for scheduled rules. When this field is present, the rule runs based on the schedule. When absent, it runs real-time on ingested logs.
:type scheduling_options: SecurityMonitoringSchedulingOptions, none_type, optional

:param tags: Tags for generated signals.
:type tags: [str], optional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, **kwargs):
"""
Test a rule.

:param calculated_fields: Calculated fields. Only allowed for scheduled rules - in other words, when schedulingOptions is also defined.
:type calculated_fields: [CalculatedField], optional

:param cases: Cases for generating signals.
:type cases: [SecurityMonitoringRuleCaseCreate]

Expand Down Expand Up @@ -45,6 +48,9 @@ def __init__(self, **kwargs):
:param reference_tables: Reference tables for the rule.
:type reference_tables: [SecurityMonitoringReferenceTable], optional

:param scheduling_options: Options for scheduled rules. When this field is present, the rule runs based on the schedule. When absent, it runs real-time on ingested logs.
:type scheduling_options: SecurityMonitoringSchedulingOptions, none_type, optional

:param tags: Tags for generated signals.
:type tags: [str], optional

Expand Down
Loading
Loading