Skip to content

Commit ae9d402

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Regenerate client from commit 53a6366 of spec repo (#3736)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 3b90196 commit ae9d402

10 files changed

Lines changed: 611 additions & 187 deletions

.generator/schemas/v1/openapi.yaml

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12338,33 +12338,73 @@ components:
1233812338
type: object
1233912339
SLOCountDefinition:
1234012340
description: 'A count-based (metric) SLI specification, composed of three parts:
12341-
the good events formula, the total events formula,
12341+
the good events formula,
1234212342

12343-
and the underlying queries.'
12343+
the bad or total events formula, and the underlying queries.
12344+
12345+
Exactly one of `total_events_formula` or `bad_events_formula` must be provided.'
1234412346
example:
12345-
good_events_formula: query1 - query2
12347+
bad_events_formula: query2
12348+
good_events_formula: query1
1234612349
queries:
1234712350
- data_source: metrics
1234812351
name: query1
12349-
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
12352+
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
1235012353
- data_source: metrics
1235112354
name: query2
12352-
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
12353-
total_events_formula: query1
12355+
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
12356+
oneOf:
12357+
- $ref: '#/components/schemas/SLOCountDefinitionWithTotalEventsFormula'
12358+
- $ref: '#/components/schemas/SLOCountDefinitionWithBadEventsFormula'
12359+
SLOCountDefinitionWithBadEventsFormula:
12360+
additionalProperties: false
1235412361
properties:
12362+
bad_events_formula:
12363+
$ref: '#/components/schemas/SLOFormula'
12364+
description: The bad events formula (recommended). Total events queries
12365+
can be defined using the `total_events_formula` field as an alternative.
12366+
Only one of `total_events_formula` or `bad_events_formula` must be provided.
1235512367
good_events_formula:
1235612368
$ref: '#/components/schemas/SLOFormula'
1235712369
queries:
1235812370
example:
1235912371
- data_source: metrics
1236012372
name: query1
12361-
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
12373+
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
12374+
- data_source: metrics
12375+
name: query2
12376+
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
12377+
items:
12378+
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
12379+
minItems: 1
12380+
type: array
12381+
required:
12382+
- good_events_formula
12383+
- bad_events_formula
12384+
- queries
12385+
type: object
12386+
SLOCountDefinitionWithTotalEventsFormula:
12387+
additionalProperties: false
12388+
properties:
12389+
good_events_formula:
12390+
$ref: '#/components/schemas/SLOFormula'
12391+
queries:
12392+
example:
12393+
- data_source: metrics
12394+
name: query1
12395+
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
12396+
- data_source: metrics
12397+
name: query2
12398+
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
1236212399
items:
1236312400
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
1236412401
minItems: 1
1236512402
type: array
1236612403
total_events_formula:
1236712404
$ref: '#/components/schemas/SLOFormula'
12405+
description: The total events formula. Bad events queries can be defined
12406+
using the `bad_events_formula` field as an alternative. Only one of `total_events_formula`
12407+
or `bad_events_formula` must be provided.
1236812408
required:
1236912409
- good_events_formula
1237012410
- total_events_formula
@@ -12375,15 +12415,15 @@ components:
1237512415
description: A metric SLI specification.
1237612416
example:
1237712417
count:
12378-
good_events_formula: query1 - query2
12418+
bad_events_formula: query2
12419+
good_events_formula: query1
1237912420
queries:
1238012421
- data_source: metrics
1238112422
name: query1
12382-
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
12423+
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
1238312424
- data_source: metrics
1238412425
name: query2
12385-
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
12386-
total_events_formula: query1
12426+
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
1238712427
properties:
1238812428
count:
1238912429
$ref: '#/components/schemas/SLOCountDefinition'
@@ -13519,7 +13559,7 @@ components:
1351913559
name: query1
1352013560
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
1352113561
- data_source: metrics
13522-
name: query1
13562+
name: query2
1352313563
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
1352413564
threshold: 5
1352513565
properties:

api/datadogV1/model_slo_count_definition.go

Lines changed: 71 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -5,174 +5,103 @@
55
package datadogV1
66

77
import (
8-
"fmt"
9-
108
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
119
)
1210

13-
// SLOCountDefinition A count-based (metric) SLI specification, composed of three parts: the good events formula, the total events formula,
14-
// and the underlying queries.
11+
// SLOCountDefinition - A count-based (metric) SLI specification, composed of three parts: the good events formula,
12+
// the bad or total events formula, and the underlying queries.
13+
// Exactly one of `total_events_formula` or `bad_events_formula` must be provided.
1514
type SLOCountDefinition struct {
16-
// A formula that specifies how to combine the results of multiple queries.
17-
GoodEventsFormula SLOFormula `json:"good_events_formula"`
18-
//
19-
Queries []SLODataSourceQueryDefinition `json:"queries"`
20-
// A formula that specifies how to combine the results of multiple queries.
21-
TotalEventsFormula SLOFormula `json:"total_events_formula"`
22-
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
23-
UnparsedObject map[string]interface{} `json:"-"`
24-
AdditionalProperties map[string]interface{} `json:"-"`
25-
}
15+
SLOCountDefinitionWithTotalEventsFormula *SLOCountDefinitionWithTotalEventsFormula
16+
SLOCountDefinitionWithBadEventsFormula *SLOCountDefinitionWithBadEventsFormula
2617

27-
// NewSLOCountDefinition instantiates a new SLOCountDefinition object.
28-
// This constructor will assign default values to properties that have it defined,
29-
// and makes sure properties required by API are set, but the set of arguments
30-
// will change when the set of required properties is changed.
31-
func NewSLOCountDefinition(goodEventsFormula SLOFormula, queries []SLODataSourceQueryDefinition, totalEventsFormula SLOFormula) *SLOCountDefinition {
32-
this := SLOCountDefinition{}
33-
this.GoodEventsFormula = goodEventsFormula
34-
this.Queries = queries
35-
this.TotalEventsFormula = totalEventsFormula
36-
return &this
18+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
19+
UnparsedObject interface{}
3720
}
3821

39-
// NewSLOCountDefinitionWithDefaults instantiates a new SLOCountDefinition object.
40-
// This constructor will only assign default values to properties that have it defined,
41-
// but it doesn't guarantee that properties required by API are set.
42-
func NewSLOCountDefinitionWithDefaults() *SLOCountDefinition {
43-
this := SLOCountDefinition{}
44-
return &this
22+
// SLOCountDefinitionWithTotalEventsFormulaAsSLOCountDefinition is a convenience function that returns SLOCountDefinitionWithTotalEventsFormula wrapped in SLOCountDefinition.
23+
func SLOCountDefinitionWithTotalEventsFormulaAsSLOCountDefinition(v *SLOCountDefinitionWithTotalEventsFormula) SLOCountDefinition {
24+
return SLOCountDefinition{SLOCountDefinitionWithTotalEventsFormula: v}
4525
}
4626

47-
// GetGoodEventsFormula returns the GoodEventsFormula field value.
48-
func (o *SLOCountDefinition) GetGoodEventsFormula() SLOFormula {
49-
if o == nil {
50-
var ret SLOFormula
51-
return ret
52-
}
53-
return o.GoodEventsFormula
27+
// SLOCountDefinitionWithBadEventsFormulaAsSLOCountDefinition is a convenience function that returns SLOCountDefinitionWithBadEventsFormula wrapped in SLOCountDefinition.
28+
func SLOCountDefinitionWithBadEventsFormulaAsSLOCountDefinition(v *SLOCountDefinitionWithBadEventsFormula) SLOCountDefinition {
29+
return SLOCountDefinition{SLOCountDefinitionWithBadEventsFormula: v}
5430
}
5531

56-
// GetGoodEventsFormulaOk returns a tuple with the GoodEventsFormula field value
57-
// and a boolean to check if the value has been set.
58-
func (o *SLOCountDefinition) GetGoodEventsFormulaOk() (*SLOFormula, bool) {
59-
if o == nil {
60-
return nil, false
32+
// UnmarshalJSON turns data into one of the pointers in the struct.
33+
func (obj *SLOCountDefinition) UnmarshalJSON(data []byte) error {
34+
var err error
35+
match := 0
36+
// try to unmarshal data into SLOCountDefinitionWithTotalEventsFormula
37+
err = datadog.Unmarshal(data, &obj.SLOCountDefinitionWithTotalEventsFormula)
38+
if err == nil {
39+
if obj.SLOCountDefinitionWithTotalEventsFormula != nil && obj.SLOCountDefinitionWithTotalEventsFormula.UnparsedObject == nil {
40+
jsonSLOCountDefinitionWithTotalEventsFormula, _ := datadog.Marshal(obj.SLOCountDefinitionWithTotalEventsFormula)
41+
if string(jsonSLOCountDefinitionWithTotalEventsFormula) == "{}" { // empty struct
42+
obj.SLOCountDefinitionWithTotalEventsFormula = nil
43+
} else {
44+
match++
45+
}
46+
} else {
47+
obj.SLOCountDefinitionWithTotalEventsFormula = nil
48+
}
49+
} else {
50+
obj.SLOCountDefinitionWithTotalEventsFormula = nil
51+
}
52+
53+
// try to unmarshal data into SLOCountDefinitionWithBadEventsFormula
54+
err = datadog.Unmarshal(data, &obj.SLOCountDefinitionWithBadEventsFormula)
55+
if err == nil {
56+
if obj.SLOCountDefinitionWithBadEventsFormula != nil && obj.SLOCountDefinitionWithBadEventsFormula.UnparsedObject == nil {
57+
jsonSLOCountDefinitionWithBadEventsFormula, _ := datadog.Marshal(obj.SLOCountDefinitionWithBadEventsFormula)
58+
if string(jsonSLOCountDefinitionWithBadEventsFormula) == "{}" { // empty struct
59+
obj.SLOCountDefinitionWithBadEventsFormula = nil
60+
} else {
61+
match++
62+
}
63+
} else {
64+
obj.SLOCountDefinitionWithBadEventsFormula = nil
65+
}
66+
} else {
67+
obj.SLOCountDefinitionWithBadEventsFormula = nil
6168
}
62-
return &o.GoodEventsFormula, true
63-
}
6469

65-
// SetGoodEventsFormula sets field value.
66-
func (o *SLOCountDefinition) SetGoodEventsFormula(v SLOFormula) {
67-
o.GoodEventsFormula = v
68-
}
69-
70-
// GetQueries returns the Queries field value.
71-
func (o *SLOCountDefinition) GetQueries() []SLODataSourceQueryDefinition {
72-
if o == nil {
73-
var ret []SLODataSourceQueryDefinition
74-
return ret
70+
if match != 1 { // more than 1 match
71+
// reset to nil
72+
obj.SLOCountDefinitionWithTotalEventsFormula = nil
73+
obj.SLOCountDefinitionWithBadEventsFormula = nil
74+
return datadog.Unmarshal(data, &obj.UnparsedObject)
7575
}
76-
return o.Queries
76+
return nil // exactly one match
7777
}
7878

79-
// GetQueriesOk returns a tuple with the Queries field value
80-
// and a boolean to check if the value has been set.
81-
func (o *SLOCountDefinition) GetQueriesOk() (*[]SLODataSourceQueryDefinition, bool) {
82-
if o == nil {
83-
return nil, false
79+
// MarshalJSON turns data from the first non-nil pointers in the struct to JSON.
80+
func (obj SLOCountDefinition) MarshalJSON() ([]byte, error) {
81+
if obj.SLOCountDefinitionWithTotalEventsFormula != nil {
82+
return datadog.Marshal(&obj.SLOCountDefinitionWithTotalEventsFormula)
8483
}
85-
return &o.Queries, true
86-
}
87-
88-
// SetQueries sets field value.
89-
func (o *SLOCountDefinition) SetQueries(v []SLODataSourceQueryDefinition) {
90-
o.Queries = v
91-
}
9284

93-
// GetTotalEventsFormula returns the TotalEventsFormula field value.
94-
func (o *SLOCountDefinition) GetTotalEventsFormula() SLOFormula {
95-
if o == nil {
96-
var ret SLOFormula
97-
return ret
85+
if obj.SLOCountDefinitionWithBadEventsFormula != nil {
86+
return datadog.Marshal(&obj.SLOCountDefinitionWithBadEventsFormula)
9887
}
99-
return o.TotalEventsFormula
100-
}
10188

102-
// GetTotalEventsFormulaOk returns a tuple with the TotalEventsFormula field value
103-
// and a boolean to check if the value has been set.
104-
func (o *SLOCountDefinition) GetTotalEventsFormulaOk() (*SLOFormula, bool) {
105-
if o == nil {
106-
return nil, false
89+
if obj.UnparsedObject != nil {
90+
return datadog.Marshal(obj.UnparsedObject)
10791
}
108-
return &o.TotalEventsFormula, true
109-
}
110-
111-
// SetTotalEventsFormula sets field value.
112-
func (o *SLOCountDefinition) SetTotalEventsFormula(v SLOFormula) {
113-
o.TotalEventsFormula = v
92+
return nil, nil // no data in oneOf schemas
11493
}
11594

116-
// MarshalJSON serializes the struct using spec logic.
117-
func (o SLOCountDefinition) MarshalJSON() ([]byte, error) {
118-
toSerialize := map[string]interface{}{}
119-
if o.UnparsedObject != nil {
120-
return datadog.Marshal(o.UnparsedObject)
121-
}
122-
toSerialize["good_events_formula"] = o.GoodEventsFormula
123-
toSerialize["queries"] = o.Queries
124-
toSerialize["total_events_formula"] = o.TotalEventsFormula
125-
126-
for key, value := range o.AdditionalProperties {
127-
toSerialize[key] = value
128-
}
129-
return datadog.Marshal(toSerialize)
130-
}
131-
132-
// UnmarshalJSON deserializes the given payload.
133-
func (o *SLOCountDefinition) UnmarshalJSON(bytes []byte) (err error) {
134-
all := struct {
135-
GoodEventsFormula *SLOFormula `json:"good_events_formula"`
136-
Queries *[]SLODataSourceQueryDefinition `json:"queries"`
137-
TotalEventsFormula *SLOFormula `json:"total_events_formula"`
138-
}{}
139-
if err = datadog.Unmarshal(bytes, &all); err != nil {
140-
return datadog.Unmarshal(bytes, &o.UnparsedObject)
141-
}
142-
if all.GoodEventsFormula == nil {
143-
return fmt.Errorf("required field good_events_formula missing")
144-
}
145-
if all.Queries == nil {
146-
return fmt.Errorf("required field queries missing")
147-
}
148-
if all.TotalEventsFormula == nil {
149-
return fmt.Errorf("required field total_events_formula missing")
150-
}
151-
additionalProperties := make(map[string]interface{})
152-
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
153-
datadog.DeleteKeys(additionalProperties, &[]string{"good_events_formula", "queries", "total_events_formula"})
154-
} else {
155-
return err
156-
}
157-
158-
hasInvalidField := false
159-
if all.GoodEventsFormula.UnparsedObject != nil && o.UnparsedObject == nil {
160-
hasInvalidField = true
161-
}
162-
o.GoodEventsFormula = *all.GoodEventsFormula
163-
o.Queries = *all.Queries
164-
if all.TotalEventsFormula.UnparsedObject != nil && o.UnparsedObject == nil {
165-
hasInvalidField = true
166-
}
167-
o.TotalEventsFormula = *all.TotalEventsFormula
168-
169-
if len(additionalProperties) > 0 {
170-
o.AdditionalProperties = additionalProperties
95+
// GetActualInstance returns the actual instance.
96+
func (obj *SLOCountDefinition) GetActualInstance() interface{} {
97+
if obj.SLOCountDefinitionWithTotalEventsFormula != nil {
98+
return obj.SLOCountDefinitionWithTotalEventsFormula
17199
}
172100

173-
if hasInvalidField {
174-
return datadog.Unmarshal(bytes, &o.UnparsedObject)
101+
if obj.SLOCountDefinitionWithBadEventsFormula != nil {
102+
return obj.SLOCountDefinitionWithBadEventsFormula
175103
}
176104

105+
// all schemas are nil
177106
return nil
178107
}

0 commit comments

Comments
 (0)