Skip to content

Commit 76e4ce0

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add tags and description fields to the logs nested pipeline type LogsPipelineProcessor (#3850)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 9931af0 commit 76e4ce0

6 files changed

Lines changed: 193 additions & 6 deletions

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6236,6 +6236,9 @@ components:
62366236

62376237
A pipeline can contain Nested Pipelines and Processors whereas a Nested Pipeline can only contain Processors.
62386238
properties:
6239+
description:
6240+
description: A description of the pipeline.
6241+
type: string
62396242
filter:
62406243
$ref: "#/components/schemas/LogsFilter"
62416244
is_enabled:
@@ -6250,6 +6253,12 @@ components:
62506253
items:
62516254
$ref: "#/components/schemas/LogsProcessor"
62526255
type: array
6256+
tags:
6257+
description: A list of tags associated with the pipeline.
6258+
items:
6259+
description: A single tag using the format `key:value`.
6260+
type: string
6261+
type: array
62536262
type:
62546263
$ref: "#/components/schemas/LogsPipelineProcessorType"
62556264
required:

api/datadogV1/model_logs_pipeline_processor.go

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
//
1717
// A pipeline can contain Nested Pipelines and Processors whereas a Nested Pipeline can only contain Processors.
1818
type LogsPipelineProcessor struct {
19+
// A description of the pipeline.
20+
Description *string `json:"description,omitempty"`
1921
// Filter for logs.
2022
Filter *LogsFilter `json:"filter,omitempty"`
2123
// Whether or not the processor is enabled.
@@ -24,6 +26,8 @@ type LogsPipelineProcessor struct {
2426
Name *string `json:"name,omitempty"`
2527
// Ordered list of processors in this pipeline.
2628
Processors []LogsProcessor `json:"processors,omitempty"`
29+
// A list of tags associated with the pipeline.
30+
Tags []string `json:"tags,omitempty"`
2731
// Type of logs pipeline processor.
2832
Type LogsPipelineProcessorType `json:"type"`
2933
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
@@ -55,6 +59,34 @@ func NewLogsPipelineProcessorWithDefaults() *LogsPipelineProcessor {
5559
return &this
5660
}
5761

62+
// GetDescription returns the Description field value if set, zero value otherwise.
63+
func (o *LogsPipelineProcessor) GetDescription() string {
64+
if o == nil || o.Description == nil {
65+
var ret string
66+
return ret
67+
}
68+
return *o.Description
69+
}
70+
71+
// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
72+
// and a boolean to check if the value has been set.
73+
func (o *LogsPipelineProcessor) GetDescriptionOk() (*string, bool) {
74+
if o == nil || o.Description == nil {
75+
return nil, false
76+
}
77+
return o.Description, true
78+
}
79+
80+
// HasDescription returns a boolean if a field has been set.
81+
func (o *LogsPipelineProcessor) HasDescription() bool {
82+
return o != nil && o.Description != nil
83+
}
84+
85+
// SetDescription gets a reference to the given string and assigns it to the Description field.
86+
func (o *LogsPipelineProcessor) SetDescription(v string) {
87+
o.Description = &v
88+
}
89+
5890
// GetFilter returns the Filter field value if set, zero value otherwise.
5991
func (o *LogsPipelineProcessor) GetFilter() LogsFilter {
6092
if o == nil || o.Filter == nil {
@@ -167,6 +199,34 @@ func (o *LogsPipelineProcessor) SetProcessors(v []LogsProcessor) {
167199
o.Processors = v
168200
}
169201

202+
// GetTags returns the Tags field value if set, zero value otherwise.
203+
func (o *LogsPipelineProcessor) GetTags() []string {
204+
if o == nil || o.Tags == nil {
205+
var ret []string
206+
return ret
207+
}
208+
return o.Tags
209+
}
210+
211+
// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
212+
// and a boolean to check if the value has been set.
213+
func (o *LogsPipelineProcessor) GetTagsOk() (*[]string, bool) {
214+
if o == nil || o.Tags == nil {
215+
return nil, false
216+
}
217+
return &o.Tags, true
218+
}
219+
220+
// HasTags returns a boolean if a field has been set.
221+
func (o *LogsPipelineProcessor) HasTags() bool {
222+
return o != nil && o.Tags != nil
223+
}
224+
225+
// SetTags gets a reference to the given []string and assigns it to the Tags field.
226+
func (o *LogsPipelineProcessor) SetTags(v []string) {
227+
o.Tags = v
228+
}
229+
170230
// GetType returns the Type field value.
171231
func (o *LogsPipelineProcessor) GetType() LogsPipelineProcessorType {
172232
if o == nil {
@@ -196,6 +256,9 @@ func (o LogsPipelineProcessor) MarshalJSON() ([]byte, error) {
196256
if o.UnparsedObject != nil {
197257
return datadog.Marshal(o.UnparsedObject)
198258
}
259+
if o.Description != nil {
260+
toSerialize["description"] = o.Description
261+
}
199262
if o.Filter != nil {
200263
toSerialize["filter"] = o.Filter
201264
}
@@ -208,6 +271,9 @@ func (o LogsPipelineProcessor) MarshalJSON() ([]byte, error) {
208271
if o.Processors != nil {
209272
toSerialize["processors"] = o.Processors
210273
}
274+
if o.Tags != nil {
275+
toSerialize["tags"] = o.Tags
276+
}
211277
toSerialize["type"] = o.Type
212278

213279
for key, value := range o.AdditionalProperties {
@@ -219,11 +285,13 @@ func (o LogsPipelineProcessor) MarshalJSON() ([]byte, error) {
219285
// UnmarshalJSON deserializes the given payload.
220286
func (o *LogsPipelineProcessor) UnmarshalJSON(bytes []byte) (err error) {
221287
all := struct {
222-
Filter *LogsFilter `json:"filter,omitempty"`
223-
IsEnabled *bool `json:"is_enabled,omitempty"`
224-
Name *string `json:"name,omitempty"`
225-
Processors []LogsProcessor `json:"processors,omitempty"`
226-
Type *LogsPipelineProcessorType `json:"type"`
288+
Description *string `json:"description,omitempty"`
289+
Filter *LogsFilter `json:"filter,omitempty"`
290+
IsEnabled *bool `json:"is_enabled,omitempty"`
291+
Name *string `json:"name,omitempty"`
292+
Processors []LogsProcessor `json:"processors,omitempty"`
293+
Tags []string `json:"tags,omitempty"`
294+
Type *LogsPipelineProcessorType `json:"type"`
227295
}{}
228296
if err = datadog.Unmarshal(bytes, &all); err != nil {
229297
return datadog.Unmarshal(bytes, &o.UnparsedObject)
@@ -233,19 +301,21 @@ func (o *LogsPipelineProcessor) UnmarshalJSON(bytes []byte) (err error) {
233301
}
234302
additionalProperties := make(map[string]interface{})
235303
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
236-
datadog.DeleteKeys(additionalProperties, &[]string{"filter", "is_enabled", "name", "processors", "type"})
304+
datadog.DeleteKeys(additionalProperties, &[]string{"description", "filter", "is_enabled", "name", "processors", "tags", "type"})
237305
} else {
238306
return err
239307
}
240308

241309
hasInvalidField := false
310+
o.Description = all.Description
242311
if all.Filter != nil && all.Filter.UnparsedObject != nil && o.UnparsedObject == nil {
243312
hasInvalidField = true
244313
}
245314
o.Filter = all.Filter
246315
o.IsEnabled = all.IsEnabled
247316
o.Name = all.Name
248317
o.Processors = all.Processors
318+
o.Tags = all.Tags
249319
if !all.Type.IsValid() {
250320
hasInvalidField = true
251321
} else {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Create a pipeline with nested pipeline processor returns "OK" response
2+
3+
package main
4+
5+
import (
6+
"context"
7+
"encoding/json"
8+
"fmt"
9+
"os"
10+
11+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
12+
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
13+
)
14+
15+
func main() {
16+
body := datadogV1.LogsPipeline{
17+
Filter: &datadogV1.LogsFilter{
18+
Query: datadog.PtrString("source:python"),
19+
},
20+
Name: "testPipelineWithNested",
21+
Processors: []datadogV1.LogsProcessor{
22+
datadogV1.LogsProcessor{
23+
LogsPipelineProcessor: &datadogV1.LogsPipelineProcessor{
24+
Type: datadogV1.LOGSPIPELINEPROCESSORTYPE_PIPELINE,
25+
IsEnabled: datadog.PtrBool(true),
26+
Name: datadog.PtrString("nested_pipeline_with_metadata"),
27+
Filter: &datadogV1.LogsFilter{
28+
Query: datadog.PtrString("env:production"),
29+
},
30+
Tags: []string{
31+
"env:prod",
32+
"type:nested",
33+
},
34+
Description: datadog.PtrString("This is a nested pipeline for production logs"),
35+
}},
36+
},
37+
Tags: []string{
38+
"team:test",
39+
},
40+
Description: datadog.PtrString("Pipeline containing nested processor with tags and description"),
41+
}
42+
ctx := datadog.NewDefaultContext(context.Background())
43+
configuration := datadog.NewConfiguration()
44+
apiClient := datadog.NewAPIClient(configuration)
45+
api := datadogV1.NewLogsPipelinesApi(apiClient)
46+
resp, r, err := api.CreateLogsPipeline(ctx, body)
47+
48+
if err != nil {
49+
fmt.Fprintf(os.Stderr, "Error when calling `LogsPipelinesApi.CreateLogsPipeline`: %v\n", err)
50+
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
51+
}
52+
53+
responseContent, _ := json.MarshalIndent(resp, "", " ")
54+
fmt.Fprintf(os.Stdout, "Response from `LogsPipelinesApi.CreateLogsPipeline`:\n%s\n", responseContent)
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-03-18T17:10:40.108Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
interactions:
2+
- request:
3+
body: |
4+
{"description":"Pipeline containing nested processor with tags and description","filter":{"query":"source:python"},"name":"testPipelineWithNested","processors":[{"description":"This is a nested pipeline for production logs","filter":{"query":"env:production"},"is_enabled":true,"name":"nested_pipeline_with_metadata","tags":["env:prod","type:nested"],"type":"pipeline"}],"tags":["team:test"]}
5+
form: {}
6+
headers:
7+
Accept:
8+
- application/json
9+
Content-Type:
10+
- application/json
11+
id: 0
12+
method: POST
13+
url: https://api.datadoghq.com/api/v1/logs/config/pipelines
14+
response:
15+
body: '{"id":"GyYNpCrVQtOB3KhqJSpOOA","type":"pipeline","name":"testPipelineWithNested","is_enabled":false,"is_read_only":false,"filter":{"query":"source:python"},"processors":[{"type":"pipeline","name":"nested_pipeline_with_metadata","is_enabled":true,"filter":{"query":"env:production"},"processors":[],"tags":["env:prod","type:nested"],"description":"This
16+
is a nested pipeline for production logs"}],"tags":["team:test"],"description":"Pipeline
17+
containing nested processor with tags and description"}
18+
19+
'
20+
code: 200
21+
duration: 0ms
22+
headers:
23+
Content-Type:
24+
- application/json
25+
status: 200 OK
26+
- request:
27+
body: ''
28+
form: {}
29+
headers:
30+
Accept:
31+
- '*/*'
32+
id: 1
33+
method: DELETE
34+
url: https://api.datadoghq.com/api/v1/logs/config/pipelines/GyYNpCrVQtOB3KhqJSpOOA
35+
response:
36+
body: '{}
37+
38+
'
39+
code: 200
40+
duration: 0ms
41+
headers:
42+
Content-Type:
43+
- application/json
44+
status: 200 OK
45+
version: 2

tests/scenarios/features/v1/logs_pipelines.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ Feature: Logs Pipelines
9898
When the request is sent
9999
Then the response status is 200 OK
100100

101+
@team:DataDog/event-platform-experience
102+
Scenario: Create a pipeline with nested pipeline processor returns "OK" response
103+
Given new "CreateLogsPipeline" request
104+
And body with value {"filter": {"query": "source:python"}, "name": "testPipelineWithNested", "processors": [{"type": "pipeline", "is_enabled": true, "name": "nested_pipeline_with_metadata", "filter": {"query": "env:production"}, "tags": ["env:prod", "type:nested"], "description": "This is a nested pipeline for production logs"}], "tags": ["team:test"], "description": "Pipeline containing nested processor with tags and description"}
105+
When the request is sent
106+
Then the response status is 200 OK
107+
101108
@team:DataDog/event-platform-experience
102109
Scenario: Create a pipeline with schema processor
103110
Given new "CreateLogsPipeline" request

0 commit comments

Comments
 (0)