Skip to content

Commit 10b804b

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 68054b9 of spec repo
1 parent 14d9e5d commit 10b804b

File tree

7 files changed

+199
-16
lines changed

7 files changed

+199
-16
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11902,10 +11902,10 @@ components:
1190211902
type: object
1190311903
SLOCountDefinition:
1190411904
description: 'A count-based (metric) SLI specification, composed of three parts:
11905-
the good events formula, the total events formula,
11906-
11907-
and the underlying queries.'
11905+
the good events formula, the bad or total events formula, and the underlying
11906+
queries.'
1190811907
example:
11908+
bad_events_formula: query2
1190911909
good_events_formula: query1 - query2
1191011910
queries:
1191111911
- data_source: metrics
@@ -11914,8 +11914,13 @@ components:
1191411914
- data_source: metrics
1191511915
name: query2
1191611916
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
11917-
total_events_formula: query1
1191811917
properties:
11918+
bad_events_formula:
11919+
$ref: '#/components/schemas/SLOFormula'
11920+
description: 'The bad events formula. Exactly one of `total_events_formula`
11921+
or
11922+
11923+
`bad_events_formula` must be provided.'
1191911924
good_events_formula:
1192011925
$ref: '#/components/schemas/SLOFormula'
1192111926
queries:
@@ -11929,16 +11934,21 @@ components:
1192911934
type: array
1193011935
total_events_formula:
1193111936
$ref: '#/components/schemas/SLOFormula'
11937+
description: 'The total events formula. Exactly one of `total_events_formula`
11938+
or
11939+
11940+
`bad_events_formula` must be provided. This field is deprecated in favor
11941+
of `bad_events_formula`.'
1193211942
required:
1193311943
- good_events_formula
11934-
- total_events_formula
1193511944
- queries
1193611945
type: object
1193711946
SLOCountSpec:
1193811947
additionalProperties: false
1193911948
description: A metric SLI specification.
1194011949
example:
1194111950
count:
11951+
bad_events_formula: query2
1194211952
good_events_formula: query1 - query2
1194311953
queries:
1194411954
- data_source: metrics
@@ -11947,7 +11957,6 @@ components:
1194711957
- data_source: metrics
1194811958
name: query2
1194911959
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
11950-
total_events_formula: query1
1195111960
properties:
1195211961
count:
1195311962
$ref: '#/components/schemas/SLOCountDefinition'
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Create a new metric SLO object using bad events formula returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v1.api.ServiceLevelObjectivesApi;
6+
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricDataSource;
7+
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricQueryDefinition;
8+
import com.datadog.api.client.v1.model.SLOCountDefinition;
9+
import com.datadog.api.client.v1.model.SLOCountSpec;
10+
import com.datadog.api.client.v1.model.SLODataSourceQueryDefinition;
11+
import com.datadog.api.client.v1.model.SLOFormula;
12+
import com.datadog.api.client.v1.model.SLOListResponse;
13+
import com.datadog.api.client.v1.model.SLOSliSpec;
14+
import com.datadog.api.client.v1.model.SLOThreshold;
15+
import com.datadog.api.client.v1.model.SLOTimeframe;
16+
import com.datadog.api.client.v1.model.SLOType;
17+
import com.datadog.api.client.v1.model.ServiceLevelObjectiveRequest;
18+
import java.util.Arrays;
19+
import java.util.Collections;
20+
21+
public class Example {
22+
public static void main(String[] args) {
23+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
24+
ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
25+
26+
ServiceLevelObjectiveRequest body =
27+
new ServiceLevelObjectiveRequest()
28+
.type(SLOType.METRIC)
29+
.description("Metric SLO using sli_specification")
30+
.name("Example-Service-Level-Objective")
31+
.sliSpecification(
32+
new SLOSliSpec(
33+
new SLOCountSpec()
34+
.count(
35+
new SLOCountDefinition()
36+
.goodEventsFormula(new SLOFormula().formula("query1 - query2"))
37+
.badEventsFormula(new SLOFormula().formula("query2"))
38+
.queries(
39+
Arrays.asList(
40+
new SLODataSourceQueryDefinition(
41+
new FormulaAndFunctionMetricQueryDefinition()
42+
.dataSource(
43+
FormulaAndFunctionMetricDataSource.METRICS)
44+
.name("query1")
45+
.query("sum:httpservice.hits{*}.as_count()")),
46+
new SLODataSourceQueryDefinition(
47+
new FormulaAndFunctionMetricQueryDefinition()
48+
.dataSource(
49+
FormulaAndFunctionMetricDataSource.METRICS)
50+
.name("query2")
51+
.query("sum:httpservice.errors{*}.as_count()")))))))
52+
.tags(Arrays.asList("env:prod", "type:count"))
53+
.thresholds(
54+
Collections.singletonList(
55+
new SLOThreshold()
56+
.target(99.0)
57+
.targetDisplay("99.0")
58+
.timeframe(SLOTimeframe.SEVEN_DAYS)
59+
.warning(99.5)
60+
.warningDisplay("99.5")))
61+
.timeframe(SLOTimeframe.SEVEN_DAYS)
62+
.targetThreshold(99.0)
63+
.warningThreshold(99.5);
64+
65+
try {
66+
SLOListResponse result = apiInstance.createSLO(body);
67+
System.out.println(result);
68+
} catch (ApiException e) {
69+
System.err.println("Exception when calling ServiceLevelObjectivesApi#createSLO");
70+
System.err.println("Status code: " + e.getCode());
71+
System.err.println("Reason: " + e.getResponseBody());
72+
System.err.println("Response headers: " + e.getResponseHeaders());
73+
e.printStackTrace();
74+
}
75+
}
76+
}

src/main/java/com/datadog/api/client/v1/model/SLOCountDefinition.java

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121

2222
/**
2323
* A count-based (metric) SLI specification, composed of three parts: the good events formula, the
24-
* total events formula, and the underlying queries.
24+
* bad or total events formula, and the underlying queries.
2525
*/
2626
@JsonPropertyOrder({
27+
SLOCountDefinition.JSON_PROPERTY_BAD_EVENTS_FORMULA,
2728
SLOCountDefinition.JSON_PROPERTY_GOOD_EVENTS_FORMULA,
2829
SLOCountDefinition.JSON_PROPERTY_QUERIES,
2930
SLOCountDefinition.JSON_PROPERTY_TOTAL_EVENTS_FORMULA
@@ -32,6 +33,9 @@
3233
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
3334
public class SLOCountDefinition {
3435
@JsonIgnore public boolean unparsed = false;
36+
public static final String JSON_PROPERTY_BAD_EVENTS_FORMULA = "bad_events_formula";
37+
private SLOFormula badEventsFormula;
38+
3539
public static final String JSON_PROPERTY_GOOD_EVENTS_FORMULA = "good_events_formula";
3640
private SLOFormula goodEventsFormula;
3741

@@ -48,14 +52,32 @@ public SLOCountDefinition(
4852
@JsonProperty(required = true, value = JSON_PROPERTY_GOOD_EVENTS_FORMULA)
4953
SLOFormula goodEventsFormula,
5054
@JsonProperty(required = true, value = JSON_PROPERTY_QUERIES)
51-
List<SLODataSourceQueryDefinition> queries,
52-
@JsonProperty(required = true, value = JSON_PROPERTY_TOTAL_EVENTS_FORMULA)
53-
SLOFormula totalEventsFormula) {
55+
List<SLODataSourceQueryDefinition> queries) {
5456
this.goodEventsFormula = goodEventsFormula;
5557
this.unparsed |= goodEventsFormula.unparsed;
5658
this.queries = queries;
57-
this.totalEventsFormula = totalEventsFormula;
58-
this.unparsed |= totalEventsFormula.unparsed;
59+
}
60+
61+
public SLOCountDefinition badEventsFormula(SLOFormula badEventsFormula) {
62+
this.badEventsFormula = badEventsFormula;
63+
this.unparsed |= badEventsFormula.unparsed;
64+
return this;
65+
}
66+
67+
/**
68+
* A formula that specifies how to combine the results of multiple queries.
69+
*
70+
* @return badEventsFormula
71+
*/
72+
@jakarta.annotation.Nullable
73+
@JsonProperty(JSON_PROPERTY_BAD_EVENTS_FORMULA)
74+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
75+
public SLOFormula getBadEventsFormula() {
76+
return badEventsFormula;
77+
}
78+
79+
public void setBadEventsFormula(SLOFormula badEventsFormula) {
80+
this.badEventsFormula = badEventsFormula;
5981
}
6082

6183
public SLOCountDefinition goodEventsFormula(SLOFormula goodEventsFormula) {
@@ -119,8 +141,9 @@ public SLOCountDefinition totalEventsFormula(SLOFormula totalEventsFormula) {
119141
*
120142
* @return totalEventsFormula
121143
*/
144+
@jakarta.annotation.Nullable
122145
@JsonProperty(JSON_PROPERTY_TOTAL_EVENTS_FORMULA)
123-
@JsonInclude(value = JsonInclude.Include.ALWAYS)
146+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
124147
public SLOFormula getTotalEventsFormula() {
125148
return totalEventsFormula;
126149
}
@@ -185,21 +208,24 @@ public boolean equals(Object o) {
185208
return false;
186209
}
187210
SLOCountDefinition sloCountDefinition = (SLOCountDefinition) o;
188-
return Objects.equals(this.goodEventsFormula, sloCountDefinition.goodEventsFormula)
211+
return Objects.equals(this.badEventsFormula, sloCountDefinition.badEventsFormula)
212+
&& Objects.equals(this.goodEventsFormula, sloCountDefinition.goodEventsFormula)
189213
&& Objects.equals(this.queries, sloCountDefinition.queries)
190214
&& Objects.equals(this.totalEventsFormula, sloCountDefinition.totalEventsFormula)
191215
&& Objects.equals(this.additionalProperties, sloCountDefinition.additionalProperties);
192216
}
193217

194218
@Override
195219
public int hashCode() {
196-
return Objects.hash(goodEventsFormula, queries, totalEventsFormula, additionalProperties);
220+
return Objects.hash(
221+
badEventsFormula, goodEventsFormula, queries, totalEventsFormula, additionalProperties);
197222
}
198223

199224
@Override
200225
public String toString() {
201226
StringBuilder sb = new StringBuilder();
202227
sb.append("class SLOCountDefinition {\n");
228+
sb.append(" badEventsFormula: ").append(toIndentedString(badEventsFormula)).append("\n");
203229
sb.append(" goodEventsFormula: ").append(toIndentedString(goodEventsFormula)).append("\n");
204230
sb.append(" queries: ").append(toIndentedString(queries)).append("\n");
205231
sb.append(" totalEventsFormula: ").append(toIndentedString(totalEventsFormula)).append("\n");

src/main/java/com/datadog/api/client/v1/model/SLOCountSpec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public SLOCountSpec count(SLOCountDefinition count) {
3939

4040
/**
4141
* A count-based (metric) SLI specification, composed of three parts: the good events formula, the
42-
* total events formula, and the underlying queries.
42+
* bad or total events formula, and the underlying queries.
4343
*
4444
* @return count
4545
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-02-25T17:45:38.518Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"httpRequest": {
4+
"body": {
5+
"type": "JSON",
6+
"json": "{\"description\": \"Metric SLO using sli_specification\", \"name\": \"Test-Create_a_new_metric_SLO_object_using_bad_events_formula_returns_OK_response-1772041538\", \"sli_specification\": {\"count\": {\"bad_events_formula\": {\"formula\": \"query2\"}, \"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()\"}]}}, \"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}"
7+
},
8+
"headers": {},
9+
"method": "POST",
10+
"path": "/api/v1/slo",
11+
"keepAlive": false,
12+
"secure": true
13+
},
14+
"httpResponse": {
15+
"body": "{\"data\":[{\"id\":\"7309ff3752fd519f80f65a2ed3247dbb\",\"name\":\"Test-Create_a_new_metric_SLO_object_using_bad_events_formula_returns_OK_response-1772041538\",\"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() - sum:httpservice.errors{*}.as_count()) + (sum:httpservice.errors{*}.as_count())\"},\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\"},\"created_at\":1772041538,\"modified_at\":1772041538,\"sli_specification\":{\"count\":{\"bad_events_formula\":{\"formula\":\"query2\"},\"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()\"}]}}}],\"error\":null}\n",
16+
"headers": {
17+
"Content-Type": [
18+
"application/json"
19+
]
20+
},
21+
"statusCode": 200,
22+
"reasonPhrase": "OK"
23+
},
24+
"times": {
25+
"remainingTimes": 1
26+
},
27+
"timeToLive": {
28+
"unlimited": true
29+
},
30+
"id": "d5693d5e-ee1e-afa7-88d0-69277375e5d9"
31+
},
32+
{
33+
"httpRequest": {
34+
"headers": {},
35+
"method": "DELETE",
36+
"path": "/api/v1/slo/7309ff3752fd519f80f65a2ed3247dbb",
37+
"keepAlive": false,
38+
"secure": true
39+
},
40+
"httpResponse": {
41+
"body": "{\"data\":[\"7309ff3752fd519f80f65a2ed3247dbb\"],\"error\":null}\n",
42+
"headers": {
43+
"Content-Type": [
44+
"application/json"
45+
]
46+
},
47+
"statusCode": 200,
48+
"reasonPhrase": "OK"
49+
},
50+
"times": {
51+
"remainingTimes": 1
52+
},
53+
"timeToLive": {
54+
"unlimited": true
55+
},
56+
"id": "c0933b3f-30b7-b24a-0ddb-dcdf3c1ea62d"
57+
}
58+
]

src/test/resources/com/datadog/api/client/v1/api/service_level_objectives.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ Feature: Service Level Objectives
4848
When the request is sent
4949
Then the response status is 200 OK
5050

51+
@team:DataDog/slo-app
52+
Scenario: Create a new metric SLO object using bad events formula returns "OK" response
53+
Given new "CreateSLO" request
54+
And body with value {"type":"metric","description":"Metric SLO using sli_specification","name":"{{ unique }}","sli_specification":{"count":{"good_events_formula":{"formula":"query1 - query2"},"bad_events_formula":{"formula":"query2"},"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}
55+
When the request is sent
56+
Then the response status is 200 OK
57+
And the response "data[0]" has field "sli_specification"
58+
And the response "data[0].sli_specification" has field "count"
59+
And the response "data[0].sli_specification.count" has field "good_events_formula"
60+
And the response "data[0].sli_specification.count" has field "bad_events_formula"
61+
And the response "data[0].sli_specification.count" has field "queries"
62+
And the response "data[0].sli_specification.count.queries" has length 2
63+
5164
@team:DataDog/slo-app
5265
Scenario: Create a new metric SLO object using sli_specification returns "OK" response
5366
Given new "CreateSLO" request

0 commit comments

Comments
 (0)