Skip to content

Commit a1941ae

Browse files
api-clients-generation-pipeline[bot]peachprosecutorclaudeci.datadog-api-spec
authored
Add slo_query to SLO Correction API for global correction support (#4207)
* Wrap SloId with PtrString in SLO lifecycle tests slo_id is now optional in SLOCorrectionCreateRequestAttributes (a correction can target slo_query instead of slo_id), so the generated SloId field is now *string. Update the hand-written SLO lifecycle test accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Regenerate client from commit 948302c of spec repo --------- Co-authored-by: Blaise von Ohlen <blaise.vonohlen@datadoghq.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 7e443d6 commit a1941ae

18 files changed

Lines changed: 467 additions & 46 deletions

.generator/schemas/v1/openapi.yaml

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13177,13 +13177,16 @@ components:
1317713177
type: object
1317813178
SLOCorrectionCreateRequest:
1317913179
description: |-
13180-
An object that defines a correction to be applied to an SLO.
13180+
An object that defines a correction to be applied to one or more SLOs.
1318113181
properties:
1318213182
data:
1318313183
$ref: "#/components/schemas/SLOCorrectionCreateData"
1318413184
type: object
1318513185
SLOCorrectionCreateRequestAttributes:
13186-
description: The attribute object associated with the SLO correction to be created.
13186+
description: |-
13187+
The attribute object associated with the SLO correction to be created.
13188+
13189+
Exactly one of `slo_id` or `slo_query` must be provided.
1318713190
properties:
1318813191
category:
1318913192
$ref: "#/components/schemas/SLOCorrectionCategory"
@@ -13207,9 +13210,16 @@ components:
1320713210
example: FREQ=DAILY;INTERVAL=10;COUNT=5
1320813211
type: string
1320913212
slo_id:
13210-
description: ID of the SLO that this correction applies to.
13213+
description: ID of the single SLO that this correction applies to.
1321113214
example: sloId
1321213215
type: string
13216+
slo_query:
13217+
description: |-
13218+
Query that matches the SLOs this correction applies to.
13219+
The query uses the [Events search syntax](https://docs.datadoghq.com/events/explorer/searching/)
13220+
and can filter SLOs by SLO tags.
13221+
example: "env:prod service:checkout"
13222+
type: string
1321313223
start:
1321413224
description: Starting time of the correction in epoch seconds.
1321513225
example: 1600000000
@@ -13220,7 +13230,6 @@ components:
1322013230
example: UTC
1322113231
type: string
1322213232
required:
13223-
- slo_id
1322413233
- start
1322513234
- category
1322613235
type: object
@@ -13284,7 +13293,12 @@ components:
1328413293
nullable: true
1328513294
type: string
1328613295
slo_id:
13287-
description: ID of the SLO that this correction applies to.
13296+
description: ID of the single SLO that this correction applies to.
13297+
nullable: true
13298+
type: string
13299+
slo_query:
13300+
description: Query that matches the SLOs this correction applies to.
13301+
nullable: true
1328813302
type: string
1328913303
start:
1329013304
description: Starting time of the correction in epoch seconds.
@@ -13356,6 +13370,13 @@ components:
1335613370
are `FREQ`, `INTERVAL`, `COUNT`, `UNTIL` and `BYDAY`.
1335713371
example: FREQ=DAILY;INTERVAL=10;COUNT=5
1335813372
type: string
13373+
slo_query:
13374+
description: |-
13375+
Query that matches the SLOs this correction applies to.
13376+
The query uses the [Events search syntax](https://docs.datadoghq.com/events/explorer/searching/)
13377+
and can filter SLOs by SLO tags.
13378+
example: "env:prod service:checkout"
13379+
type: string
1335913380
start:
1336013381
description: Starting time of the correction in epoch seconds.
1336113382
example: 1600000000
@@ -37493,7 +37514,8 @@ paths:
3749337514
- slos_read
3749437515
post:
3749537516
description: |-
37496-
Create an SLO Correction.
37517+
Create an SLO correction. Use `slo_id` to apply the correction to a single SLO, or `slo_query` to apply the
37518+
correction to SLOs that match a query. Exactly one of `slo_id` or `slo_query` is required.
3749737519
operationId: CreateSLOCorrection
3749837520
requestBody:
3749937521
content:
@@ -37510,6 +37532,17 @@ paths:
3751037532
start: 1600000000
3751137533
timezone: UTC
3751237534
type: correction
37535+
slo_query:
37536+
value:
37537+
data:
37538+
attributes:
37539+
category: "Scheduled Maintenance"
37540+
description: "Planned maintenance window for checkout services."
37541+
end: 1600003600
37542+
slo_query: "env:prod service:checkout"
37543+
start: 1600000000
37544+
timezone: UTC
37545+
type: correction
3751337546
schema:
3751437547
$ref: "#/components/schemas/SLOCorrectionCreateRequest"
3751537548
description: Create an SLO Correction
@@ -37669,6 +37702,17 @@ paths:
3766937702
start: 1600000000
3767037703
timezone: UTC
3767137704
type: correction
37705+
slo_query:
37706+
value:
37707+
data:
37708+
attributes:
37709+
category: "Scheduled Maintenance"
37710+
description: "Updated correction for checkout services."
37711+
end: 1600003600
37712+
slo_query: "env:prod service:checkout"
37713+
start: 1600000000
37714+
timezone: UTC
37715+
type: correction
3767237716
schema:
3767337717
$ref: "#/components/schemas/SLOCorrectionUpdateRequest"
3767437718
description: The edited SLO correction object.

api/datadogV1/api_service_level_objective_corrections.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import (
1616
type ServiceLevelObjectiveCorrectionsApi datadog.Service
1717

1818
// CreateSLOCorrection Create an SLO correction.
19-
// Create an SLO Correction.
19+
// Create an SLO correction. Use `slo_id` to apply the correction to a single SLO, or `slo_query` to apply the
20+
// correction to SLOs that match a query. Exactly one of `slo_id` or `slo_query` is required.
2021
func (a *ServiceLevelObjectiveCorrectionsApi) CreateSLOCorrection(ctx _context.Context, body SLOCorrectionCreateRequest) (SLOCorrectionResponse, *_nethttp.Response, error) {
2122
var (
2223
localVarHTTPMethod = _nethttp.MethodPost

api/datadogV1/model_slo_correction_create_data.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
// SLOCorrectionCreateData The data object associated with the SLO correction to be created.
1414
type SLOCorrectionCreateData struct {
1515
// The attribute object associated with the SLO correction to be created.
16+
//
17+
// Exactly one of `slo_id` or `slo_query` must be provided.
1618
Attributes *SLOCorrectionCreateRequestAttributes `json:"attributes,omitempty"`
1719
// SLO correction resource type.
1820
Type SLOCorrectionType `json:"type"`

api/datadogV1/model_slo_correction_create_request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
99
)
1010

11-
// SLOCorrectionCreateRequest An object that defines a correction to be applied to an SLO.
11+
// SLOCorrectionCreateRequest An object that defines a correction to be applied to one or more SLOs.
1212
type SLOCorrectionCreateRequest struct {
1313
// The data object associated with the SLO correction to be created.
1414
Data *SLOCorrectionCreateData `json:"data,omitempty"`

api/datadogV1/model_slo_correction_create_request_attributes.go

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
)
1212

1313
// SLOCorrectionCreateRequestAttributes The attribute object associated with the SLO correction to be created.
14+
//
15+
// Exactly one of `slo_id` or `slo_query` must be provided.
1416
type SLOCorrectionCreateRequestAttributes struct {
1517
// Category the SLO correction belongs to.
1618
Category SLOCorrectionCategory `json:"category"`
@@ -23,8 +25,12 @@ type SLOCorrectionCreateRequestAttributes struct {
2325
// The recurrence rules as defined in the iCalendar RFC 5545. The supported rules for SLO corrections
2426
// are `FREQ`, `INTERVAL`, `COUNT`, `UNTIL` and `BYDAY`.
2527
Rrule *string `json:"rrule,omitempty"`
26-
// ID of the SLO that this correction applies to.
27-
SloId string `json:"slo_id"`
28+
// ID of the single SLO that this correction applies to.
29+
SloId *string `json:"slo_id,omitempty"`
30+
// Query that matches the SLOs this correction applies to.
31+
// The query uses the [Events search syntax](https://docs.datadoghq.com/events/explorer/searching/)
32+
// and can filter SLOs by SLO tags.
33+
SloQuery *string `json:"slo_query,omitempty"`
2834
// Starting time of the correction in epoch seconds.
2935
Start int64 `json:"start"`
3036
// The timezone to display in the UI for the correction times (defaults to "UTC").
@@ -38,10 +44,9 @@ type SLOCorrectionCreateRequestAttributes struct {
3844
// This constructor will assign default values to properties that have it defined,
3945
// and makes sure properties required by API are set, but the set of arguments
4046
// will change when the set of required properties is changed.
41-
func NewSLOCorrectionCreateRequestAttributes(category SLOCorrectionCategory, sloId string, start int64) *SLOCorrectionCreateRequestAttributes {
47+
func NewSLOCorrectionCreateRequestAttributes(category SLOCorrectionCategory, start int64) *SLOCorrectionCreateRequestAttributes {
4248
this := SLOCorrectionCreateRequestAttributes{}
4349
this.Category = category
44-
this.SloId = sloId
4550
this.Start = start
4651
return &this
4752
}
@@ -189,27 +194,60 @@ func (o *SLOCorrectionCreateRequestAttributes) SetRrule(v string) {
189194
o.Rrule = &v
190195
}
191196

192-
// GetSloId returns the SloId field value.
197+
// GetSloId returns the SloId field value if set, zero value otherwise.
193198
func (o *SLOCorrectionCreateRequestAttributes) GetSloId() string {
194-
if o == nil {
199+
if o == nil || o.SloId == nil {
195200
var ret string
196201
return ret
197202
}
198-
return o.SloId
203+
return *o.SloId
199204
}
200205

201-
// GetSloIdOk returns a tuple with the SloId field value
206+
// GetSloIdOk returns a tuple with the SloId field value if set, nil otherwise
202207
// and a boolean to check if the value has been set.
203208
func (o *SLOCorrectionCreateRequestAttributes) GetSloIdOk() (*string, bool) {
204-
if o == nil {
209+
if o == nil || o.SloId == nil {
205210
return nil, false
206211
}
207-
return &o.SloId, true
212+
return o.SloId, true
213+
}
214+
215+
// HasSloId returns a boolean if a field has been set.
216+
func (o *SLOCorrectionCreateRequestAttributes) HasSloId() bool {
217+
return o != nil && o.SloId != nil
208218
}
209219

210-
// SetSloId sets field value.
220+
// SetSloId gets a reference to the given string and assigns it to the SloId field.
211221
func (o *SLOCorrectionCreateRequestAttributes) SetSloId(v string) {
212-
o.SloId = v
222+
o.SloId = &v
223+
}
224+
225+
// GetSloQuery returns the SloQuery field value if set, zero value otherwise.
226+
func (o *SLOCorrectionCreateRequestAttributes) GetSloQuery() string {
227+
if o == nil || o.SloQuery == nil {
228+
var ret string
229+
return ret
230+
}
231+
return *o.SloQuery
232+
}
233+
234+
// GetSloQueryOk returns a tuple with the SloQuery field value if set, nil otherwise
235+
// and a boolean to check if the value has been set.
236+
func (o *SLOCorrectionCreateRequestAttributes) GetSloQueryOk() (*string, bool) {
237+
if o == nil || o.SloQuery == nil {
238+
return nil, false
239+
}
240+
return o.SloQuery, true
241+
}
242+
243+
// HasSloQuery returns a boolean if a field has been set.
244+
func (o *SLOCorrectionCreateRequestAttributes) HasSloQuery() bool {
245+
return o != nil && o.SloQuery != nil
246+
}
247+
248+
// SetSloQuery gets a reference to the given string and assigns it to the SloQuery field.
249+
func (o *SLOCorrectionCreateRequestAttributes) SetSloQuery(v string) {
250+
o.SloQuery = &v
213251
}
214252

215253
// GetStart returns the Start field value.
@@ -282,7 +320,12 @@ func (o SLOCorrectionCreateRequestAttributes) MarshalJSON() ([]byte, error) {
282320
if o.Rrule != nil {
283321
toSerialize["rrule"] = o.Rrule
284322
}
285-
toSerialize["slo_id"] = o.SloId
323+
if o.SloId != nil {
324+
toSerialize["slo_id"] = o.SloId
325+
}
326+
if o.SloQuery != nil {
327+
toSerialize["slo_query"] = o.SloQuery
328+
}
286329
toSerialize["start"] = o.Start
287330
if o.Timezone != nil {
288331
toSerialize["timezone"] = o.Timezone
@@ -302,7 +345,8 @@ func (o *SLOCorrectionCreateRequestAttributes) UnmarshalJSON(bytes []byte) (err
302345
Duration *int64 `json:"duration,omitempty"`
303346
End *int64 `json:"end,omitempty"`
304347
Rrule *string `json:"rrule,omitempty"`
305-
SloId *string `json:"slo_id"`
348+
SloId *string `json:"slo_id,omitempty"`
349+
SloQuery *string `json:"slo_query,omitempty"`
306350
Start *int64 `json:"start"`
307351
Timezone *string `json:"timezone,omitempty"`
308352
}{}
@@ -312,15 +356,12 @@ func (o *SLOCorrectionCreateRequestAttributes) UnmarshalJSON(bytes []byte) (err
312356
if all.Category == nil {
313357
return fmt.Errorf("required field category missing")
314358
}
315-
if all.SloId == nil {
316-
return fmt.Errorf("required field slo_id missing")
317-
}
318359
if all.Start == nil {
319360
return fmt.Errorf("required field start missing")
320361
}
321362
additionalProperties := make(map[string]interface{})
322363
if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil {
323-
datadog.DeleteKeys(additionalProperties, &[]string{"category", "description", "duration", "end", "rrule", "slo_id", "start", "timezone"})
364+
datadog.DeleteKeys(additionalProperties, &[]string{"category", "description", "duration", "end", "rrule", "slo_id", "slo_query", "start", "timezone"})
324365
} else {
325366
return err
326367
}
@@ -335,7 +376,8 @@ func (o *SLOCorrectionCreateRequestAttributes) UnmarshalJSON(bytes []byte) (err
335376
o.Duration = all.Duration
336377
o.End = all.End
337378
o.Rrule = all.Rrule
338-
o.SloId = *all.SloId
379+
o.SloId = all.SloId
380+
o.SloQuery = all.SloQuery
339381
o.Start = *all.Start
340382
o.Timezone = all.Timezone
341383

0 commit comments

Comments
 (0)