Skip to content

Commit 763d17f

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
[SEC-19484] Add datasource to rule model (#2972)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 890fd46 commit 763d17f

4 files changed

Lines changed: 127 additions & 5 deletions

File tree

.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": "2025-03-11 16:30:30.102793",
8-
"spec_repo_commit": "baf04a80"
7+
"regenerated": "2025-03-13 09:11:30.011128",
8+
"spec_repo_commit": "a1fc1148"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-03-11 16:30:30.118458",
13-
"spec_repo_commit": "baf04a80"
12+
"regenerated": "2025-03-13 09:11:30.026653",
13+
"spec_repo_commit": "a1fc1148"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27642,6 +27642,17 @@ components:
2764227642
x-enum-varnames:
2764327643
- TIMESTAMP_ASCENDING
2764427644
- TIMESTAMP_DESCENDING
27645+
SecurityMonitoringStandardDataSource:
27646+
default: logs
27647+
description: Source of events, either logs or audit trail.
27648+
enum:
27649+
- logs
27650+
- audit
27651+
example: logs
27652+
type: string
27653+
x-enum-varnames:
27654+
- LOGS
27655+
- AUDIT
2764527656
SecurityMonitoringStandardRuleCreatePayload:
2764627657
description: Create a new rule.
2764727658
properties:
@@ -27809,6 +27820,8 @@ components:
2780927820
properties:
2781027821
aggregation:
2781127822
$ref: '#/components/schemas/SecurityMonitoringRuleQueryAggregation'
27823+
dataSource:
27824+
$ref: '#/components/schemas/SecurityMonitoringStandardDataSource'
2781227825
distinctFields:
2781327826
description: Field for which the cardinality is measured. Sent as an array.
2781427827
items:
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// SecurityMonitoringStandardDataSource Source of events, either logs or audit trail.
14+
type SecurityMonitoringStandardDataSource string
15+
16+
// List of SecurityMonitoringStandardDataSource.
17+
const (
18+
SECURITYMONITORINGSTANDARDDATASOURCE_LOGS SecurityMonitoringStandardDataSource = "logs"
19+
SECURITYMONITORINGSTANDARDDATASOURCE_AUDIT SecurityMonitoringStandardDataSource = "audit"
20+
)
21+
22+
var allowedSecurityMonitoringStandardDataSourceEnumValues = []SecurityMonitoringStandardDataSource{
23+
SECURITYMONITORINGSTANDARDDATASOURCE_LOGS,
24+
SECURITYMONITORINGSTANDARDDATASOURCE_AUDIT,
25+
}
26+
27+
// GetAllowedValues reeturns the list of possible values.
28+
func (v *SecurityMonitoringStandardDataSource) GetAllowedValues() []SecurityMonitoringStandardDataSource {
29+
return allowedSecurityMonitoringStandardDataSourceEnumValues
30+
}
31+
32+
// UnmarshalJSON deserializes the given payload.
33+
func (v *SecurityMonitoringStandardDataSource) UnmarshalJSON(src []byte) error {
34+
var value string
35+
err := datadog.Unmarshal(src, &value)
36+
if err != nil {
37+
return err
38+
}
39+
*v = SecurityMonitoringStandardDataSource(value)
40+
return nil
41+
}
42+
43+
// NewSecurityMonitoringStandardDataSourceFromValue returns a pointer to a valid SecurityMonitoringStandardDataSource
44+
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
45+
func NewSecurityMonitoringStandardDataSourceFromValue(v string) (*SecurityMonitoringStandardDataSource, error) {
46+
ev := SecurityMonitoringStandardDataSource(v)
47+
if ev.IsValid() {
48+
return &ev, nil
49+
}
50+
return nil, fmt.Errorf("invalid value '%v' for SecurityMonitoringStandardDataSource: valid values are %v", v, allowedSecurityMonitoringStandardDataSourceEnumValues)
51+
}
52+
53+
// IsValid return true if the value is valid for the enum, false otherwise.
54+
func (v SecurityMonitoringStandardDataSource) IsValid() bool {
55+
for _, existing := range allowedSecurityMonitoringStandardDataSourceEnumValues {
56+
if existing == v {
57+
return true
58+
}
59+
}
60+
return false
61+
}
62+
63+
// Ptr returns reference to SecurityMonitoringStandardDataSource value.
64+
func (v SecurityMonitoringStandardDataSource) Ptr() *SecurityMonitoringStandardDataSource {
65+
return &v
66+
}

api/datadogV2/model_security_monitoring_standard_rule_query.go

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
type SecurityMonitoringStandardRuleQuery struct {
1313
// The aggregation type.
1414
Aggregation *SecurityMonitoringRuleQueryAggregation `json:"aggregation,omitempty"`
15+
// Source of events, either logs or audit trail.
16+
DataSource *SecurityMonitoringStandardDataSource `json:"dataSource,omitempty"`
1517
// Field for which the cardinality is measured. Sent as an array.
1618
DistinctFields []string `json:"distinctFields,omitempty"`
1719
// Fields to group by.
@@ -39,6 +41,8 @@ type SecurityMonitoringStandardRuleQuery struct {
3941
// will change when the set of required properties is changed.
4042
func NewSecurityMonitoringStandardRuleQuery() *SecurityMonitoringStandardRuleQuery {
4143
this := SecurityMonitoringStandardRuleQuery{}
44+
var dataSource SecurityMonitoringStandardDataSource = SECURITYMONITORINGSTANDARDDATASOURCE_LOGS
45+
this.DataSource = &dataSource
4246
return &this
4347
}
4448

@@ -47,6 +51,8 @@ func NewSecurityMonitoringStandardRuleQuery() *SecurityMonitoringStandardRuleQue
4751
// but it doesn't guarantee that properties required by API are set.
4852
func NewSecurityMonitoringStandardRuleQueryWithDefaults() *SecurityMonitoringStandardRuleQuery {
4953
this := SecurityMonitoringStandardRuleQuery{}
54+
var dataSource SecurityMonitoringStandardDataSource = SECURITYMONITORINGSTANDARDDATASOURCE_LOGS
55+
this.DataSource = &dataSource
5056
return &this
5157
}
5258

@@ -78,6 +84,34 @@ func (o *SecurityMonitoringStandardRuleQuery) SetAggregation(v SecurityMonitorin
7884
o.Aggregation = &v
7985
}
8086

87+
// GetDataSource returns the DataSource field value if set, zero value otherwise.
88+
func (o *SecurityMonitoringStandardRuleQuery) GetDataSource() SecurityMonitoringStandardDataSource {
89+
if o == nil || o.DataSource == nil {
90+
var ret SecurityMonitoringStandardDataSource
91+
return ret
92+
}
93+
return *o.DataSource
94+
}
95+
96+
// GetDataSourceOk returns a tuple with the DataSource field value if set, nil otherwise
97+
// and a boolean to check if the value has been set.
98+
func (o *SecurityMonitoringStandardRuleQuery) GetDataSourceOk() (*SecurityMonitoringStandardDataSource, bool) {
99+
if o == nil || o.DataSource == nil {
100+
return nil, false
101+
}
102+
return o.DataSource, true
103+
}
104+
105+
// HasDataSource returns a boolean if a field has been set.
106+
func (o *SecurityMonitoringStandardRuleQuery) HasDataSource() bool {
107+
return o != nil && o.DataSource != nil
108+
}
109+
110+
// SetDataSource gets a reference to the given SecurityMonitoringStandardDataSource and assigns it to the DataSource field.
111+
func (o *SecurityMonitoringStandardRuleQuery) SetDataSource(v SecurityMonitoringStandardDataSource) {
112+
o.DataSource = &v
113+
}
114+
81115
// GetDistinctFields returns the DistinctFields field value if set, zero value otherwise.
82116
func (o *SecurityMonitoringStandardRuleQuery) GetDistinctFields() []string {
83117
if o == nil || o.DistinctFields == nil {
@@ -286,6 +320,9 @@ func (o SecurityMonitoringStandardRuleQuery) MarshalJSON() ([]byte, error) {
286320
if o.Aggregation != nil {
287321
toSerialize["aggregation"] = o.Aggregation
288322
}
323+
if o.DataSource != nil {
324+
toSerialize["dataSource"] = o.DataSource
325+
}
289326
if o.DistinctFields != nil {
290327
toSerialize["distinctFields"] = o.DistinctFields
291328
}
@@ -318,6 +355,7 @@ func (o SecurityMonitoringStandardRuleQuery) MarshalJSON() ([]byte, error) {
318355
func (o *SecurityMonitoringStandardRuleQuery) UnmarshalJSON(bytes []byte) (err error) {
319356
all := struct {
320357
Aggregation *SecurityMonitoringRuleQueryAggregation `json:"aggregation,omitempty"`
358+
DataSource *SecurityMonitoringStandardDataSource `json:"dataSource,omitempty"`
321359
DistinctFields []string `json:"distinctFields,omitempty"`
322360
GroupByFields []string `json:"groupByFields,omitempty"`
323361
HasOptionalGroupByFields *bool `json:"hasOptionalGroupByFields,omitempty"`
@@ -331,7 +369,7 @@ func (o *SecurityMonitoringStandardRuleQuery) UnmarshalJSON(bytes []byte) (err e
331369
}
332370
additionalProperties := make(map[string]interface{})
333371
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
334-
datadog.DeleteKeys(additionalProperties, &[]string{"aggregation", "distinctFields", "groupByFields", "hasOptionalGroupByFields", "metric", "metrics", "name", "query"})
372+
datadog.DeleteKeys(additionalProperties, &[]string{"aggregation", "dataSource", "distinctFields", "groupByFields", "hasOptionalGroupByFields", "metric", "metrics", "name", "query"})
335373
} else {
336374
return err
337375
}
@@ -342,6 +380,11 @@ func (o *SecurityMonitoringStandardRuleQuery) UnmarshalJSON(bytes []byte) (err e
342380
} else {
343381
o.Aggregation = all.Aggregation
344382
}
383+
if all.DataSource != nil && !all.DataSource.IsValid() {
384+
hasInvalidField = true
385+
} else {
386+
o.DataSource = all.DataSource
387+
}
345388
o.DistinctFields = all.DistinctFields
346389
o.GroupByFields = all.GroupByFields
347390
o.HasOptionalGroupByFields = all.HasOptionalGroupByFields

0 commit comments

Comments
 (0)