Skip to content

Commit 6e1db62

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add support for routes in datadog logs destination (#3624)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 5a853a4 commit 6e1db62

3 files changed

Lines changed: 281 additions & 4 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36571,6 +36571,18 @@ components:
3657136571
items:
3657236572
type: string
3657336573
type: array
36574+
routes:
36575+
description: A list of routing rules that forward matching logs to Datadog
36576+
using dedicated API keys.
36577+
example:
36578+
- api_key_key: API_KEY_IDENTIFIER
36579+
include: service:api
36580+
route_id: datadog-logs-route-us1
36581+
site: us1
36582+
items:
36583+
$ref: '#/components/schemas/ObservabilityPipelineDatadogLogsDestinationRoute'
36584+
maxItems: 100
36585+
type: array
3657436586
type:
3657536587
$ref: '#/components/schemas/ObservabilityPipelineDatadogLogsDestinationType'
3657636588
required:
@@ -36580,6 +36592,29 @@ components:
3658036592
type: object
3658136593
x-pipeline-types:
3658236594
- logs
36595+
ObservabilityPipelineDatadogLogsDestinationRoute:
36596+
description: Defines how the `datadog_logs` destination routes matching logs
36597+
to a Datadog site using a specific API key.
36598+
properties:
36599+
api_key_key:
36600+
description: Name of the environment variable or secret that stores the
36601+
Datadog API key used by this route.
36602+
example: API_KEY_IDENTIFIER
36603+
type: string
36604+
include:
36605+
description: A Datadog search query that determines which logs are forwarded
36606+
using this route.
36607+
example: service:api
36608+
type: string
36609+
route_id:
36610+
description: Unique identifier for this route within the destination.
36611+
example: datadog-logs-route-us
36612+
type: string
36613+
site:
36614+
description: Datadog site where matching logs are sent (for example, `us1`).
36615+
example: us1
36616+
type: string
36617+
type: object
3658336618
ObservabilityPipelineDatadogLogsDestinationType:
3658436619
default: datadog_logs
3658536620
description: The destination type. The value should always be `datadog_logs`.

api/datadogV2/model_observability_pipeline_datadog_logs_destination.go

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type ObservabilityPipelineDatadogLogsDestination struct {
1818
Id string `json:"id"`
1919
// A list of component IDs whose output is used as the `input` for this component.
2020
Inputs []string `json:"inputs"`
21+
// A list of routing rules that forward matching logs to Datadog using dedicated API keys.
22+
Routes []ObservabilityPipelineDatadogLogsDestinationRoute `json:"routes,omitempty"`
2123
// The destination type. The value should always be `datadog_logs`.
2224
Type ObservabilityPipelineDatadogLogsDestinationType `json:"type"`
2325
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
@@ -93,6 +95,34 @@ func (o *ObservabilityPipelineDatadogLogsDestination) SetInputs(v []string) {
9395
o.Inputs = v
9496
}
9597

98+
// GetRoutes returns the Routes field value if set, zero value otherwise.
99+
func (o *ObservabilityPipelineDatadogLogsDestination) GetRoutes() []ObservabilityPipelineDatadogLogsDestinationRoute {
100+
if o == nil || o.Routes == nil {
101+
var ret []ObservabilityPipelineDatadogLogsDestinationRoute
102+
return ret
103+
}
104+
return o.Routes
105+
}
106+
107+
// GetRoutesOk returns a tuple with the Routes field value if set, nil otherwise
108+
// and a boolean to check if the value has been set.
109+
func (o *ObservabilityPipelineDatadogLogsDestination) GetRoutesOk() (*[]ObservabilityPipelineDatadogLogsDestinationRoute, bool) {
110+
if o == nil || o.Routes == nil {
111+
return nil, false
112+
}
113+
return &o.Routes, true
114+
}
115+
116+
// HasRoutes returns a boolean if a field has been set.
117+
func (o *ObservabilityPipelineDatadogLogsDestination) HasRoutes() bool {
118+
return o != nil && o.Routes != nil
119+
}
120+
121+
// SetRoutes gets a reference to the given []ObservabilityPipelineDatadogLogsDestinationRoute and assigns it to the Routes field.
122+
func (o *ObservabilityPipelineDatadogLogsDestination) SetRoutes(v []ObservabilityPipelineDatadogLogsDestinationRoute) {
123+
o.Routes = v
124+
}
125+
96126
// GetType returns the Type field value.
97127
func (o *ObservabilityPipelineDatadogLogsDestination) GetType() ObservabilityPipelineDatadogLogsDestinationType {
98128
if o == nil {
@@ -124,6 +154,9 @@ func (o ObservabilityPipelineDatadogLogsDestination) MarshalJSON() ([]byte, erro
124154
}
125155
toSerialize["id"] = o.Id
126156
toSerialize["inputs"] = o.Inputs
157+
if o.Routes != nil {
158+
toSerialize["routes"] = o.Routes
159+
}
127160
toSerialize["type"] = o.Type
128161

129162
for key, value := range o.AdditionalProperties {
@@ -135,9 +168,10 @@ func (o ObservabilityPipelineDatadogLogsDestination) MarshalJSON() ([]byte, erro
135168
// UnmarshalJSON deserializes the given payload.
136169
func (o *ObservabilityPipelineDatadogLogsDestination) UnmarshalJSON(bytes []byte) (err error) {
137170
all := struct {
138-
Id *string `json:"id"`
139-
Inputs *[]string `json:"inputs"`
140-
Type *ObservabilityPipelineDatadogLogsDestinationType `json:"type"`
171+
Id *string `json:"id"`
172+
Inputs *[]string `json:"inputs"`
173+
Routes []ObservabilityPipelineDatadogLogsDestinationRoute `json:"routes,omitempty"`
174+
Type *ObservabilityPipelineDatadogLogsDestinationType `json:"type"`
141175
}{}
142176
if err = datadog.Unmarshal(bytes, &all); err != nil {
143177
return datadog.Unmarshal(bytes, &o.UnparsedObject)
@@ -153,14 +187,15 @@ func (o *ObservabilityPipelineDatadogLogsDestination) UnmarshalJSON(bytes []byte
153187
}
154188
additionalProperties := make(map[string]interface{})
155189
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
156-
datadog.DeleteKeys(additionalProperties, &[]string{"id", "inputs", "type"})
190+
datadog.DeleteKeys(additionalProperties, &[]string{"id", "inputs", "routes", "type"})
157191
} else {
158192
return err
159193
}
160194

161195
hasInvalidField := false
162196
o.Id = *all.Id
163197
o.Inputs = *all.Inputs
198+
o.Routes = all.Routes
164199
if !all.Type.IsValid() {
165200
hasInvalidField = true
166201
} else {
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
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+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
9+
)
10+
11+
// ObservabilityPipelineDatadogLogsDestinationRoute Defines how the `datadog_logs` destination routes matching logs to a Datadog site using a specific API key.
12+
type ObservabilityPipelineDatadogLogsDestinationRoute struct {
13+
// Name of the environment variable or secret that stores the Datadog API key used by this route.
14+
ApiKeyKey *string `json:"api_key_key,omitempty"`
15+
// A Datadog search query that determines which logs are forwarded using this route.
16+
Include *string `json:"include,omitempty"`
17+
// Unique identifier for this route within the destination.
18+
RouteId *string `json:"route_id,omitempty"`
19+
// Datadog site where matching logs are sent (for example, `us1`).
20+
Site *string `json:"site,omitempty"`
21+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
22+
UnparsedObject map[string]interface{} `json:"-"`
23+
AdditionalProperties map[string]interface{} `json:"-"`
24+
}
25+
26+
// NewObservabilityPipelineDatadogLogsDestinationRoute instantiates a new ObservabilityPipelineDatadogLogsDestinationRoute object.
27+
// This constructor will assign default values to properties that have it defined,
28+
// and makes sure properties required by API are set, but the set of arguments
29+
// will change when the set of required properties is changed.
30+
func NewObservabilityPipelineDatadogLogsDestinationRoute() *ObservabilityPipelineDatadogLogsDestinationRoute {
31+
this := ObservabilityPipelineDatadogLogsDestinationRoute{}
32+
return &this
33+
}
34+
35+
// NewObservabilityPipelineDatadogLogsDestinationRouteWithDefaults instantiates a new ObservabilityPipelineDatadogLogsDestinationRoute object.
36+
// This constructor will only assign default values to properties that have it defined,
37+
// but it doesn't guarantee that properties required by API are set.
38+
func NewObservabilityPipelineDatadogLogsDestinationRouteWithDefaults() *ObservabilityPipelineDatadogLogsDestinationRoute {
39+
this := ObservabilityPipelineDatadogLogsDestinationRoute{}
40+
return &this
41+
}
42+
43+
// GetApiKeyKey returns the ApiKeyKey field value if set, zero value otherwise.
44+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) GetApiKeyKey() string {
45+
if o == nil || o.ApiKeyKey == nil {
46+
var ret string
47+
return ret
48+
}
49+
return *o.ApiKeyKey
50+
}
51+
52+
// GetApiKeyKeyOk returns a tuple with the ApiKeyKey field value if set, nil otherwise
53+
// and a boolean to check if the value has been set.
54+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) GetApiKeyKeyOk() (*string, bool) {
55+
if o == nil || o.ApiKeyKey == nil {
56+
return nil, false
57+
}
58+
return o.ApiKeyKey, true
59+
}
60+
61+
// HasApiKeyKey returns a boolean if a field has been set.
62+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) HasApiKeyKey() bool {
63+
return o != nil && o.ApiKeyKey != nil
64+
}
65+
66+
// SetApiKeyKey gets a reference to the given string and assigns it to the ApiKeyKey field.
67+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) SetApiKeyKey(v string) {
68+
o.ApiKeyKey = &v
69+
}
70+
71+
// GetInclude returns the Include field value if set, zero value otherwise.
72+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) GetInclude() string {
73+
if o == nil || o.Include == nil {
74+
var ret string
75+
return ret
76+
}
77+
return *o.Include
78+
}
79+
80+
// GetIncludeOk returns a tuple with the Include field value if set, nil otherwise
81+
// and a boolean to check if the value has been set.
82+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) GetIncludeOk() (*string, bool) {
83+
if o == nil || o.Include == nil {
84+
return nil, false
85+
}
86+
return o.Include, true
87+
}
88+
89+
// HasInclude returns a boolean if a field has been set.
90+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) HasInclude() bool {
91+
return o != nil && o.Include != nil
92+
}
93+
94+
// SetInclude gets a reference to the given string and assigns it to the Include field.
95+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) SetInclude(v string) {
96+
o.Include = &v
97+
}
98+
99+
// GetRouteId returns the RouteId field value if set, zero value otherwise.
100+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) GetRouteId() string {
101+
if o == nil || o.RouteId == nil {
102+
var ret string
103+
return ret
104+
}
105+
return *o.RouteId
106+
}
107+
108+
// GetRouteIdOk returns a tuple with the RouteId field value if set, nil otherwise
109+
// and a boolean to check if the value has been set.
110+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) GetRouteIdOk() (*string, bool) {
111+
if o == nil || o.RouteId == nil {
112+
return nil, false
113+
}
114+
return o.RouteId, true
115+
}
116+
117+
// HasRouteId returns a boolean if a field has been set.
118+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) HasRouteId() bool {
119+
return o != nil && o.RouteId != nil
120+
}
121+
122+
// SetRouteId gets a reference to the given string and assigns it to the RouteId field.
123+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) SetRouteId(v string) {
124+
o.RouteId = &v
125+
}
126+
127+
// GetSite returns the Site field value if set, zero value otherwise.
128+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) GetSite() string {
129+
if o == nil || o.Site == nil {
130+
var ret string
131+
return ret
132+
}
133+
return *o.Site
134+
}
135+
136+
// GetSiteOk returns a tuple with the Site field value if set, nil otherwise
137+
// and a boolean to check if the value has been set.
138+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) GetSiteOk() (*string, bool) {
139+
if o == nil || o.Site == nil {
140+
return nil, false
141+
}
142+
return o.Site, true
143+
}
144+
145+
// HasSite returns a boolean if a field has been set.
146+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) HasSite() bool {
147+
return o != nil && o.Site != nil
148+
}
149+
150+
// SetSite gets a reference to the given string and assigns it to the Site field.
151+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) SetSite(v string) {
152+
o.Site = &v
153+
}
154+
155+
// MarshalJSON serializes the struct using spec logic.
156+
func (o ObservabilityPipelineDatadogLogsDestinationRoute) MarshalJSON() ([]byte, error) {
157+
toSerialize := map[string]interface{}{}
158+
if o.UnparsedObject != nil {
159+
return datadog.Marshal(o.UnparsedObject)
160+
}
161+
if o.ApiKeyKey != nil {
162+
toSerialize["api_key_key"] = o.ApiKeyKey
163+
}
164+
if o.Include != nil {
165+
toSerialize["include"] = o.Include
166+
}
167+
if o.RouteId != nil {
168+
toSerialize["route_id"] = o.RouteId
169+
}
170+
if o.Site != nil {
171+
toSerialize["site"] = o.Site
172+
}
173+
174+
for key, value := range o.AdditionalProperties {
175+
toSerialize[key] = value
176+
}
177+
return datadog.Marshal(toSerialize)
178+
}
179+
180+
// UnmarshalJSON deserializes the given payload.
181+
func (o *ObservabilityPipelineDatadogLogsDestinationRoute) UnmarshalJSON(bytes []byte) (err error) {
182+
all := struct {
183+
ApiKeyKey *string `json:"api_key_key,omitempty"`
184+
Include *string `json:"include,omitempty"`
185+
RouteId *string `json:"route_id,omitempty"`
186+
Site *string `json:"site,omitempty"`
187+
}{}
188+
if err = datadog.Unmarshal(bytes, &all); err != nil {
189+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
190+
}
191+
additionalProperties := make(map[string]interface{})
192+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
193+
datadog.DeleteKeys(additionalProperties, &[]string{"api_key_key", "include", "route_id", "site"})
194+
} else {
195+
return err
196+
}
197+
o.ApiKeyKey = all.ApiKeyKey
198+
o.Include = all.Include
199+
o.RouteId = all.RouteId
200+
o.Site = all.Site
201+
202+
if len(additionalProperties) > 0 {
203+
o.AdditionalProperties = additionalProperties
204+
}
205+
206+
return nil
207+
}

0 commit comments

Comments
 (0)