Skip to content

Commit c208b52

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add tags support to Logs Indexes API (DataDog#3628)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 2db5584 commit c208b52

6 files changed

Lines changed: 105 additions & 7 deletions

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6152,6 +6152,16 @@ components:
61526152
example: 15
61536153
format: int64
61546154
type: integer
6155+
tags:
6156+
description: A list of tags associated with the index. Tags must be in `key:value`
6157+
format.
6158+
example:
6159+
- team:backend
6160+
- env:production
6161+
items:
6162+
description: A single tag using the format `key:value`.
6163+
type: string
6164+
type: array
61556165
required:
61566166
- name
61576167
- filter
@@ -6239,6 +6249,16 @@ components:
62396249
example: 15
62406250
format: int64
62416251
type: integer
6252+
tags:
6253+
description: A list of tags associated with the index. Tags must be in `key:value`
6254+
format.
6255+
example:
6256+
- team:backend
6257+
- env:production
6258+
items:
6259+
description: A single tag using the format `key:value`.
6260+
type: string
6261+
type: array
62426262
required:
62436263
- filter
62446264
type: object

api/datadogV1/model_logs_index.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ type LogsIndex struct {
3737
// The number of days logs are stored in Standard Tier before aging into the Flex Tier or being deleted from the index.
3838
// The available values depend on retention plans specified in your organization's contract/subscriptions.
3939
NumRetentionDays *int64 `json:"num_retention_days,omitempty"`
40+
// A list of tags associated with the index. Tags must be in `key:value` format.
41+
Tags []string `json:"tags,omitempty"`
4042
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
4143
UnparsedObject map[string]interface{} `json:"-"`
4244
AdditionalProperties map[string]interface{} `json:"-"`
@@ -303,6 +305,34 @@ func (o *LogsIndex) SetNumRetentionDays(v int64) {
303305
o.NumRetentionDays = &v
304306
}
305307

308+
// GetTags returns the Tags field value if set, zero value otherwise.
309+
func (o *LogsIndex) GetTags() []string {
310+
if o == nil || o.Tags == nil {
311+
var ret []string
312+
return ret
313+
}
314+
return o.Tags
315+
}
316+
317+
// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
318+
// and a boolean to check if the value has been set.
319+
func (o *LogsIndex) GetTagsOk() (*[]string, bool) {
320+
if o == nil || o.Tags == nil {
321+
return nil, false
322+
}
323+
return &o.Tags, true
324+
}
325+
326+
// HasTags returns a boolean if a field has been set.
327+
func (o *LogsIndex) HasTags() bool {
328+
return o != nil && o.Tags != nil
329+
}
330+
331+
// SetTags gets a reference to the given []string and assigns it to the Tags field.
332+
func (o *LogsIndex) SetTags(v []string) {
333+
o.Tags = v
334+
}
335+
306336
// MarshalJSON serializes the struct using spec logic.
307337
func (o LogsIndex) MarshalJSON() ([]byte, error) {
308338
toSerialize := map[string]interface{}{}
@@ -332,6 +362,9 @@ func (o LogsIndex) MarshalJSON() ([]byte, error) {
332362
if o.NumRetentionDays != nil {
333363
toSerialize["num_retention_days"] = o.NumRetentionDays
334364
}
365+
if o.Tags != nil {
366+
toSerialize["tags"] = o.Tags
367+
}
335368

336369
for key, value := range o.AdditionalProperties {
337370
toSerialize[key] = value
@@ -351,6 +384,7 @@ func (o *LogsIndex) UnmarshalJSON(bytes []byte) (err error) {
351384
Name *string `json:"name"`
352385
NumFlexLogsRetentionDays *int64 `json:"num_flex_logs_retention_days,omitempty"`
353386
NumRetentionDays *int64 `json:"num_retention_days,omitempty"`
387+
Tags []string `json:"tags,omitempty"`
354388
}{}
355389
if err = datadog.Unmarshal(bytes, &all); err != nil {
356390
return datadog.Unmarshal(bytes, &o.UnparsedObject)
@@ -363,7 +397,7 @@ func (o *LogsIndex) UnmarshalJSON(bytes []byte) (err error) {
363397
}
364398
additionalProperties := make(map[string]interface{})
365399
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
366-
datadog.DeleteKeys(additionalProperties, &[]string{"daily_limit", "daily_limit_reset", "daily_limit_warning_threshold_percentage", "exclusion_filters", "filter", "is_rate_limited", "name", "num_flex_logs_retention_days", "num_retention_days"})
400+
datadog.DeleteKeys(additionalProperties, &[]string{"daily_limit", "daily_limit_reset", "daily_limit_warning_threshold_percentage", "exclusion_filters", "filter", "is_rate_limited", "name", "num_flex_logs_retention_days", "num_retention_days", "tags"})
367401
} else {
368402
return err
369403
}
@@ -384,6 +418,7 @@ func (o *LogsIndex) UnmarshalJSON(bytes []byte) (err error) {
384418
o.Name = *all.Name
385419
o.NumFlexLogsRetentionDays = all.NumFlexLogsRetentionDays
386420
o.NumRetentionDays = all.NumRetentionDays
421+
o.Tags = all.Tags
387422

388423
if len(additionalProperties) > 0 {
389424
o.AdditionalProperties = additionalProperties

api/datadogV1/model_logs_index_update_request.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ type LogsIndexUpdateRequest struct {
4040
//
4141
// **Note**: Changing this value affects all logs already in this index. It may also affect billing.
4242
NumRetentionDays *int64 `json:"num_retention_days,omitempty"`
43+
// A list of tags associated with the index. Tags must be in `key:value` format.
44+
Tags []string `json:"tags,omitempty"`
4345
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
4446
UnparsedObject map[string]interface{} `json:"-"`
4547
AdditionalProperties map[string]interface{} `json:"-"`
@@ -282,6 +284,34 @@ func (o *LogsIndexUpdateRequest) SetNumRetentionDays(v int64) {
282284
o.NumRetentionDays = &v
283285
}
284286

287+
// GetTags returns the Tags field value if set, zero value otherwise.
288+
func (o *LogsIndexUpdateRequest) GetTags() []string {
289+
if o == nil || o.Tags == nil {
290+
var ret []string
291+
return ret
292+
}
293+
return o.Tags
294+
}
295+
296+
// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
297+
// and a boolean to check if the value has been set.
298+
func (o *LogsIndexUpdateRequest) GetTagsOk() (*[]string, bool) {
299+
if o == nil || o.Tags == nil {
300+
return nil, false
301+
}
302+
return &o.Tags, true
303+
}
304+
305+
// HasTags returns a boolean if a field has been set.
306+
func (o *LogsIndexUpdateRequest) HasTags() bool {
307+
return o != nil && o.Tags != nil
308+
}
309+
310+
// SetTags gets a reference to the given []string and assigns it to the Tags field.
311+
func (o *LogsIndexUpdateRequest) SetTags(v []string) {
312+
o.Tags = v
313+
}
314+
285315
// MarshalJSON serializes the struct using spec logic.
286316
func (o LogsIndexUpdateRequest) MarshalJSON() ([]byte, error) {
287317
toSerialize := map[string]interface{}{}
@@ -310,6 +340,9 @@ func (o LogsIndexUpdateRequest) MarshalJSON() ([]byte, error) {
310340
if o.NumRetentionDays != nil {
311341
toSerialize["num_retention_days"] = o.NumRetentionDays
312342
}
343+
if o.Tags != nil {
344+
toSerialize["tags"] = o.Tags
345+
}
313346

314347
for key, value := range o.AdditionalProperties {
315348
toSerialize[key] = value
@@ -328,6 +361,7 @@ func (o *LogsIndexUpdateRequest) UnmarshalJSON(bytes []byte) (err error) {
328361
Filter *LogsFilter `json:"filter"`
329362
NumFlexLogsRetentionDays *int64 `json:"num_flex_logs_retention_days,omitempty"`
330363
NumRetentionDays *int64 `json:"num_retention_days,omitempty"`
364+
Tags []string `json:"tags,omitempty"`
331365
}{}
332366
if err = datadog.Unmarshal(bytes, &all); err != nil {
333367
return datadog.Unmarshal(bytes, &o.UnparsedObject)
@@ -337,7 +371,7 @@ func (o *LogsIndexUpdateRequest) UnmarshalJSON(bytes []byte) (err error) {
337371
}
338372
additionalProperties := make(map[string]interface{})
339373
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
340-
datadog.DeleteKeys(additionalProperties, &[]string{"daily_limit", "daily_limit_reset", "daily_limit_warning_threshold_percentage", "disable_daily_limit", "exclusion_filters", "filter", "num_flex_logs_retention_days", "num_retention_days"})
374+
datadog.DeleteKeys(additionalProperties, &[]string{"daily_limit", "daily_limit_reset", "daily_limit_warning_threshold_percentage", "disable_daily_limit", "exclusion_filters", "filter", "num_flex_logs_retention_days", "num_retention_days", "tags"})
341375
} else {
342376
return err
343377
}
@@ -357,6 +391,7 @@ func (o *LogsIndexUpdateRequest) UnmarshalJSON(bytes []byte) (err error) {
357391
o.Filter = *all.Filter
358392
o.NumFlexLogsRetentionDays = all.NumFlexLogsRetentionDays
359393
o.NumRetentionDays = all.NumRetentionDays
394+
o.Tags = all.Tags
360395

361396
if len(additionalProperties) > 0 {
362397
o.AdditionalProperties = additionalProperties

examples/v1/logs-indexes/CreateLogsIndex.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ func main() {
3535
Name: "main",
3636
NumFlexLogsRetentionDays: datadog.PtrInt64(360),
3737
NumRetentionDays: datadog.PtrInt64(15),
38+
Tags: []string{
39+
"team:backend",
40+
"env:production",
41+
},
3842
}
3943
ctx := datadog.NewDefaultContext(context.Background())
4044
configuration := datadog.NewConfiguration()

examples/v1/logs-indexes/UpdateLogsIndex.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ func main() {
3535
},
3636
NumFlexLogsRetentionDays: datadog.PtrInt64(360),
3737
NumRetentionDays: datadog.PtrInt64(15),
38+
Tags: []string{
39+
"team:backend",
40+
"env:production",
41+
},
3842
}
3943
ctx := datadog.NewDefaultContext(context.Background())
4044
configuration := datadog.NewConfiguration()

tests/scenarios/features/v1/logs_indexes.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ Feature: Logs Indexes
1111
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
1212
Scenario: Create an index returns "Invalid Parameter Error" response
1313
Given new "CreateLogsIndex" request
14-
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15}
14+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
1515
When the request is sent
1616
Then the response status is 400 Invalid Parameter Error
1717

1818
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
1919
Scenario: Create an index returns "OK" response
2020
Given new "CreateLogsIndex" request
21-
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15}
21+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
2222
When the request is sent
2323
Then the response status is 200 OK
2424

2525
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
2626
Scenario: Create an index returns "Unprocessable Entity" response
2727
Given new "CreateLogsIndex" request
28-
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15}
28+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
2929
When the request is sent
3030
Then the response status is 422 Unprocessable Entity
3131

@@ -73,15 +73,15 @@ Feature: Logs Indexes
7373
Scenario: Update an index returns "Invalid Parameter Error" response
7474
Given new "UpdateLogsIndex" request
7575
And request contains "name" parameter from "REPLACE.ME"
76-
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15}
76+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
7777
When the request is sent
7878
Then the response status is 400 Invalid Parameter Error
7979

8080
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
8181
Scenario: Update an index returns "OK" response
8282
Given new "UpdateLogsIndex" request
8383
And request contains "name" parameter from "REPLACE.ME"
84-
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15}
84+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
8585
When the request is sent
8686
Then the response status is 200 OK
8787

0 commit comments

Comments
 (0)