diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index a38d274f9b8..3e86f3a82c2 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -11900,6 +11900,60 @@ components: example: UTC type: string type: object + SLOCountDefinition: + description: 'A count-based (metric) SLI specification, composed of three parts: + the good events formula, the total events formula, + + and the underlying queries.' + example: + good_events_formula: query1 - query2 + queries: + - data_source: metrics + name: query1 + query: sum:trace.servlet.request.hits{*} by {env}.as_count() + - data_source: metrics + name: query2 + query: sum:trace.servlet.request.errors{*} by {env}.as_count() + total_events_formula: query1 + properties: + good_events_formula: + $ref: '#/components/schemas/SLOFormula' + queries: + example: + - data_source: metrics + name: query1 + query: sum:trace.servlet.request.hits{*} by {env}.as_count() + items: + $ref: '#/components/schemas/SLODataSourceQueryDefinition' + minItems: 1 + type: array + total_events_formula: + $ref: '#/components/schemas/SLOFormula' + required: + - good_events_formula + - total_events_formula + - queries + type: object + SLOCountSpec: + additionalProperties: false + description: A metric SLI specification. + example: + count: + good_events_formula: query1 - query2 + queries: + - data_source: metrics + name: query1 + query: sum:trace.servlet.request.hits{*} by {env}.as_count() + - data_source: metrics + name: query2 + query: sum:trace.servlet.request.errors{*} by {env}.as_count() + total_events_formula: query1 + properties: + count: + $ref: '#/components/schemas/SLOCountDefinition' + required: + - count + type: object SLOCreator: description: The creator of the SLO nullable: true @@ -12747,8 +12801,12 @@ components: type: string query: $ref: '#/components/schemas/ServiceLevelObjectiveQuery' + description: The metric query used to define a count-based SLO as the ratio + of good events to total events. sli_specification: $ref: '#/components/schemas/SLOSliSpec' + description: A generic SLI specification. This is currently used for time-slice + and count-based (metric) SLOs only. tags: description: 'A list of tags associated with this service level objective. @@ -12804,10 +12862,11 @@ components: type: number type: object SLOSliSpec: - description: A generic SLI specification. This is currently used for time-slice - SLOs only. + description: A generic SLI specification. This is used for time-slice and count-based + (metric) SLOs only. oneOf: - $ref: '#/components/schemas/SLOTimeSliceSpec' + - $ref: '#/components/schemas/SLOCountSpec' SLOState: description: State of the SLO. enum: @@ -13959,7 +14018,8 @@ components: - type type: object ServiceLevelObjectiveQuery: - description: 'A metric-based SLO. **Required if type is `metric`**. Note that + description: 'A count-based (metric) SLO query. This field is superseded by + `sli_specification` but is retained for backwards compatibility. Note that Datadog only allows the sum by aggregator to be used because this will sum up all request counts instead of averaging diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index e301432aca7..050808b8c45 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -24023,22 +24023,6 @@ components: type: string flaky_state: $ref: '#/components/schemas/FlakyTestAttributesFlakyState' - history: - description: 'Chronological history of status changes for this flaky test, - ordered from most recent to oldest. - - Includes state transitions like new -> quarantined -> fixed, along with - the associated commit SHA when available.' - example: - - commit_sha: abc123def456 - status: quarantined - timestamp: 1704067200000 - - commit_sha: '' - status: new - timestamp: 1703980800000 - items: - $ref: '#/components/schemas/FlakyTestHistory' - type: array last_flaked_branch: description: The branch name where the test exhibited flakiness for the last time. @@ -24123,29 +24107,6 @@ components: - FIXED - QUARANTINED - DISABLED - FlakyTestHistory: - description: A single history entry representing a status change for a flaky - test. - properties: - commit_sha: - description: The commit SHA associated with this status change. Will be - an empty string if the commit SHA is not available. - example: abc123def456 - type: string - status: - description: The test status at this point in history. - example: quarantined - type: string - timestamp: - description: Unix timestamp in milliseconds when this status change occurred. - example: 1704067200000 - format: int64 - type: integer - required: - - status - - commit_sha - - timestamp - type: object FlakyTestPipelineStats: description: CI pipeline related statistics for the flaky test. This information is only available if test runs are associated with CI pipeline events from @@ -24292,17 +24253,6 @@ components: properties: filter: $ref: '#/components/schemas/FlakyTestsSearchFilter' - include_history: - default: false - description: 'Whether to include the status change history for each flaky - test in the response. - - When set to true, each test will include a `history` array with chronological - status changes. - - Defaults to false.' - example: true - type: boolean page: $ref: '#/components/schemas/FlakyTestsSearchPageOptions' sort: @@ -101135,33 +101085,8 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' post: - description: 'List endpoint returning flaky tests from Flaky Test Management. + description: List endpoint returning flaky tests from Flaky Test Management. Results are paginated. - - - The response includes comprehensive test information including: - - - Test identification and metadata (module, suite, name) - - - Flaky state and categorization - - - First and last flake occurrences (timestamp, branch, commit SHA) - - - Test execution statistics from the last 7 days (failure rate) - - - Pipeline impact metrics (failed pipelines count, total lost time) - - - Complete status change history (optional, ordered from most recent to oldest) - - - Set `include_history` to `true` in the request to receive the status change - history for each test. - - History is disabled by default for better performance. - - - Results support filtering by various facets including service, environment, - repository, branch, and test state.' operationId: SearchFlakyTests requestBody: content: diff --git a/examples/v1/service-level-objectives/CreateSLO_512760759.java b/examples/v1/service-level-objectives/CreateSLO_512760759.java new file mode 100644 index 00000000000..ccbd3e89353 --- /dev/null +++ b/examples/v1/service-level-objectives/CreateSLO_512760759.java @@ -0,0 +1,76 @@ +// Create a new metric SLO object using sli_specification returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.ServiceLevelObjectivesApi; +import com.datadog.api.client.v1.model.FormulaAndFunctionMetricDataSource; +import com.datadog.api.client.v1.model.FormulaAndFunctionMetricQueryDefinition; +import com.datadog.api.client.v1.model.SLOCountDefinition; +import com.datadog.api.client.v1.model.SLOCountSpec; +import com.datadog.api.client.v1.model.SLODataSourceQueryDefinition; +import com.datadog.api.client.v1.model.SLOFormula; +import com.datadog.api.client.v1.model.SLOListResponse; +import com.datadog.api.client.v1.model.SLOSliSpec; +import com.datadog.api.client.v1.model.SLOThreshold; +import com.datadog.api.client.v1.model.SLOTimeframe; +import com.datadog.api.client.v1.model.SLOType; +import com.datadog.api.client.v1.model.ServiceLevelObjectiveRequest; +import java.util.Arrays; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient); + + ServiceLevelObjectiveRequest body = + new ServiceLevelObjectiveRequest() + .type(SLOType.METRIC) + .description("Metric SLO using sli_specification") + .name("Example-Service-Level-Objective") + .sliSpecification( + new SLOSliSpec( + new SLOCountSpec() + .count( + new SLOCountDefinition() + .goodEventsFormula(new SLOFormula().formula("query1 - query2")) + .totalEventsFormula(new SLOFormula().formula("query1")) + .queries( + Arrays.asList( + new SLODataSourceQueryDefinition( + new FormulaAndFunctionMetricQueryDefinition() + .dataSource( + FormulaAndFunctionMetricDataSource.METRICS) + .name("query1") + .query("sum:httpservice.hits{*}.as_count()")), + new SLODataSourceQueryDefinition( + new FormulaAndFunctionMetricQueryDefinition() + .dataSource( + FormulaAndFunctionMetricDataSource.METRICS) + .name("query2") + .query("sum:httpservice.errors{*}.as_count()"))))))) + .tags(Arrays.asList("env:prod", "type:count")) + .thresholds( + Collections.singletonList( + new SLOThreshold() + .target(99.0) + .targetDisplay("99.0") + .timeframe(SLOTimeframe.SEVEN_DAYS) + .warning(99.5) + .warningDisplay("99.5"))) + .timeframe(SLOTimeframe.SEVEN_DAYS) + .targetThreshold(99.0) + .warningThreshold(99.5); + + try { + SLOListResponse result = apiInstance.createSLO(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ServiceLevelObjectivesApi#createSLO"); + 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/v2/test-optimization/SearchFlakyTests.java b/examples/v2/test-optimization/SearchFlakyTests.java index 58650a27895..bd908ce88e3 100644 --- a/examples/v2/test-optimization/SearchFlakyTests.java +++ b/examples/v2/test-optimization/SearchFlakyTests.java @@ -31,7 +31,6 @@ public static void main(String[] args) { """ flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist" """)) - .includeHistory(true) .page( new FlakyTestsSearchPageOptions() .cursor( diff --git a/examples/v2/test-optimization/SearchFlakyTests_1224086727.java b/examples/v2/test-optimization/SearchFlakyTests_1224086727.java index 164ee6fe99f..7c851377965 100644 --- a/examples/v2/test-optimization/SearchFlakyTests_1224086727.java +++ b/examples/v2/test-optimization/SearchFlakyTests_1224086727.java @@ -31,7 +31,6 @@ public static void main(String[] args) { """ flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist" """)) - .includeHistory(true) .page( new FlakyTestsSearchPageOptions() .cursor( diff --git a/examples/v2/test-optimization/SearchFlakyTests_209064879.java b/examples/v2/test-optimization/SearchFlakyTests_209064879.java deleted file mode 100644 index f1b3d1462bc..00000000000 --- a/examples/v2/test-optimization/SearchFlakyTests_209064879.java +++ /dev/null @@ -1,51 +0,0 @@ -// Search flaky tests returns "OK" response with history - -import com.datadog.api.client.ApiClient; -import com.datadog.api.client.ApiException; -import com.datadog.api.client.v2.api.TestOptimizationApi; -import com.datadog.api.client.v2.api.TestOptimizationApi.SearchFlakyTestsOptionalParameters; -import com.datadog.api.client.v2.model.FlakyTestsSearchFilter; -import com.datadog.api.client.v2.model.FlakyTestsSearchPageOptions; -import com.datadog.api.client.v2.model.FlakyTestsSearchRequest; -import com.datadog.api.client.v2.model.FlakyTestsSearchRequestAttributes; -import com.datadog.api.client.v2.model.FlakyTestsSearchRequestData; -import com.datadog.api.client.v2.model.FlakyTestsSearchRequestDataType; -import com.datadog.api.client.v2.model.FlakyTestsSearchResponse; -import com.datadog.api.client.v2.model.FlakyTestsSearchSort; - -public class Example { - public static void main(String[] args) { - ApiClient defaultClient = ApiClient.getDefaultApiClient(); - defaultClient.setUnstableOperationEnabled("v2.searchFlakyTests", true); - TestOptimizationApi apiInstance = new TestOptimizationApi(defaultClient); - - FlakyTestsSearchRequest body = - new FlakyTestsSearchRequest() - .data( - new FlakyTestsSearchRequestData() - .attributes( - new FlakyTestsSearchRequestAttributes() - .filter( - new FlakyTestsSearchFilter() - .query( - """ -flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist" -""")) - .page(new FlakyTestsSearchPageOptions().limit(10L)) - .sort(FlakyTestsSearchSort.FQN_ASCENDING) - .includeHistory(true)) - .type(FlakyTestsSearchRequestDataType.SEARCH_FLAKY_TESTS_REQUEST)); - - try { - FlakyTestsSearchResponse result = - apiInstance.searchFlakyTests(new SearchFlakyTestsOptionalParameters().body(body)); - System.out.println(result); - } catch (ApiException e) { - System.err.println("Exception when calling TestOptimizationApi#searchFlakyTests"); - 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/model/SLOCountDefinition.java b/src/main/java/com/datadog/api/client/v1/model/SLOCountDefinition.java new file mode 100644 index 00000000000..d63c83045ef --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/SLOCountDefinition.java @@ -0,0 +1,222 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A count-based (metric) SLI specification, composed of three parts: the good events formula, the + * total events formula, and the underlying queries. + */ +@JsonPropertyOrder({ + SLOCountDefinition.JSON_PROPERTY_GOOD_EVENTS_FORMULA, + SLOCountDefinition.JSON_PROPERTY_QUERIES, + SLOCountDefinition.JSON_PROPERTY_TOTAL_EVENTS_FORMULA +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SLOCountDefinition { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_GOOD_EVENTS_FORMULA = "good_events_formula"; + private SLOFormula goodEventsFormula; + + public static final String JSON_PROPERTY_QUERIES = "queries"; + private List queries = new ArrayList<>(); + + public static final String JSON_PROPERTY_TOTAL_EVENTS_FORMULA = "total_events_formula"; + private SLOFormula totalEventsFormula; + + public SLOCountDefinition() {} + + @JsonCreator + public SLOCountDefinition( + @JsonProperty(required = true, value = JSON_PROPERTY_GOOD_EVENTS_FORMULA) + SLOFormula goodEventsFormula, + @JsonProperty(required = true, value = JSON_PROPERTY_QUERIES) + List queries, + @JsonProperty(required = true, value = JSON_PROPERTY_TOTAL_EVENTS_FORMULA) + SLOFormula totalEventsFormula) { + this.goodEventsFormula = goodEventsFormula; + this.unparsed |= goodEventsFormula.unparsed; + this.queries = queries; + this.totalEventsFormula = totalEventsFormula; + this.unparsed |= totalEventsFormula.unparsed; + } + + public SLOCountDefinition goodEventsFormula(SLOFormula goodEventsFormula) { + this.goodEventsFormula = goodEventsFormula; + this.unparsed |= goodEventsFormula.unparsed; + return this; + } + + /** + * A formula that specifies how to combine the results of multiple queries. + * + * @return goodEventsFormula + */ + @JsonProperty(JSON_PROPERTY_GOOD_EVENTS_FORMULA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public SLOFormula getGoodEventsFormula() { + return goodEventsFormula; + } + + public void setGoodEventsFormula(SLOFormula goodEventsFormula) { + this.goodEventsFormula = goodEventsFormula; + } + + public SLOCountDefinition queries(List queries) { + this.queries = queries; + for (SLODataSourceQueryDefinition item : queries) { + this.unparsed |= item.unparsed; + } + return this; + } + + public SLOCountDefinition addQueriesItem(SLODataSourceQueryDefinition queriesItem) { + this.queries.add(queriesItem); + this.unparsed |= queriesItem.unparsed; + return this; + } + + /** + * Getqueries + * + * @return queries + */ + @JsonProperty(JSON_PROPERTY_QUERIES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getQueries() { + return queries; + } + + public void setQueries(List queries) { + this.queries = queries; + } + + public SLOCountDefinition totalEventsFormula(SLOFormula totalEventsFormula) { + this.totalEventsFormula = totalEventsFormula; + this.unparsed |= totalEventsFormula.unparsed; + return this; + } + + /** + * A formula that specifies how to combine the results of multiple queries. + * + * @return totalEventsFormula + */ + @JsonProperty(JSON_PROPERTY_TOTAL_EVENTS_FORMULA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public SLOFormula getTotalEventsFormula() { + return totalEventsFormula; + } + + public void setTotalEventsFormula(SLOFormula totalEventsFormula) { + this.totalEventsFormula = totalEventsFormula; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SLOCountDefinition + */ + @JsonAnySetter + public SLOCountDefinition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SLOCountDefinition object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SLOCountDefinition sloCountDefinition = (SLOCountDefinition) o; + return Objects.equals(this.goodEventsFormula, sloCountDefinition.goodEventsFormula) + && Objects.equals(this.queries, sloCountDefinition.queries) + && Objects.equals(this.totalEventsFormula, sloCountDefinition.totalEventsFormula) + && Objects.equals(this.additionalProperties, sloCountDefinition.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(goodEventsFormula, queries, totalEventsFormula, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SLOCountDefinition {\n"); + sb.append(" goodEventsFormula: ").append(toIndentedString(goodEventsFormula)).append("\n"); + sb.append(" queries: ").append(toIndentedString(queries)).append("\n"); + sb.append(" totalEventsFormula: ").append(toIndentedString(totalEventsFormula)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/SLOCountSpec.java b/src/main/java/com/datadog/api/client/v1/model/SLOCountSpec.java new file mode 100644 index 00000000000..d11603840c5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/SLOCountSpec.java @@ -0,0 +1,92 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** A metric SLI specification. */ +@JsonPropertyOrder({SLOCountSpec.JSON_PROPERTY_COUNT}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SLOCountSpec { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_COUNT = "count"; + private SLOCountDefinition count; + + public SLOCountSpec() {} + + @JsonCreator + public SLOCountSpec( + @JsonProperty(required = true, value = JSON_PROPERTY_COUNT) SLOCountDefinition count) { + this.count = count; + this.unparsed |= count.unparsed; + } + + public SLOCountSpec count(SLOCountDefinition count) { + this.count = count; + this.unparsed |= count.unparsed; + return this; + } + + /** + * A count-based (metric) SLI specification, composed of three parts: the good events formula, the + * total events formula, and the underlying queries. + * + * @return count + */ + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public SLOCountDefinition getCount() { + return count; + } + + public void setCount(SLOCountDefinition count) { + this.count = count; + } + + /** Return true if this SLOCountSpec object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SLOCountSpec sloCountSpec = (SLOCountSpec) o; + return Objects.equals(this.count, sloCountSpec.count); + } + + @Override + public int hashCode() { + return Objects.hash(count); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SLOCountSpec {\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/SLOResponseData.java b/src/main/java/com/datadog/api/client/v1/model/SLOResponseData.java index e55f6a99d45..ab9ba44532a 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SLOResponseData.java +++ b/src/main/java/com/datadog/api/client/v1/model/SLOResponseData.java @@ -343,9 +343,10 @@ public SLOResponseData query(ServiceLevelObjectiveQuery query) { } /** - * A metric-based SLO. Required if type is metric. Note that Datadog - * only allows the sum by aggregator to be used because this will sum up all request counts - * instead of averaging them, or taking the max or min of all of those requests. + * A count-based (metric) SLO query. This field is superseded by sli_specification + * but is retained for backwards compatibility. Note that Datadog only allows the sum by + * aggregator to be used because this will sum up all request counts instead of averaging them, or + * taking the max or min of all of those requests. * * @return query */ @@ -367,7 +368,7 @@ public SLOResponseData sliSpecification(SLOSliSpec sliSpecification) { } /** - * A generic SLI specification. This is currently used for time-slice SLOs only. + * A generic SLI specification. This is used for time-slice and count-based (metric) SLOs only. * * @return sliSpecification */ diff --git a/src/main/java/com/datadog/api/client/v1/model/SLOSliSpec.java b/src/main/java/com/datadog/api/client/v1/model/SLOSliSpec.java index 36a3066f9f6..c45083515b6 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SLOSliSpec.java +++ b/src/main/java/com/datadog/api/client/v1/model/SLOSliSpec.java @@ -121,6 +121,48 @@ public SLOSliSpec deserialize(JsonParser jp, DeserializationContext ctxt) log.log(Level.FINER, "Input data does not match schema 'SLOTimeSliceSpec'", e); } + // deserialize SLOCountSpec + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (SLOCountSpec.class.equals(Integer.class) + || SLOCountSpec.class.equals(Long.class) + || SLOCountSpec.class.equals(Float.class) + || SLOCountSpec.class.equals(Double.class) + || SLOCountSpec.class.equals(Boolean.class) + || SLOCountSpec.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((SLOCountSpec.class.equals(Integer.class) || SLOCountSpec.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((SLOCountSpec.class.equals(Float.class) || SLOCountSpec.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (SLOCountSpec.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (SLOCountSpec.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(SLOCountSpec.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((SLOCountSpec) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'SLOCountSpec'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'SLOCountSpec'", e); + } + SLOSliSpec ret = new SLOSliSpec(); if (match == 1) { ret.setActualInstance(deserialized); @@ -154,8 +196,14 @@ public SLOSliSpec(SLOTimeSliceSpec o) { setActualInstance(o); } + public SLOSliSpec(SLOCountSpec o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + static { schemas.put("SLOTimeSliceSpec", new GenericType() {}); + schemas.put("SLOCountSpec", new GenericType() {}); JSON.registerDescendants(SLOSliSpec.class, Collections.unmodifiableMap(schemas)); } @@ -166,7 +214,7 @@ public Map getSchemas() { /** * Set the instance that matches the oneOf child schema, check the instance parameter is valid - * against the oneOf child schemas: SLOTimeSliceSpec + * against the oneOf child schemas: SLOTimeSliceSpec, SLOCountSpec * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -177,18 +225,22 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf(SLOCountSpec.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - throw new RuntimeException("Invalid instance type. Must be SLOTimeSliceSpec"); + throw new RuntimeException("Invalid instance type. Must be SLOTimeSliceSpec, SLOCountSpec"); } /** - * Get the actual instance, which can be the following: SLOTimeSliceSpec + * Get the actual instance, which can be the following: SLOTimeSliceSpec, SLOCountSpec * - * @return The actual instance (SLOTimeSliceSpec) + * @return The actual instance (SLOTimeSliceSpec, SLOCountSpec) */ @Override public Object getActualInstance() { @@ -205,4 +257,15 @@ public Object getActualInstance() { public SLOTimeSliceSpec getSLOTimeSliceSpec() throws ClassCastException { return (SLOTimeSliceSpec) super.getActualInstance(); } + + /** + * Get the actual instance of `SLOCountSpec`. If the actual instance is not `SLOCountSpec`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `SLOCountSpec` + * @throws ClassCastException if the instance is not `SLOCountSpec` + */ + public SLOCountSpec getSLOCountSpec() throws ClassCastException { + return (SLOCountSpec) super.getActualInstance(); + } } diff --git a/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjective.java b/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjective.java index a0e4f9b0371..b129ccbaca5 100644 --- a/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjective.java +++ b/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjective.java @@ -324,9 +324,10 @@ public ServiceLevelObjective query(ServiceLevelObjectiveQuery query) { } /** - * A metric-based SLO. Required if type is metric. Note that Datadog - * only allows the sum by aggregator to be used because this will sum up all request counts - * instead of averaging them, or taking the max or min of all of those requests. + * A count-based (metric) SLO query. This field is superseded by sli_specification + * but is retained for backwards compatibility. Note that Datadog only allows the sum by + * aggregator to be used because this will sum up all request counts instead of averaging them, or + * taking the max or min of all of those requests. * * @return query */ @@ -348,7 +349,7 @@ public ServiceLevelObjective sliSpecification(SLOSliSpec sliSpecification) { } /** - * A generic SLI specification. This is currently used for time-slice SLOs only. + * A generic SLI specification. This is used for time-slice and count-based (metric) SLOs only. * * @return sliSpecification */ diff --git a/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjectiveQuery.java b/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjectiveQuery.java index aee83319b41..0bc3a61656a 100644 --- a/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjectiveQuery.java +++ b/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjectiveQuery.java @@ -18,9 +18,10 @@ import java.util.Objects; /** - * A metric-based SLO. Required if type is metric. Note that Datadog - * only allows the sum by aggregator to be used because this will sum up all request counts instead - * of averaging them, or taking the max or min of all of those requests. + * A count-based (metric) SLO query. This field is superseded by sli_specification but + * is retained for backwards compatibility. Note that Datadog only allows the sum by aggregator to + * be used because this will sum up all request counts instead of averaging them, or taking the max + * or min of all of those requests. */ @JsonPropertyOrder({ ServiceLevelObjectiveQuery.JSON_PROPERTY_DENOMINATOR, diff --git a/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjectiveRequest.java b/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjectiveRequest.java index dfb2e482c73..68208b7f6b9 100644 --- a/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjectiveRequest.java +++ b/src/main/java/com/datadog/api/client/v1/model/ServiceLevelObjectiveRequest.java @@ -217,9 +217,10 @@ public ServiceLevelObjectiveRequest query(ServiceLevelObjectiveQuery query) { } /** - * A metric-based SLO. Required if type is metric. Note that Datadog - * only allows the sum by aggregator to be used because this will sum up all request counts - * instead of averaging them, or taking the max or min of all of those requests. + * A count-based (metric) SLO query. This field is superseded by sli_specification + * but is retained for backwards compatibility. Note that Datadog only allows the sum by + * aggregator to be used because this will sum up all request counts instead of averaging them, or + * taking the max or min of all of those requests. * * @return query */ @@ -241,7 +242,7 @@ public ServiceLevelObjectiveRequest sliSpecification(SLOSliSpec sliSpecification } /** - * A generic SLI specification. This is currently used for time-slice SLOs only. + * A generic SLI specification. This is used for time-slice and count-based (metric) SLOs only. * * @return sliSpecification */ diff --git a/src/main/java/com/datadog/api/client/v2/api/TestOptimizationApi.java b/src/main/java/com/datadog/api/client/v2/api/TestOptimizationApi.java index 02e6e7a08f4..9cbe934357a 100644 --- a/src/main/java/com/datadog/api/client/v2/api/TestOptimizationApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/TestOptimizationApi.java @@ -197,18 +197,6 @@ public PaginationIterable searchFlakyTestsWithPagination( /** * List endpoint returning flaky tests from Flaky Test Management. Results are paginated. * - *

The response includes comprehensive test information including: - Test identification and - * metadata (module, suite, name) - Flaky state and categorization - First and last flake - * occurrences (timestamp, branch, commit SHA) - Test execution statistics from the last 7 days - * (failure rate) - Pipeline impact metrics (failed pipelines count, total lost time) - Complete - * status change history (optional, ordered from most recent to oldest) - * - *

Set include_history to true in the request to receive the status - * change history for each test. History is disabled by default for better performance. - * - *

Results support filtering by various facets including service, environment, repository, - * branch, and test state. - * * @param parameters Optional parameters for the request. * @return ApiResponse<FlakyTestsSearchResponse> * @throws ApiException if fails to make API call diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestAttributes.java index 5989264cb10..18296e02107 100644 --- a/src/main/java/com/datadog/api/client/v2/model/FlakyTestAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestAttributes.java @@ -29,7 +29,6 @@ FlakyTestAttributes.JSON_PROPERTY_FIRST_FLAKED_TS, FlakyTestAttributes.JSON_PROPERTY_FLAKY_CATEGORY, FlakyTestAttributes.JSON_PROPERTY_FLAKY_STATE, - FlakyTestAttributes.JSON_PROPERTY_HISTORY, FlakyTestAttributes.JSON_PROPERTY_LAST_FLAKED_BRANCH, FlakyTestAttributes.JSON_PROPERTY_LAST_FLAKED_SHA, FlakyTestAttributes.JSON_PROPERTY_LAST_FLAKED_TS, @@ -69,9 +68,6 @@ public class FlakyTestAttributes { public static final String JSON_PROPERTY_FLAKY_STATE = "flaky_state"; private FlakyTestAttributesFlakyState flakyState; - public static final String JSON_PROPERTY_HISTORY = "history"; - private List history = null; - public static final String JSON_PROPERTY_LAST_FLAKED_BRANCH = "last_flaked_branch"; private String lastFlakedBranch; @@ -306,41 +302,6 @@ public void setFlakyState(FlakyTestAttributesFlakyState flakyState) { this.flakyState = flakyState; } - public FlakyTestAttributes history(List history) { - this.history = history; - for (FlakyTestHistory item : history) { - this.unparsed |= item.unparsed; - } - return this; - } - - public FlakyTestAttributes addHistoryItem(FlakyTestHistory historyItem) { - if (this.history == null) { - this.history = new ArrayList<>(); - } - this.history.add(historyItem); - this.unparsed |= historyItem.unparsed; - return this; - } - - /** - * Chronological history of status changes for this flaky test, ordered from most recent to - * oldest. Includes state transitions like new -> quarantined -> fixed, along with the - * associated commit SHA when available. - * - * @return history - */ - @jakarta.annotation.Nullable - @JsonProperty(JSON_PROPERTY_HISTORY) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public List getHistory() { - return history; - } - - public void setHistory(List history) { - this.history = history; - } - public FlakyTestAttributes lastFlakedBranch(String lastFlakedBranch) { this.lastFlakedBranch = lastFlakedBranch; return this; @@ -650,7 +611,6 @@ public boolean equals(Object o) { && Objects.equals(this.firstFlakedTs, flakyTestAttributes.firstFlakedTs) && Objects.equals(this.flakyCategory, flakyTestAttributes.flakyCategory) && Objects.equals(this.flakyState, flakyTestAttributes.flakyState) - && Objects.equals(this.history, flakyTestAttributes.history) && Objects.equals(this.lastFlakedBranch, flakyTestAttributes.lastFlakedBranch) && Objects.equals(this.lastFlakedSha, flakyTestAttributes.lastFlakedSha) && Objects.equals(this.lastFlakedTs, flakyTestAttributes.lastFlakedTs) @@ -675,7 +635,6 @@ public int hashCode() { firstFlakedTs, flakyCategory, flakyState, - history, lastFlakedBranch, lastFlakedSha, lastFlakedTs, @@ -701,7 +660,6 @@ public String toString() { sb.append(" firstFlakedTs: ").append(toIndentedString(firstFlakedTs)).append("\n"); sb.append(" flakyCategory: ").append(toIndentedString(flakyCategory)).append("\n"); sb.append(" flakyState: ").append(toIndentedString(flakyState)).append("\n"); - sb.append(" history: ").append(toIndentedString(history)).append("\n"); sb.append(" lastFlakedBranch: ").append(toIndentedString(lastFlakedBranch)).append("\n"); sb.append(" lastFlakedSha: ").append(toIndentedString(lastFlakedSha)).append("\n"); sb.append(" lastFlakedTs: ").append(toIndentedString(lastFlakedTs)).append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestHistory.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestHistory.java deleted file mode 100644 index e99e13440fa..00000000000 --- a/src/main/java/com/datadog/api/client/v2/model/FlakyTestHistory.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. - * This product includes software developed at Datadog (https://www.datadoghq.com/). - * Copyright 2019-Present Datadog, Inc. - */ - -package com.datadog.api.client.v2.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** A single history entry representing a status change for a flaky test. */ -@JsonPropertyOrder({ - FlakyTestHistory.JSON_PROPERTY_COMMIT_SHA, - FlakyTestHistory.JSON_PROPERTY_STATUS, - FlakyTestHistory.JSON_PROPERTY_TIMESTAMP -}) -@jakarta.annotation.Generated( - value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") -public class FlakyTestHistory { - @JsonIgnore public boolean unparsed = false; - public static final String JSON_PROPERTY_COMMIT_SHA = "commit_sha"; - private String commitSha; - - public static final String JSON_PROPERTY_STATUS = "status"; - private String status; - - public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; - private Long timestamp; - - public FlakyTestHistory() {} - - @JsonCreator - public FlakyTestHistory( - @JsonProperty(required = true, value = JSON_PROPERTY_COMMIT_SHA) String commitSha, - @JsonProperty(required = true, value = JSON_PROPERTY_STATUS) String status, - @JsonProperty(required = true, value = JSON_PROPERTY_TIMESTAMP) Long timestamp) { - this.commitSha = commitSha; - this.status = status; - this.timestamp = timestamp; - } - - public FlakyTestHistory commitSha(String commitSha) { - this.commitSha = commitSha; - return this; - } - - /** - * The commit SHA associated with this status change. Will be an empty string if the commit SHA is - * not available. - * - * @return commitSha - */ - @JsonProperty(JSON_PROPERTY_COMMIT_SHA) - @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getCommitSha() { - return commitSha; - } - - public void setCommitSha(String commitSha) { - this.commitSha = commitSha; - } - - public FlakyTestHistory status(String status) { - this.status = status; - return this; - } - - /** - * The test status at this point in history. - * - * @return status - */ - @JsonProperty(JSON_PROPERTY_STATUS) - @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public FlakyTestHistory timestamp(Long timestamp) { - this.timestamp = timestamp; - return this; - } - - /** - * Unix timestamp in milliseconds when this status change occurred. - * - * @return timestamp - */ - @JsonProperty(JSON_PROPERTY_TIMESTAMP) - @JsonInclude(value = JsonInclude.Include.ALWAYS) - public Long getTimestamp() { - return timestamp; - } - - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - /** - * A container for additional, undeclared properties. This is a holder for any undeclared - * properties as specified with the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. If the property - * does not already exist, create it otherwise replace it. - * - * @param key The arbitrary key to set - * @param value The associated value - * @return FlakyTestHistory - */ - @JsonAnySetter - public FlakyTestHistory putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return The additional properties - */ - @JsonAnyGetter - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key The arbitrary key to get - * @return The specific additional property for the given key - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } - - /** Return true if this FlakyTestHistory object is equal to o. */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FlakyTestHistory flakyTestHistory = (FlakyTestHistory) o; - return Objects.equals(this.commitSha, flakyTestHistory.commitSha) - && Objects.equals(this.status, flakyTestHistory.status) - && Objects.equals(this.timestamp, flakyTestHistory.timestamp) - && Objects.equals(this.additionalProperties, flakyTestHistory.additionalProperties); - } - - @Override - public int hashCode() { - return Objects.hash(commitSha, status, timestamp, additionalProperties); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class FlakyTestHistory {\n"); - sb.append(" commitSha: ").append(toIndentedString(commitSha)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" additionalProperties: ") - .append(toIndentedString(additionalProperties)) - .append("\n"); - sb.append('}'); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestAttributes.java index b8c4e04d22e..eb6799104de 100644 --- a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestAttributes.java @@ -19,7 +19,6 @@ /** Attributes for the flaky tests search request. */ @JsonPropertyOrder({ FlakyTestsSearchRequestAttributes.JSON_PROPERTY_FILTER, - FlakyTestsSearchRequestAttributes.JSON_PROPERTY_INCLUDE_HISTORY, FlakyTestsSearchRequestAttributes.JSON_PROPERTY_PAGE, FlakyTestsSearchRequestAttributes.JSON_PROPERTY_SORT }) @@ -30,9 +29,6 @@ public class FlakyTestsSearchRequestAttributes { public static final String JSON_PROPERTY_FILTER = "filter"; private FlakyTestsSearchFilter filter; - public static final String JSON_PROPERTY_INCLUDE_HISTORY = "include_history"; - private Boolean includeHistory = false; - public static final String JSON_PROPERTY_PAGE = "page"; private FlakyTestsSearchPageOptions page; @@ -61,29 +57,6 @@ public void setFilter(FlakyTestsSearchFilter filter) { this.filter = filter; } - public FlakyTestsSearchRequestAttributes includeHistory(Boolean includeHistory) { - this.includeHistory = includeHistory; - return this; - } - - /** - * Whether to include the status change history for each flaky test in the response. When set to - * true, each test will include a history array with chronological status changes. - * Defaults to false. - * - * @return includeHistory - */ - @jakarta.annotation.Nullable - @JsonProperty(JSON_PROPERTY_INCLUDE_HISTORY) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public Boolean getIncludeHistory() { - return includeHistory; - } - - public void setIncludeHistory(Boolean includeHistory) { - this.includeHistory = includeHistory; - } - public FlakyTestsSearchRequestAttributes page(FlakyTestsSearchPageOptions page) { this.page = page; this.unparsed |= page.unparsed; @@ -190,7 +163,6 @@ public boolean equals(Object o) { FlakyTestsSearchRequestAttributes flakyTestsSearchRequestAttributes = (FlakyTestsSearchRequestAttributes) o; return Objects.equals(this.filter, flakyTestsSearchRequestAttributes.filter) - && Objects.equals(this.includeHistory, flakyTestsSearchRequestAttributes.includeHistory) && Objects.equals(this.page, flakyTestsSearchRequestAttributes.page) && Objects.equals(this.sort, flakyTestsSearchRequestAttributes.sort) && Objects.equals( @@ -199,7 +171,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(filter, includeHistory, page, sort, additionalProperties); + return Objects.hash(filter, page, sort, additionalProperties); } @Override @@ -207,7 +179,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FlakyTestsSearchRequestAttributes {\n"); sb.append(" filter: ").append(toIndentedString(filter)).append("\n"); - sb.append(" includeHistory: ").append(toIndentedString(includeHistory)).append("\n"); sb.append(" page: ").append(toIndentedString(page)).append("\n"); sb.append(" sort: ").append(toIndentedString(sort)).append("\n"); sb.append(" additionalProperties: ") diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_metric_SLO_object_using_sli_specification_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Create_a_new_metric_SLO_object_using_sli_specification_returns_OK_response.freeze new file mode 100644 index 00000000000..6f05e9c1d1d --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_metric_SLO_object_using_sli_specification_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-02-05T20:07:38.100Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_metric_SLO_object_using_sli_specification_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Create_a_new_metric_SLO_object_using_sli_specification_returns_OK_response.json new file mode 100644 index 00000000000..a4c7a970722 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_metric_SLO_object_using_sli_specification_returns_OK_response.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"description\": \"Metric SLO using sli_specification\", \"name\": \"Test-Create_a_new_metric_SLO_object_using_sli_specification_returns_OK_response-1770322058\", \"sli_specification\": {\"count\": {\"good_events_formula\": {\"formula\": \"query1 - query2\"}, \"queries\": [{\"data_source\": \"metrics\", \"name\": \"query1\", \"query\": \"sum:httpservice.hits{*}.as_count()\"}, {\"data_source\": \"metrics\", \"name\": \"query2\", \"query\": \"sum:httpservice.errors{*}.as_count()\"}], \"total_events_formula\": {\"formula\": \"query1\"}}}, \"tags\": [\"env:prod\", \"type:count\"], \"target_threshold\": 99, \"thresholds\": [{\"target\": 99.0, \"target_display\": \"99.0\", \"timeframe\": \"7d\", \"warning\": 99.5, \"warning_display\": \"99.5\"}], \"timeframe\": \"7d\", \"type\": \"metric\", \"warning_threshold\": 99.5}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/slo", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":[{\"id\":\"6e49f8aa9883507dbc719f00eede5a5d\",\"name\":\"Test-Create_a_new_metric_SLO_object_using_sli_specification_returns_OK_response-1770322058\",\"tags\":[\"env:prod\",\"type:count\"],\"monitor_tags\":[],\"thresholds\":[{\"timeframe\":\"7d\",\"target\":99.0,\"target_display\":\"99.\",\"warning\":99.5,\"warning_display\":\"99.5\"}],\"type\":\"metric\",\"type_id\":1,\"description\":\"Metric SLO using sli_specification\",\"timeframe\":\"7d\",\"warning_threshold\":99.5,\"target_threshold\":99,\"query\":{\"numerator\":\"sum:httpservice.hits{*}.as_count() - sum:httpservice.errors{*}.as_count()\",\"denominator\":\"sum:httpservice.hits{*}.as_count()\"},\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\"},\"created_at\":1770322058,\"modified_at\":1770322058,\"sli_specification\":{\"count\":{\"good_events_formula\":{\"formula\":\"query1 - query2\"},\"queries\":[{\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"sum:httpservice.hits{*}.as_count()\"},{\"data_source\":\"metrics\",\"name\":\"query2\",\"query\":\"sum:httpservice.errors{*}.as_count()\"}],\"total_events_formula\":{\"formula\":\"query1\"}}}}],\"error\":null}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "fc56381b-bf9d-c291-6659-7c47c77e8a46" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/slo/6e49f8aa9883507dbc719f00eede5a5d", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":[\"6e49f8aa9883507dbc719f00eede5a5d\"],\"error\":null}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "1820d1ed-78bd-f49f-fd6e-1b42da76547c" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v1/api/service_level_objectives.feature b/src/test/resources/com/datadog/api/client/v1/api/service_level_objectives.feature index c5534618a73..22c9d6cd3f9 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/service_level_objectives.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/service_level_objectives.feature @@ -48,6 +48,23 @@ Feature: Service Level Objectives When the request is sent Then the response status is 200 OK + @team:DataDog/slo-app + Scenario: Create a new metric SLO object using sli_specification returns "OK" response + Given new "CreateSLO" request + And body with value {"type":"metric","description":"Metric SLO using sli_specification","name":"{{ unique }}","sli_specification":{"count":{"good_events_formula":{"formula":"query1 - query2"},"total_events_formula":{"formula":"query1"},"queries":[{"data_source":"metrics","name":"query1","query":"sum:httpservice.hits{*}.as_count()"},{"data_source":"metrics","name":"query2","query":"sum:httpservice.errors{*}.as_count()"}]}},"tags":["env:prod","type:count"],"thresholds":[{"target":99.0,"target_display":"99.0","timeframe":"7d","warning":99.5,"warning_display":"99.5"}],"timeframe":"7d","target_threshold":99.0,"warning_threshold":99.5} + When the request is sent + Then the response status is 200 OK + And the response "data[0].timeframe" is equal to "7d" + And the response "data[0].target_threshold" is equal to 99.0 + And the response "data[0].warning_threshold" is equal to 99.5 + And the response "data[0]" has field "sli_specification" + And the response "data[0].sli_specification" has field "count" + And the response "data[0].sli_specification.count" has field "good_events_formula" + And the response "data[0].sli_specification.count" has field "total_events_formula" + And the response "data[0].sli_specification.count" has field "queries" + And the response "data[0].sli_specification.count.queries" has length 2 + And the response "data[0]" has field "query" + @team:DataDog/slo-app Scenario: Create a time-slice SLO object returns "OK" response Given new "CreateSLO" request diff --git a/src/test/resources/com/datadog/api/client/v2/api/test_optimization.feature b/src/test/resources/com/datadog/api/client/v2/api/test_optimization.feature index bbf7d87075e..d21278d7646 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/test_optimization.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/test_optimization.feature @@ -13,7 +13,7 @@ Feature: Test Optimization Scenario: Search flaky tests returns "Bad Request" response Given operation "SearchFlakyTests" enabled And new "SearchFlakyTests" request - And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "include_history": true, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} + And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} When the request is sent Then the response status is 400 Bad Request @@ -29,7 +29,7 @@ Feature: Test Optimization Scenario: Search flaky tests returns "OK" response Given operation "SearchFlakyTests" enabled And new "SearchFlakyTests" request - And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "include_history": true, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} + And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} When the request is sent Then the response status is 200 OK @@ -41,23 +41,11 @@ Feature: Test Optimization When the request with pagination is sent Then the response status is 200 OK - @skip @team:DataDog/ci-app-backend - Scenario: Search flaky tests returns "OK" response with history - Given operation "SearchFlakyTests" enabled - And new "SearchFlakyTests" request - And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"limit": 10}, "sort": "fqn", "include_history": true}, "type": "search_flaky_tests_request"}} - When the request is sent - Then the response status is 200 OK - And the response "data[0].attributes" has field "history" - And the response "data[0].attributes.history[0]" has field "status" - And the response "data[0].attributes.history[0]" has field "commit_sha" - And the response "data[0].attributes.history[0]" has field "timestamp" - @generated @skip @team:DataDog/ci-app-backend @with-pagination Scenario: Search flaky tests returns "OK" response with pagination Given operation "SearchFlakyTests" enabled And new "SearchFlakyTests" request - And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "include_history": true, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} + And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} When the request with pagination is sent Then the response status is 200 OK