Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 50 additions & 6 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13177,13 +13177,16 @@ components:
type: object
SLOCorrectionCreateRequest:
description: |-
An object that defines a correction to be applied to an SLO.
An object that defines a correction to be applied to one or more SLOs.
properties:
data:
$ref: "#/components/schemas/SLOCorrectionCreateData"
type: object
SLOCorrectionCreateRequestAttributes:
description: The attribute object associated with the SLO correction to be created.
description: |-
The attribute object associated with the SLO correction to be created.

Exactly one of `slo_id` or `slo_query` must be provided.
properties:
category:
$ref: "#/components/schemas/SLOCorrectionCategory"
Expand All @@ -13207,9 +13210,16 @@ components:
example: FREQ=DAILY;INTERVAL=10;COUNT=5
type: string
slo_id:
description: ID of the SLO that this correction applies to.
description: ID of the single SLO that this correction applies to.
example: sloId
type: string
slo_query:
description: |-
Query that matches the SLOs this correction applies to.
The query uses the [Events search syntax](https://docs.datadoghq.com/events/explorer/searching/)
and can filter SLOs by SLO tags.
example: "env:prod service:checkout"
type: string
start:
description: Starting time of the correction in epoch seconds.
example: 1600000000
Expand All @@ -13220,7 +13230,6 @@ components:
example: UTC
type: string
required:
- slo_id
- start
- category
type: object
Expand Down Expand Up @@ -13284,7 +13293,12 @@ components:
nullable: true
type: string
slo_id:
description: ID of the SLO that this correction applies to.
description: ID of the single SLO that this correction applies to.
nullable: true
type: string
slo_query:
description: Query that matches the SLOs this correction applies to.
nullable: true
type: string
start:
description: Starting time of the correction in epoch seconds.
Expand Down Expand Up @@ -13356,6 +13370,13 @@ components:
are `FREQ`, `INTERVAL`, `COUNT`, `UNTIL` and `BYDAY`.
example: FREQ=DAILY;INTERVAL=10;COUNT=5
type: string
slo_query:
description: |-
Query that matches the SLOs this correction applies to.
The query uses the [Events search syntax](https://docs.datadoghq.com/events/explorer/searching/)
and can filter SLOs by SLO tags.
example: "env:prod service:checkout"
type: string
start:
description: Starting time of the correction in epoch seconds.
example: 1600000000
Expand Down Expand Up @@ -37493,7 +37514,8 @@ paths:
- slos_read
post:
description: |-
Create an SLO Correction.
Create an SLO correction. Use `slo_id` to apply the correction to a single SLO, or `slo_query` to apply the
correction to SLOs that match a query. Exactly one of `slo_id` or `slo_query` is required.
operationId: CreateSLOCorrection
requestBody:
content:
Expand All @@ -37510,6 +37532,17 @@ paths:
start: 1600000000
timezone: UTC
type: correction
slo_query:
value:
data:
attributes:
category: "Scheduled Maintenance"
description: "Planned maintenance window for checkout services."
end: 1600003600
slo_query: "env:prod service:checkout"
start: 1600000000
timezone: UTC
type: correction
schema:
$ref: "#/components/schemas/SLOCorrectionCreateRequest"
description: Create an SLO Correction
Expand Down Expand Up @@ -37669,6 +37702,17 @@ paths:
start: 1600000000
timezone: UTC
type: correction
slo_query:
value:
data:
attributes:
category: "Scheduled Maintenance"
description: "Updated correction for checkout services."
end: 1600003600
slo_query: "env:prod service:checkout"
start: 1600000000
timezone: UTC
type: correction
schema:
$ref: "#/components/schemas/SLOCorrectionUpdateRequest"
description: The edited SLO correction object.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-05-27T20:45:22.423Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-06-03T15:43:01.600Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Create an SLO correction with slo_query returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::ServiceLevelObjectiveCorrectionsAPI.new

body = DatadogAPIClient::V1::SLOCorrectionCreateRequest.new({
data: DatadogAPIClient::V1::SLOCorrectionCreateData.new({
attributes: DatadogAPIClient::V1::SLOCorrectionCreateRequestAttributes.new({
category: DatadogAPIClient::V1::SLOCorrectionCategory::SCHEDULED_MAINTENANCE,
description: "Example-Service-Level-Objective-Correction",
_end: (Time.now + 1 * 3600).to_i,
slo_query: "env:prod service:checkout",
start: Time.now.to_i,
timezone: "UTC",
}),
type: DatadogAPIClient::V1::SLOCorrectionType::CORRECTION,
}),
})
p api_instance.create_slo_correction(body)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Update an SLO correction with slo_query returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::ServiceLevelObjectiveCorrectionsAPI.new

# there is a valid "correction_with_query" in the system
CORRECTION_WITH_QUERY_DATA_ID = ENV["CORRECTION_WITH_QUERY_DATA_ID"]

body = DatadogAPIClient::V1::SLOCorrectionUpdateRequest.new({
data: DatadogAPIClient::V1::SLOCorrectionUpdateData.new({
attributes: DatadogAPIClient::V1::SLOCorrectionUpdateRequestAttributes.new({
category: DatadogAPIClient::V1::SLOCorrectionCategory::SCHEDULED_MAINTENANCE,
description: "Example-Service-Level-Objective-Correction",
_end: (Time.now + 1 * 3600).to_i,
slo_query: "env:staging service:checkout",
start: Time.now.to_i,
timezone: "UTC",
}),
type: DatadogAPIClient::V1::SLOCorrectionType::CORRECTION,
}),
})
p api_instance.update_slo_correction(CORRECTION_WITH_QUERY_DATA_ID, body)
12 changes: 12 additions & 0 deletions features/v1/given.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@
"tag": "Service Level Objective Corrections",
"operationId": "CreateSLOCorrection"
},
{
"parameters": [
{
"name": "body",
"value": "{\n \"data\": {\n \"attributes\": {\n \"slo_query\": \"env:prod service:checkout\",\n \"start\": {{ timestamp(\"now\") }},\n \"end\": {{ timestamp(\"now + 1h\") }},\n \"category\": \"Other\",\n \"timezone\": \"UTC\",\n \"description\": \"Test Correction\"\n },\n \"type\": \"correction\"\n }\n}"
}
],
"step": "there is a valid \"correction_with_query\" in the system",
"key": "correction_with_query",
"tag": "Service Level Objective Corrections",
"operationId": "CreateSLOCorrection"
},
{
"parameters": [
{
Expand Down
23 changes: 22 additions & 1 deletion features/v1/service_level_objective_corrections.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ Feature: Service Level Objective Corrections
And the response "data.type" is equal to "correction"
And the response "data.attributes.rrule" is equal to "FREQ=DAILY;INTERVAL=10;COUNT=5"

@team:DataDog/slo-app
Scenario: Create an SLO correction with slo_query returns "OK" response
Given new "CreateSLOCorrection" request
And body with value {"data": {"attributes": {"category": "Scheduled Maintenance", "description": "{{ unique }}", "end": {{ timestamp("now + 1h") }}, "slo_query": "env:prod service:checkout", "start": {{ timestamp("now") }}, "timezone": "UTC"}, "type": "correction"}}
When the request is sent
Then the response status is 200 OK
And the response "data.type" is equal to "correction"
And the response "data.attributes.category" is equal to "Scheduled Maintenance"
And the response "data.attributes.slo_query" is equal to "env:prod service:checkout"

@generated @skip @team:DataDog/slo-app
Scenario: Delete an SLO correction returns "Not found" response
Given new "DeleteSLOCorrection" request
Expand Down Expand Up @@ -114,7 +124,7 @@ Feature: Service Level Objective Corrections
Scenario: Update an SLO correction returns "Not Found" response
Given new "UpdateSLOCorrection" request
And request contains "slo_correction_id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"category": "Scheduled Maintenance", "duration": 3600, "end": 1600000000, "rrule": "FREQ=DAILY;INTERVAL=10;COUNT=5", "start": 1600000000, "timezone": "UTC"}, "type": "correction"}}
And body with value {"data": {"attributes": {"category": "Scheduled Maintenance", "duration": 3600, "end": 1600000000, "rrule": "FREQ=DAILY;INTERVAL=10;COUNT=5", "slo_query": "env:prod service:checkout", "start": 1600000000, "timezone": "UTC"}, "type": "correction"}}
When the request is sent
Then the response status is 404 Not Found

Expand All @@ -130,3 +140,14 @@ Feature: Service Level Objective Corrections
And the response "data.id" has the same value as "correction.data.id"
And the response "data.attributes.slo_id" has the same value as "correction.data.attributes.slo_id"
And the response "data.attributes.category" is equal to "Deployment"

@team:DataDog/slo-app
Scenario: Update an SLO correction with slo_query returns "OK" response
Given there is a valid "correction_with_query" in the system
And new "UpdateSLOCorrection" request
And request contains "slo_correction_id" parameter from "correction_with_query.data.id"
And body with value {"data": {"attributes": {"category": "Scheduled Maintenance", "description": "{{ unique }}", "end": {{ timestamp("now + 1h") }}, "slo_query": "env:staging service:checkout", "start": {{ timestamp("now") }}, "timezone": "UTC"}, "type": "correction"}}
When the request is sent
Then the response status is 200 OK
And the response "data.id" has the same value as "correction_with_query.data.id"
And the response "data.attributes.slo_query" is equal to "env:staging service:checkout"
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def create_slo_correction(body, opts = {})

# Create an SLO correction.
#
# Create an SLO Correction.
# Create an SLO correction. Use `slo_id` to apply the correction to a single SLO, or `slo_query` to apply the
# correction to SLOs that match a query. Exactly one of `slo_id` or `slo_query` is required.
#
# @param body [SLOCorrectionCreateRequest] Create an SLO Correction
# @param opts [Hash] the optional parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class SLOCorrectionCreateData
include BaseGenericModel

# The attribute object associated with the SLO correction to be created.
#
# Exactly one of `slo_id` or `slo_query` must be provided.
attr_accessor :attributes

# SLO correction resource type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require 'time'

module DatadogAPIClient::V1
# An object that defines a correction to be applied to an SLO.
# An object that defines a correction to be applied to one or more SLOs.
class SLOCorrectionCreateRequest
include BaseGenericModel

Expand Down
Loading
Loading