Skip to content

Commit d10ff66

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Allow the usage of the filters field when creating an agent rule (#1967)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 8f900bb commit d10ff66

File tree

7 files changed

+28
-12
lines changed

7 files changed

+28
-12
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2024-05-22 20:06:44.952433",
8-
"spec_repo_commit": "94c7d978"
7+
"regenerated": "2024-05-23 11:28:45.445301",
8+
"spec_repo_commit": "b829bfa2"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-05-22 20:06:44.973295",
13-
"spec_repo_commit": "94c7d978"
12+
"regenerated": "2024-05-23 11:28:45.464180",
13+
"spec_repo_commit": "b829bfa2"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,6 +4105,11 @@ components:
41054105
description: The SECL expression of the Agent rule.
41064106
example: exec.file.name == \"sh\"
41074107
type: string
4108+
filters:
4109+
description: The platforms the Agent rule is supported on.
4110+
items:
4111+
type: string
4112+
type: array
41084113
name:
41094114
description: The name of the Agent rule.
41104115
example: my_agent_rule

examples/v2/csm-threats/CreateCSMThreatsAgentRule.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
description="My Agent rule",
2222
enabled=True,
2323
expression='exec.file.name == "sh"',
24+
filters=[
25+
'os == "linux"',
26+
],
2427
name="examplecsmthreat",
2528
),
2629
type=CloudWorkloadSecurityAgentRuleType.AGENT_RULE,

src/datadog_api_client/v2/model/cloud_workload_security_agent_rule_create_attributes.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6-
from typing import Union
6+
from typing import List, Union
77

88
from datadog_api_client.model_utils import (
99
ModelNormal,
@@ -20,13 +20,15 @@ def openapi_types(_):
2020
"description": (str,),
2121
"enabled": (bool,),
2222
"expression": (str,),
23+
"filters": ([str],),
2324
"name": (str,),
2425
}
2526

2627
attribute_map = {
2728
"description": "description",
2829
"enabled": "enabled",
2930
"expression": "expression",
31+
"filters": "filters",
3032
"name": "name",
3133
}
3234

@@ -36,6 +38,7 @@ def __init__(
3638
name: str,
3739
description: Union[str, UnsetType] = unset,
3840
enabled: Union[bool, UnsetType] = unset,
41+
filters: Union[List[str], UnsetType] = unset,
3942
**kwargs,
4043
):
4144
"""
@@ -50,13 +53,18 @@ def __init__(
5053
:param expression: The SECL expression of the Agent rule.
5154
:type expression: str
5255
56+
:param filters: The platforms the Agent rule is supported on.
57+
:type filters: [str], optional
58+
5359
:param name: The name of the Agent rule.
5460
:type name: str
5561
"""
5662
if description is not unset:
5763
kwargs["description"] = description
5864
if enabled is not unset:
5965
kwargs["enabled"] = enabled
66+
if filters is not unset:
67+
kwargs["filters"] = filters
6068
super().__init__(kwargs)
6169

6270
self_.expression = expression
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-04-23T17:57:44.371Z
1+
2024-05-22T16:22:22.200Z

tests/v2/cassettes/test_scenarios/test_create_a_csm_threats_agent_rule_returns_ok_response.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
interactions:
22
- request:
33
body: '{"data":{"attributes":{"description":"My Agent rule","enabled":true,"expression":"exec.file.name
4-
== \"sh\"","name":"testcreateacsmthreatsagentrulereturnsokresponse1713895064"},"type":"agent_rule"}}'
4+
== \"sh\"","filters":["os == \"linux\""],"name":"testcreateacsmthreatsagentrulereturnsokresponse1716394942"},"type":"agent_rule"}}'
55
headers:
66
accept:
77
- application/json
@@ -11,10 +11,10 @@ interactions:
1111
uri: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules
1212
response:
1313
body:
14-
string: '{"data":{"id":"922-a60-32v","type":"agent_rule","attributes":{"category":"Process
15-
Activity","creationDate":1713895064438,"creator":{"name":"","handle":"[email protected]"},"defaultRule":false,"description":"My
14+
string: '{"data":{"id":"pn4-mo8-u5r","type":"agent_rule","attributes":{"category":"Process
15+
Activity","creationDate":1716394942614,"creator":{"name":"","handle":"[email protected]"},"defaultRule":false,"description":"My
1616
Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","filters":["os
17-
== \"linux\""],"name":"testcreateacsmthreatsagentrulereturnsokresponse1713895064","updateDate":1713895064438,"updater":{"name":"","handle":"[email protected]"}}}}'
17+
== \"linux\""],"name":"testcreateacsmthreatsagentrulereturnsokresponse1716394942","updateDate":1716394942614,"updater":{"name":"","handle":"[email protected]"}}}}'
1818
headers:
1919
content-type:
2020
- application/json
@@ -27,7 +27,7 @@ interactions:
2727
accept:
2828
- '*/*'
2929
method: DELETE
30-
uri: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/922-a60-32v
30+
uri: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/pn4-mo8-u5r
3131
response:
3232
body:
3333
string: ''

tests/v2/features/csm_threats.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Feature: CSM Threats
2828
@team:DataDog/k9-cloud-security-platform @team:DataDog/k9-cws-backend
2929
Scenario: Create a CSM Threats Agent rule returns "OK" response
3030
Given new "CreateCSMThreatsAgentRule" request
31-
And body with value {"data": {"attributes": {"description": "My Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\"", "name": "{{ unique_lower_alnum }}"}, "type": "agent_rule"}}
31+
And body with value {"data": {"attributes": {"description": "My Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\"", "filters": ["os == \"linux\""], "name": "{{ unique_lower_alnum }}"}, "type": "agent_rule"}}
3232
When the request is sent
3333
Then the response status is 200 OK
3434

0 commit comments

Comments
 (0)