diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 82c52ea77c7..7131ce19a0c 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -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" @@ -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 @@ -13220,7 +13230,6 @@ components: example: UTC type: string required: - - slo_id - start - category type: object @@ -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. @@ -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 @@ -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: @@ -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 @@ -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. diff --git a/examples/v1/service-level-objective-corrections/CreateSLOCorrection_2888963657.java b/examples/v1/service-level-objective-corrections/CreateSLOCorrection_2888963657.java new file mode 100644 index 00000000000..39f1c682fdf --- /dev/null +++ b/examples/v1/service-level-objective-corrections/CreateSLOCorrection_2888963657.java @@ -0,0 +1,45 @@ +// Create an SLO correction with slo_query returns "OK" response +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.ServiceLevelObjectiveCorrectionsApi; +import com.datadog.api.client.v1.model.SLOCorrectionCategory; +import com.datadog.api.client.v1.model.SLOCorrectionCreateData; +import com.datadog.api.client.v1.model.SLOCorrectionCreateRequest; +import com.datadog.api.client.v1.model.SLOCorrectionCreateRequestAttributes; +import com.datadog.api.client.v1.model.SLOCorrectionResponse; +import com.datadog.api.client.v1.model.SLOCorrectionType; +import java.time.OffsetDateTime; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + ServiceLevelObjectiveCorrectionsApi apiInstance = + new ServiceLevelObjectiveCorrectionsApi(defaultClient); + + SLOCorrectionCreateRequest body = + new SLOCorrectionCreateRequest() + .data( + new SLOCorrectionCreateData() + .attributes( + new SLOCorrectionCreateRequestAttributes() + .category(SLOCorrectionCategory.SCHEDULED_MAINTENANCE) + .description("Example-Service-Level-Objective-Correction") + .end(OffsetDateTime.now().plusHours(1).toInstant().getEpochSecond()) + .sloQuery("env:prod service:checkout") + .start(OffsetDateTime.now().toInstant().getEpochSecond()) + .timezone("UTC")) + .type(SLOCorrectionType.CORRECTION)); + + try { + SLOCorrectionResponse result = apiInstance.createSLOCorrection(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling ServiceLevelObjectiveCorrectionsApi#createSLOCorrection"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v1/service-level-objective-corrections/UpdateSLOCorrection_2949191256.java b/examples/v1/service-level-objective-corrections/UpdateSLOCorrection_2949191256.java new file mode 100644 index 00000000000..1d37062481a --- /dev/null +++ b/examples/v1/service-level-objective-corrections/UpdateSLOCorrection_2949191256.java @@ -0,0 +1,49 @@ +// Update an SLO correction with slo_query returns "OK" response +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.ServiceLevelObjectiveCorrectionsApi; +import com.datadog.api.client.v1.model.SLOCorrectionCategory; +import com.datadog.api.client.v1.model.SLOCorrectionResponse; +import com.datadog.api.client.v1.model.SLOCorrectionType; +import com.datadog.api.client.v1.model.SLOCorrectionUpdateData; +import com.datadog.api.client.v1.model.SLOCorrectionUpdateRequest; +import com.datadog.api.client.v1.model.SLOCorrectionUpdateRequestAttributes; +import java.time.OffsetDateTime; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + ServiceLevelObjectiveCorrectionsApi apiInstance = + new ServiceLevelObjectiveCorrectionsApi(defaultClient); + + // there is a valid "correction_with_query" in the system + String CORRECTION_WITH_QUERY_DATA_ID = System.getenv("CORRECTION_WITH_QUERY_DATA_ID"); + + SLOCorrectionUpdateRequest body = + new SLOCorrectionUpdateRequest() + .data( + new SLOCorrectionUpdateData() + .attributes( + new SLOCorrectionUpdateRequestAttributes() + .category(SLOCorrectionCategory.SCHEDULED_MAINTENANCE) + .description("Example-Service-Level-Objective-Correction") + .end(OffsetDateTime.now().plusHours(1).toInstant().getEpochSecond()) + .sloQuery("env:staging service:checkout") + .start(OffsetDateTime.now().toInstant().getEpochSecond()) + .timezone("UTC")) + .type(SLOCorrectionType.CORRECTION)); + + try { + SLOCorrectionResponse result = + apiInstance.updateSLOCorrection(CORRECTION_WITH_QUERY_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling ServiceLevelObjectiveCorrectionsApi#updateSLOCorrection"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v1/api/ServiceLevelObjectiveCorrectionsApi.java b/src/main/java/com/datadog/api/client/v1/api/ServiceLevelObjectiveCorrectionsApi.java index a8f0191c017..5df5d697189 100644 --- a/src/main/java/com/datadog/api/client/v1/api/ServiceLevelObjectiveCorrectionsApi.java +++ b/src/main/java/com/datadog/api/client/v1/api/ServiceLevelObjectiveCorrectionsApi.java @@ -82,7 +82,9 @@ public CompletableFuture createSLOCorrectionAsync( } /** - * 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 Create an SLO Correction (required) * @return ApiResponse<SLOCorrectionResponse> diff --git a/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateData.java b/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateData.java index cf63600bde4..1baf69070f0 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateData.java +++ b/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateData.java @@ -50,6 +50,8 @@ public SLOCorrectionCreateData attributes(SLOCorrectionCreateRequestAttributes a /** * The attribute object associated with the SLO correction to be created. * + *

Exactly one of slo_id or slo_query must be provided. + * * @return attributes */ @jakarta.annotation.Nullable diff --git a/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateRequest.java b/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateRequest.java index 13073ccc12d..c0f63ef3b99 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateRequest.java +++ b/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateRequest.java @@ -16,7 +16,7 @@ import java.util.Map; import java.util.Objects; -/** 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. */ @JsonPropertyOrder({SLOCorrectionCreateRequest.JSON_PROPERTY_DATA}) @jakarta.annotation.Generated( value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") diff --git a/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateRequestAttributes.java b/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateRequestAttributes.java index b01e8881bea..c208c87eb4f 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateRequestAttributes.java +++ b/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionCreateRequestAttributes.java @@ -17,7 +17,11 @@ import java.util.Map; import java.util.Objects; -/** The attribute object associated with the SLO correction to be created. */ +/** + * The attribute object associated with the SLO correction to be created. + * + *

Exactly one of slo_id or slo_query must be provided. + */ @JsonPropertyOrder({ SLOCorrectionCreateRequestAttributes.JSON_PROPERTY_CATEGORY, SLOCorrectionCreateRequestAttributes.JSON_PROPERTY_DESCRIPTION, @@ -25,6 +29,7 @@ SLOCorrectionCreateRequestAttributes.JSON_PROPERTY_END, SLOCorrectionCreateRequestAttributes.JSON_PROPERTY_RRULE, SLOCorrectionCreateRequestAttributes.JSON_PROPERTY_SLO_ID, + SLOCorrectionCreateRequestAttributes.JSON_PROPERTY_SLO_QUERY, SLOCorrectionCreateRequestAttributes.JSON_PROPERTY_START, SLOCorrectionCreateRequestAttributes.JSON_PROPERTY_TIMEZONE }) @@ -50,6 +55,9 @@ public class SLOCorrectionCreateRequestAttributes { public static final String JSON_PROPERTY_SLO_ID = "slo_id"; private String sloId; + public static final String JSON_PROPERTY_SLO_QUERY = "slo_query"; + private String sloQuery; + public static final String JSON_PROPERTY_START = "start"; private Long start; @@ -61,11 +69,9 @@ public SLOCorrectionCreateRequestAttributes() {} @JsonCreator public SLOCorrectionCreateRequestAttributes( @JsonProperty(required = true, value = JSON_PROPERTY_CATEGORY) SLOCorrectionCategory category, - @JsonProperty(required = true, value = JSON_PROPERTY_SLO_ID) String sloId, @JsonProperty(required = true, value = JSON_PROPERTY_START) Long start) { this.category = category; this.unparsed |= !category.isValid(); - this.sloId = sloId; this.start = start; } @@ -185,12 +191,13 @@ public SLOCorrectionCreateRequestAttributes sloId(String sloId) { } /** - * ID of the SLO that this correction applies to. + * ID of the single SLO that this correction applies to. * * @return sloId */ + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_SLO_ID) - @JsonInclude(value = JsonInclude.Include.ALWAYS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getSloId() { return sloId; } @@ -199,6 +206,29 @@ public void setSloId(String sloId) { this.sloId = sloId; } + public SLOCorrectionCreateRequestAttributes sloQuery(String sloQuery) { + this.sloQuery = sloQuery; + return this; + } + + /** + * Query that matches the SLOs this correction applies to. The query uses the Events search syntax and can + * filter SLOs by SLO tags. + * + * @return sloQuery + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SLO_QUERY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSloQuery() { + return sloQuery; + } + + public void setSloQuery(String sloQuery) { + this.sloQuery = sloQuery; + } + public SLOCorrectionCreateRequestAttributes start(Long start) { this.start = start; return this; @@ -303,6 +333,7 @@ public boolean equals(Object o) { && Objects.equals(this.end, sloCorrectionCreateRequestAttributes.end) && Objects.equals(this.rrule, sloCorrectionCreateRequestAttributes.rrule) && Objects.equals(this.sloId, sloCorrectionCreateRequestAttributes.sloId) + && Objects.equals(this.sloQuery, sloCorrectionCreateRequestAttributes.sloQuery) && Objects.equals(this.start, sloCorrectionCreateRequestAttributes.start) && Objects.equals(this.timezone, sloCorrectionCreateRequestAttributes.timezone) && Objects.equals( @@ -312,7 +343,16 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( - category, description, duration, end, rrule, sloId, start, timezone, additionalProperties); + category, + description, + duration, + end, + rrule, + sloId, + sloQuery, + start, + timezone, + additionalProperties); } @Override @@ -325,6 +365,7 @@ public String toString() { sb.append(" end: ").append(toIndentedString(end)).append("\n"); sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n"); sb.append(" sloId: ").append(toIndentedString(sloId)).append("\n"); + sb.append(" sloQuery: ").append(toIndentedString(sloQuery)).append("\n"); sb.append(" start: ").append(toIndentedString(start)).append("\n"); sb.append(" timezone: ").append(toIndentedString(timezone)).append("\n"); sb.append(" additionalProperties: ") diff --git a/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionResponseAttributes.java b/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionResponseAttributes.java index 3d6a1f987d5..f68a9d21678 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionResponseAttributes.java +++ b/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionResponseAttributes.java @@ -29,6 +29,7 @@ SLOCorrectionResponseAttributes.JSON_PROPERTY_MODIFIER, SLOCorrectionResponseAttributes.JSON_PROPERTY_RRULE, SLOCorrectionResponseAttributes.JSON_PROPERTY_SLO_ID, + SLOCorrectionResponseAttributes.JSON_PROPERTY_SLO_QUERY, SLOCorrectionResponseAttributes.JSON_PROPERTY_START, SLOCorrectionResponseAttributes.JSON_PROPERTY_TIMEZONE }) @@ -65,7 +66,10 @@ public class SLOCorrectionResponseAttributes { private JsonNullable rrule = JsonNullable.undefined(); public static final String JSON_PROPERTY_SLO_ID = "slo_id"; - private String sloId; + private JsonNullable sloId = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_SLO_QUERY = "slo_query"; + private JsonNullable sloQuery = JsonNullable.undefined(); public static final String JSON_PROPERTY_START = "start"; private Long start; @@ -322,26 +326,67 @@ public void setRrule(String rrule) { } public SLOCorrectionResponseAttributes sloId(String sloId) { - this.sloId = sloId; + this.sloId = JsonNullable.of(sloId); return this; } /** - * ID of the SLO that this correction applies to. + * ID of the single SLO that this correction applies to. * * @return sloId */ @jakarta.annotation.Nullable + @JsonIgnore + public String getSloId() { + return sloId.orElse(null); + } + @JsonProperty(JSON_PROPERTY_SLO_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getSloId() { + public JsonNullable getSloId_JsonNullable() { return sloId; } - public void setSloId(String sloId) { + @JsonProperty(JSON_PROPERTY_SLO_ID) + public void setSloId_JsonNullable(JsonNullable sloId) { this.sloId = sloId; } + public void setSloId(String sloId) { + this.sloId = JsonNullable.of(sloId); + } + + public SLOCorrectionResponseAttributes sloQuery(String sloQuery) { + this.sloQuery = JsonNullable.of(sloQuery); + return this; + } + + /** + * Query that matches the SLOs this correction applies to. + * + * @return sloQuery + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getSloQuery() { + return sloQuery.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SLO_QUERY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getSloQuery_JsonNullable() { + return sloQuery; + } + + @JsonProperty(JSON_PROPERTY_SLO_QUERY) + public void setSloQuery_JsonNullable(JsonNullable sloQuery) { + this.sloQuery = sloQuery; + } + + public void setSloQuery(String sloQuery) { + this.sloQuery = JsonNullable.of(sloQuery); + } + public SLOCorrectionResponseAttributes start(Long start) { this.start = start; return this; @@ -451,6 +496,7 @@ public boolean equals(Object o) { && Objects.equals(this.modifier, sloCorrectionResponseAttributes.modifier) && Objects.equals(this.rrule, sloCorrectionResponseAttributes.rrule) && Objects.equals(this.sloId, sloCorrectionResponseAttributes.sloId) + && Objects.equals(this.sloQuery, sloCorrectionResponseAttributes.sloQuery) && Objects.equals(this.start, sloCorrectionResponseAttributes.start) && Objects.equals(this.timezone, sloCorrectionResponseAttributes.timezone) && Objects.equals( @@ -470,6 +516,7 @@ public int hashCode() { modifier, rrule, sloId, + sloQuery, start, timezone, additionalProperties); @@ -489,6 +536,7 @@ public String toString() { sb.append(" modifier: ").append(toIndentedString(modifier)).append("\n"); sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n"); sb.append(" sloId: ").append(toIndentedString(sloId)).append("\n"); + sb.append(" sloQuery: ").append(toIndentedString(sloQuery)).append("\n"); sb.append(" start: ").append(toIndentedString(start)).append("\n"); sb.append(" timezone: ").append(toIndentedString(timezone)).append("\n"); sb.append(" additionalProperties: ") diff --git a/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionUpdateRequestAttributes.java b/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionUpdateRequestAttributes.java index 0f5869054aa..8d2ecc69a4b 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionUpdateRequestAttributes.java +++ b/src/main/java/com/datadog/api/client/v1/model/SLOCorrectionUpdateRequestAttributes.java @@ -23,6 +23,7 @@ SLOCorrectionUpdateRequestAttributes.JSON_PROPERTY_DURATION, SLOCorrectionUpdateRequestAttributes.JSON_PROPERTY_END, SLOCorrectionUpdateRequestAttributes.JSON_PROPERTY_RRULE, + SLOCorrectionUpdateRequestAttributes.JSON_PROPERTY_SLO_QUERY, SLOCorrectionUpdateRequestAttributes.JSON_PROPERTY_START, SLOCorrectionUpdateRequestAttributes.JSON_PROPERTY_TIMEZONE }) @@ -45,6 +46,9 @@ public class SLOCorrectionUpdateRequestAttributes { public static final String JSON_PROPERTY_RRULE = "rrule"; private String rrule; + public static final String JSON_PROPERTY_SLO_QUERY = "slo_query"; + private String sloQuery; + public static final String JSON_PROPERTY_START = "start"; private Long start; @@ -162,6 +166,29 @@ public void setRrule(String rrule) { this.rrule = rrule; } + public SLOCorrectionUpdateRequestAttributes sloQuery(String sloQuery) { + this.sloQuery = sloQuery; + return this; + } + + /** + * Query that matches the SLOs this correction applies to. The query uses the Events search syntax and can + * filter SLOs by SLO tags. + * + * @return sloQuery + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SLO_QUERY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSloQuery() { + return sloQuery; + } + + public void setSloQuery(String sloQuery) { + this.sloQuery = sloQuery; + } + public SLOCorrectionUpdateRequestAttributes start(Long start) { this.start = start; return this; @@ -266,6 +293,7 @@ public boolean equals(Object o) { && Objects.equals(this.duration, sloCorrectionUpdateRequestAttributes.duration) && Objects.equals(this.end, sloCorrectionUpdateRequestAttributes.end) && Objects.equals(this.rrule, sloCorrectionUpdateRequestAttributes.rrule) + && Objects.equals(this.sloQuery, sloCorrectionUpdateRequestAttributes.sloQuery) && Objects.equals(this.start, sloCorrectionUpdateRequestAttributes.start) && Objects.equals(this.timezone, sloCorrectionUpdateRequestAttributes.timezone) && Objects.equals( @@ -275,7 +303,15 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( - category, description, duration, end, rrule, start, timezone, additionalProperties); + category, + description, + duration, + end, + rrule, + sloQuery, + start, + timezone, + additionalProperties); } @Override @@ -287,6 +323,7 @@ public String toString() { sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); sb.append(" end: ").append(toIndentedString(end)).append("\n"); sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n"); + sb.append(" sloQuery: ").append(toIndentedString(sloQuery)).append("\n"); sb.append(" start: ").append(toIndentedString(start)).append("\n"); sb.append(" timezone: ").append(toIndentedString(timezone)).append("\n"); sb.append(" additionalProperties: ") diff --git a/src/test/resources/cassettes/features/v1/Create_an_SLO_correction_with_slo_query_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Create_an_SLO_correction_with_slo_query_returns_OK_response.freeze new file mode 100644 index 00000000000..d4db7da28f6 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_an_SLO_correction_with_slo_query_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-05-27T20:45:22.423Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_an_SLO_correction_with_slo_query_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Create_an_SLO_correction_with_slo_query_returns_OK_response.json new file mode 100644 index 00000000000..cf6e59eff3f --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_an_SLO_correction_with_slo_query_returns_OK_response.json @@ -0,0 +1,57 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"category\":\"Scheduled Maintenance\",\"description\":\"Test-Create_an_SLO_correction_with_slo_query_returns_OK_response-1779914722\",\"end\":1779918322,\"slo_query\":\"env:prod service:checkout\",\"start\":1779914722,\"timezone\":\"UTC\"},\"type\":\"correction\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/slo/correction", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"correction\",\"id\":\"fb3a5c0a-5a0c-11f1-8207-da7ad0902002\",\"attributes\":{\"slo_id\":null,\"start\":1779914722,\"end\":1779918322,\"description\":\"Test-Create_an_SLO_correction_with_slo_query_returns_OK_response-1779914722\",\"category\":\"Scheduled Maintenance\",\"timezone\":\"UTC\",\"created_at\":null,\"modified_at\":null,\"rrule\":null,\"duration\":null,\"slo_query\":\"env:prod service:checkout\",\"creator\":{\"data\":{\"type\":\"users\",\"id\":\"780cfef8-1736-4a4e-a826-b875b1cadcec\",\"attributes\":{\"uuid\":\"780cfef8-1736-4a4e-a826-b875b1cadcec\",\"handle\":\"blaise.vonohlen@datadoghq.com\",\"email\":\"blaise.vonohlen@datadoghq.com\",\"name\":\"Blaise von Ohlen\",\"icon\":\"https://secure.gravatar.com/avatar/c78d8282d57321884e8f77172229634f?s=48&d=retro\"}}},\"modifier\":null}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "6b6ee136-ac79-cb1c-7489-ca3bc2bd665c" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/slo/correction/fb3a5c0a-5a0c-11f1-8207-da7ad0902002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "2b604246-6217-f380-2076-29a3b510cf83" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Update_an_SLO_correction_with_slo_query_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Update_an_SLO_correction_with_slo_query_returns_OK_response.freeze new file mode 100644 index 00000000000..2772dc4740e --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Update_an_SLO_correction_with_slo_query_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-06-03T15:43:01.600Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Update_an_SLO_correction_with_slo_query_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Update_an_SLO_correction_with_slo_query_returns_OK_response.json new file mode 100644 index 00000000000..4a86a1f1ab4 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Update_an_SLO_correction_with_slo_query_returns_OK_response.json @@ -0,0 +1,87 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"category\":\"Other\",\"description\":\"Test Correction\",\"end\":1780504981,\"slo_query\":\"env:prod service:checkout\",\"start\":1780501381,\"timezone\":\"UTC\"},\"type\":\"correction\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/slo/correction", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"correction\",\"id\":\"e74cc4de-5f62-11f1-a69d-da7ad0902002\",\"attributes\":{\"slo_id\":null,\"start\":1780501381,\"end\":1780504981,\"description\":\"Test Correction\",\"category\":\"Other\",\"timezone\":\"UTC\",\"created_at\":null,\"modified_at\":null,\"rrule\":null,\"duration\":null,\"slo_query\":\"env:prod service:checkout\",\"creator\":{\"data\":{\"type\":\"users\",\"id\":\"780cfef8-1736-4a4e-a826-b875b1cadcec\",\"attributes\":{\"uuid\":\"780cfef8-1736-4a4e-a826-b875b1cadcec\",\"handle\":\"blaise.vonohlen@datadoghq.com\",\"email\":\"blaise.vonohlen@datadoghq.com\",\"name\":\"Blaise von Ohlen\",\"icon\":\"https://secure.gravatar.com/avatar/c78d8282d57321884e8f77172229634f?s=48&d=retro\"}}},\"modifier\":null}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "0e59d499-3924-ea2d-ab20-9aa3a6a51cf4" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"category\":\"Scheduled Maintenance\",\"description\":\"Test-Update_an_SLO_correction_with_slo_query_returns_OK_response-1780501381\",\"end\":1780504981,\"slo_query\":\"env:staging service:checkout\",\"start\":1780501381,\"timezone\":\"UTC\"},\"type\":\"correction\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v1/slo/correction/e74cc4de-5f62-11f1-a69d-da7ad0902002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"correction\",\"id\":\"e74cc4de-5f62-11f1-a69d-da7ad0902002\",\"attributes\":{\"slo_id\":null,\"start\":1780501381,\"end\":1780504981,\"description\":\"Test-Update_an_SLO_correction_with_slo_query_returns_OK_response-1780501381\",\"category\":\"Scheduled Maintenance\",\"timezone\":\"UTC\",\"created_at\":1780501381,\"modified_at\":1780501381,\"rrule\":null,\"duration\":null,\"slo_query\":\"env:staging service:checkout\",\"creator\":{\"data\":{\"type\":\"users\",\"id\":\"780cfef8-1736-4a4e-a826-b875b1cadcec\",\"attributes\":{\"uuid\":\"780cfef8-1736-4a4e-a826-b875b1cadcec\",\"handle\":\"blaise.vonohlen@datadoghq.com\",\"email\":\"blaise.vonohlen@datadoghq.com\",\"name\":\"Blaise von Ohlen\",\"icon\":\"https://secure.gravatar.com/avatar/c78d8282d57321884e8f77172229634f?s=48&d=retro\"}}},\"modifier\":{\"data\":{\"type\":\"users\",\"id\":\"780cfef8-1736-4a4e-a826-b875b1cadcec\",\"attributes\":{\"uuid\":\"780cfef8-1736-4a4e-a826-b875b1cadcec\",\"handle\":\"blaise.vonohlen@datadoghq.com\",\"email\":\"blaise.vonohlen@datadoghq.com\",\"name\":\"Blaise von Ohlen\",\"icon\":\"https://secure.gravatar.com/avatar/c78d8282d57321884e8f77172229634f?s=48&d=retro\"}}}}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "2b335604-d2dd-6758-8215-f462d86db548" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/slo/correction/e74cc4de-5f62-11f1-a69d-da7ad0902002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "fb2a7800-ba02-4b94-9310-f03450fabec7" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v1/api/given.json b/src/test/resources/com/datadog/api/client/v1/api/given.json index 4415a28bc00..3c1540f6faa 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/given.json +++ b/src/test/resources/com/datadog/api/client/v1/api/given.json @@ -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": [ { diff --git a/src/test/resources/com/datadog/api/client/v1/api/service_level_objective_corrections.feature b/src/test/resources/com/datadog/api/client/v1/api/service_level_objective_corrections.feature index d301d8e6764..5b89ea6df2d 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/service_level_objective_corrections.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/service_level_objective_corrections.feature @@ -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 @@ -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 @@ -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"