Skip to content

Commit d34505c

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add referenceTables field to security monitoring endpoints (#2017)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent e0fb82d commit d34505c

13 files changed

+277
-17
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-09-30 14:37:35.409603",
8-
"spec_repo_commit": "60bc9127"
7+
"regenerated": "2024-09-30 19:44:25.066972",
8+
"spec_repo_commit": "909e369c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-09-30 14:37:35.426476",
13-
"spec_repo_commit": "60bc9127"
12+
"regenerated": "2024-09-30 19:44:25.080968",
13+
"spec_repo_commit": "909e369c"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19089,6 +19089,25 @@ components:
1908919089
meta:
1909019090
$ref: '#/components/schemas/ResponseMetaAttributes'
1909119091
type: object
19092+
SecurityMonitoringReferenceTable:
19093+
description: Reference table for the rule.
19094+
properties:
19095+
checkPresence:
19096+
description: Whether to include or exclude the matched values.
19097+
type: boolean
19098+
columnName:
19099+
description: The name of the column in the reference table.
19100+
type: string
19101+
logFieldPath:
19102+
description: The field in the log to match against the reference table.
19103+
type: string
19104+
ruleQueryName:
19105+
description: The name of the rule query to apply the reference table to.
19106+
type: string
19107+
tableName:
19108+
description: The name of the reference table.
19109+
type: string
19110+
type: object
1909219111
SecurityMonitoringRuleCase:
1909319112
description: Case when signal is generated.
1909419113
properties:
@@ -19594,6 +19613,11 @@ components:
1959419613
items:
1959519614
$ref: '#/components/schemas/SecurityMonitoringRuleQuery'
1959619615
type: array
19616+
referenceTables:
19617+
description: Reference tables for the rule.
19618+
items:
19619+
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
19620+
type: array
1959719621
tags:
1959819622
description: Tags for generated signals.
1959919623
items:
@@ -20298,6 +20322,11 @@ components:
2029820322
items:
2029920323
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
2030020324
type: array
20325+
referenceTables:
20326+
description: Reference tables for the rule.
20327+
items:
20328+
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
20329+
type: array
2030120330
tags:
2030220331
description: Tags for generated signals.
2030320332
example:
@@ -20365,6 +20394,11 @@ components:
2036520394
items:
2036620395
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
2036720396
type: array
20397+
referenceTables:
20398+
description: Reference tables for the rule.
20399+
items:
20400+
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
20401+
type: array
2036820402
tags:
2036920403
description: Tags for generated signals.
2037020404
example:
@@ -20505,6 +20539,11 @@ components:
2050520539
items:
2050620540
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
2050720541
type: array
20542+
referenceTables:
20543+
description: Reference tables for the rule.
20544+
items:
20545+
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
20546+
type: array
2050820547
tags:
2050920548
description: Tags for generated signals.
2051020549
items:
@@ -20569,6 +20608,11 @@ components:
2056920608
items:
2057020609
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
2057120610
type: array
20611+
referenceTables:
20612+
description: Reference tables for the rule.
20613+
items:
20614+
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
20615+
type: array
2057220616
tags:
2057320617
description: Tags for generated signals.
2057420618
example:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-05-10T16:34:28.650Z
1+
2024-09-11T18:14:46.491Z

cassettes/features/v2/security_monitoring/Create-a-detection-rule-returns-OK-response.yml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/v2/security-monitoring/CreateSecurityMonitoringRule.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,14 @@
3232
tags: [],
3333
is_enabled: true,
3434
type: DatadogAPIClient::V2::SecurityMonitoringRuleTypeCreate::LOG_DETECTION,
35+
reference_tables: [
36+
DatadogAPIClient::V2::SecurityMonitoringReferenceTable.new({
37+
table_name: "synthetics_test_reference_table_dont_delete",
38+
column_name: "value",
39+
log_field_path: "testtag",
40+
check_presence: true,
41+
rule_query_name: "a",
42+
}),
43+
],
3544
})
3645
p api_instance.create_security_monitoring_rule(body)

features/v2/security_monitoring.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,13 @@ Feature: Security Monitoring
123123
@skip-validation @team:DataDog/k9-cloud-security-platform
124124
Scenario: Create a detection rule returns "OK" response
125125
Given new "CreateSecurityMonitoringRule" request
126-
And body with value {"name":"{{ unique }}", "queries":[{"query":"@test:true","aggregation":"count","groupByFields":[],"distinctFields":[],"metric":""}],"filters":[],"cases":[{"name":"","status":"info","condition":"a > 0","notifications":[]}],"options":{"evaluationWindow":900,"keepAlive":3600,"maxSignalDuration":86400},"message":"Test rule","tags":[],"isEnabled":true, "type":"log_detection"}
126+
And body with value {"name":"{{ unique }}", "queries":[{"query":"@test:true","aggregation":"count","groupByFields":[],"distinctFields":[],"metric":""}],"filters":[],"cases":[{"name":"","status":"info","condition":"a > 0","notifications":[]}],"options":{"evaluationWindow":900,"keepAlive":3600,"maxSignalDuration":86400},"message":"Test rule","tags":[],"isEnabled":true, "type":"log_detection", "referenceTables":[{"tableName": "synthetics_test_reference_table_dont_delete", "columnName": "value", "logFieldPath":"testtag", "checkPresence":true, "ruleQueryName":"a"}]}
127127
When the request is sent
128128
Then the response status is 200 OK
129129
And the response "name" is equal to "{{ unique }}"
130130
And the response "type" is equal to "log_detection"
131131
And the response "message" is equal to "Test rule"
132+
And the response "referenceTables" is equal to [{"tableName": "synthetics_test_reference_table_dont_delete", "columnName": "value", "logFieldPath":"testtag", "checkPresence":true, "ruleQueryName":"a"}]
132133

133134
@team:DataDog/k9-cloud-security-platform
134135
Scenario: Create a detection rule with detection method 'third_party' returns "OK" response

lib/datadog_api_client/inflector.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,7 @@ def overrides
20792079
"v2.security_monitoring_filter" => "SecurityMonitoringFilter",
20802080
"v2.security_monitoring_filter_action" => "SecurityMonitoringFilterAction",
20812081
"v2.security_monitoring_list_rules_response" => "SecurityMonitoringListRulesResponse",
2082+
"v2.security_monitoring_reference_table" => "SecurityMonitoringReferenceTable",
20822083
"v2.security_monitoring_rule_case" => "SecurityMonitoringRuleCase",
20832084
"v2.security_monitoring_rule_case_create" => "SecurityMonitoringRuleCaseCreate",
20842085
"v2.security_monitoring_rule_convert_payload" => "SecurityMonitoringRuleConvertPayload",
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
=begin
2+
#Datadog API V2 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
Contact: support@datadoghq.com
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V2
20+
# Reference table for the rule.
21+
class SecurityMonitoringReferenceTable
22+
include BaseGenericModel
23+
24+
# Whether to include or exclude the matched values.
25+
attr_accessor :check_presence
26+
27+
# The name of the column in the reference table.
28+
attr_accessor :column_name
29+
30+
# The field in the log to match against the reference table.
31+
attr_accessor :log_field_path
32+
33+
# The name of the rule query to apply the reference table to.
34+
attr_accessor :rule_query_name
35+
36+
# The name of the reference table.
37+
attr_accessor :table_name
38+
39+
attr_accessor :additional_properties
40+
41+
# Attribute mapping from ruby-style variable name to JSON key.
42+
# @!visibility private
43+
def self.attribute_map
44+
{
45+
:'check_presence' => :'checkPresence',
46+
:'column_name' => :'columnName',
47+
:'log_field_path' => :'logFieldPath',
48+
:'rule_query_name' => :'ruleQueryName',
49+
:'table_name' => :'tableName'
50+
}
51+
end
52+
53+
# Attribute type mapping.
54+
# @!visibility private
55+
def self.openapi_types
56+
{
57+
:'check_presence' => :'Boolean',
58+
:'column_name' => :'String',
59+
:'log_field_path' => :'String',
60+
:'rule_query_name' => :'String',
61+
:'table_name' => :'String'
62+
}
63+
end
64+
65+
# Initializes the object
66+
# @param attributes [Hash] Model attributes in the form of hash
67+
# @!visibility private
68+
def initialize(attributes = {})
69+
if (!attributes.is_a?(Hash))
70+
fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::SecurityMonitoringReferenceTable` initialize method"
71+
end
72+
73+
self.additional_properties = {}
74+
# check to see if the attribute exists and convert string to symbol for hash key
75+
attributes = attributes.each_with_object({}) { |(k, v), h|
76+
if (!self.class.attribute_map.key?(k.to_sym))
77+
self.additional_properties[k.to_sym] = v
78+
else
79+
h[k.to_sym] = v
80+
end
81+
}
82+
83+
if attributes.key?(:'check_presence')
84+
self.check_presence = attributes[:'check_presence']
85+
end
86+
87+
if attributes.key?(:'column_name')
88+
self.column_name = attributes[:'column_name']
89+
end
90+
91+
if attributes.key?(:'log_field_path')
92+
self.log_field_path = attributes[:'log_field_path']
93+
end
94+
95+
if attributes.key?(:'rule_query_name')
96+
self.rule_query_name = attributes[:'rule_query_name']
97+
end
98+
99+
if attributes.key?(:'table_name')
100+
self.table_name = attributes[:'table_name']
101+
end
102+
end
103+
104+
# Returns the object in the form of hash, with additionalProperties support.
105+
# @return [Hash] Returns the object in the form of hash
106+
# @!visibility private
107+
def to_hash
108+
hash = {}
109+
self.class.attribute_map.each_pair do |attr, param|
110+
value = self.send(attr)
111+
if value.nil?
112+
is_nullable = self.class.openapi_nullable.include?(attr)
113+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
114+
end
115+
116+
hash[param] = _to_hash(value)
117+
end
118+
self.additional_properties.each_pair do |attr, value|
119+
hash[attr] = value
120+
end
121+
hash
122+
end
123+
124+
# Checks equality by comparing each attribute.
125+
# @param o [Object] Object to be compared
126+
# @!visibility private
127+
def ==(o)
128+
return true if self.equal?(o)
129+
self.class == o.class &&
130+
check_presence == o.check_presence &&
131+
column_name == o.column_name &&
132+
log_field_path == o.log_field_path &&
133+
rule_query_name == o.rule_query_name &&
134+
table_name == o.table_name
135+
additional_properties == o.additional_properties
136+
end
137+
138+
# Calculates hash code according to all attributes.
139+
# @return [Integer] Hash code
140+
# @!visibility private
141+
def hash
142+
[check_presence, column_name, log_field_path, rule_query_name, table_name].hash
143+
end
144+
end
145+
end

lib/datadog_api_client/v2/models/security_monitoring_rule_update_payload.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class SecurityMonitoringRuleUpdatePayload
4848
# Queries for selecting logs which are part of the rule.
4949
attr_accessor :queries
5050

51+
# Reference tables for the rule.
52+
attr_accessor :reference_tables
53+
5154
# Tags for generated signals.
5255
attr_accessor :tags
5356

@@ -72,6 +75,7 @@ def self.attribute_map
7275
:'name' => :'name',
7376
:'options' => :'options',
7477
:'queries' => :'queries',
78+
:'reference_tables' => :'referenceTables',
7579
:'tags' => :'tags',
7680
:'third_party_cases' => :'thirdPartyCases',
7781
:'version' => :'version'
@@ -91,6 +95,7 @@ def self.openapi_types
9195
:'name' => :'String',
9296
:'options' => :'SecurityMonitoringRuleOptions',
9397
:'queries' => :'Array<SecurityMonitoringRuleQuery>',
98+
:'reference_tables' => :'Array<SecurityMonitoringReferenceTable>',
9499
:'tags' => :'Array<String>',
95100
:'third_party_cases' => :'Array<SecurityMonitoringThirdPartyRuleCase>',
96101
:'version' => :'Integer'
@@ -157,6 +162,12 @@ def initialize(attributes = {})
157162
end
158163
end
159164

165+
if attributes.key?(:'reference_tables')
166+
if (value = attributes[:'reference_tables']).is_a?(Array)
167+
self.reference_tables = value
168+
end
169+
end
170+
160171
if attributes.key?(:'tags')
161172
if (value = attributes[:'tags']).is_a?(Array)
162173
self.tags = value
@@ -227,6 +238,7 @@ def ==(o)
227238
name == o.name &&
228239
options == o.options &&
229240
queries == o.queries &&
241+
reference_tables == o.reference_tables &&
230242
tags == o.tags &&
231243
third_party_cases == o.third_party_cases &&
232244
version == o.version
@@ -237,7 +249,7 @@ def ==(o)
237249
# @return [Integer] Hash code
238250
# @!visibility private
239251
def hash
240-
[cases, compliance_signal_options, filters, has_extended_title, is_enabled, message, name, options, queries, tags, third_party_cases, version].hash
252+
[cases, compliance_signal_options, filters, has_extended_title, is_enabled, message, name, options, queries, reference_tables, tags, third_party_cases, version].hash
241253
end
242254
end
243255
end

0 commit comments

Comments
 (0)