Skip to content

Commit 04f7614

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit eb79f9f of spec repo
1 parent a0330c9 commit 04f7614

5 files changed

Lines changed: 150 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Timeseries query with top function metadata returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v2.api.MetricsApi;
6+
import com.datadog.api.client.v2.model.MetricsDataSource;
7+
import com.datadog.api.client.v2.model.MetricsTimeseriesQuery;
8+
import com.datadog.api.client.v2.model.QueryFormula;
9+
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryRequest;
10+
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryResponse;
11+
import com.datadog.api.client.v2.model.TimeseriesFormulaRequest;
12+
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestAttributes;
13+
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestType;
14+
import com.datadog.api.client.v2.model.TimeseriesQuery;
15+
import java.util.Collections;
16+
17+
public class Example {
18+
public static void main(String[] args) {
19+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
20+
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
21+
MetricsApi apiInstance = new MetricsApi(defaultClient);
22+
23+
TimeseriesFormulaQueryRequest body =
24+
new TimeseriesFormulaQueryRequest()
25+
.data(
26+
new TimeseriesFormulaRequest()
27+
.attributes(
28+
new TimeseriesFormulaRequestAttributes()
29+
.formulas(
30+
Collections.singletonList(
31+
new QueryFormula().formula("top(a, 1, 'max', 'desc')")))
32+
.from(1636625471000L)
33+
.queries(
34+
Collections.singletonList(
35+
new TimeseriesQuery(
36+
new MetricsTimeseriesQuery()
37+
.dataSource(MetricsDataSource.METRICS)
38+
.query("avg:system.cpu.user{*} by {host}")
39+
.name("a"))))
40+
.to(1636629071000L))
41+
.type(TimeseriesFormulaRequestType.TIMESERIES_REQUEST));
42+
43+
try {
44+
TimeseriesFormulaQueryResponse result = apiInstance.queryTimeseriesData(body);
45+
System.out.println(result);
46+
} catch (ApiException e) {
47+
System.err.println("Exception when calling MetricsApi#queryTimeseriesData");
48+
System.err.println("Status code: " + e.getCode());
49+
System.err.println("Reason: " + e.getResponseBody());
50+
System.err.println("Response headers: " + e.getResponseHeaders());
51+
e.printStackTrace();
52+
}
53+
}
54+
}

‎src/test/resources/com/datadog/api/client/v2/api/metrics.feature‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,16 @@ Feature: Metrics
11441144
Then the response status is 200 OK
11451145
And the response "data.type" is equal to "timeseries_response"
11461146

1147+
@team:ddoghq/timeseries-query
1148+
Scenario: Timeseries query with top function metadata returns "OK" response
1149+
Given a valid "appKeyAuth" key in the system
1150+
And new "QueryTimeseriesData" request
1151+
And body with value {"data": {"attributes": {"formulas": [{"formula": "top(a, 1, 'max', 'desc')"}], "from": {{ timestamp('now - 1h') }}000, "queries": [{"data_source": "metrics", "query": "avg:system.cpu.user{*} by {host}", "name": "a"}], "to": {{ timestamp('now') }}000}, "type": "timeseries_request"}}
1152+
When the request is sent
1153+
Then the response status is 200 OK
1154+
And the response "data.type" is equal to "timeseries_response"
1155+
And the response "data.attributes.series[0].query_index" is equal to 0
1156+
11471157
@team:ddoghq/metrics-experience
11481158
Scenario: Update a derived metric returns "Bad Request" response
11491159
Given a valid "appKeyAuth" key in the system

‎src/test/resources/generated-test/test-runner-data/manifest.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8757,6 +8757,13 @@
87578757
"scenario": "Timeseries cross product query with spans data source returns \"OK\" response",
87588758
"version": "v2"
87598759
},
8760+
{
8761+
"feature": "Metrics",
8762+
"feature_file": "../../com/datadog/api/client/v2/api/metrics.feature",
8763+
"file": "v2/metrics/timeseries-query-with-top-function-metadata-returns-ok-response.json",
8764+
"scenario": "Timeseries query with top function metadata returns \"OK\" response",
8765+
"version": "v2"
8766+
},
87608767
{
87618768
"feature": "Metrics",
87628769
"feature_file": "../../com/datadog/api/client/v2/api/metrics.feature",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"api": "Metrics",
3+
"expected_status": 200,
4+
"feature": "Metrics",
5+
"id": "v2/Metrics/Timeseries query with top function metadata returns \"OK\" response",
6+
"operation_id": "QueryTimeseriesData",
7+
"request": {
8+
"body": {
9+
"schema": {
10+
"format": null,
11+
"ref": "TimeseriesFormulaQueryRequest",
12+
"type": "object"
13+
},
14+
"source": "inline",
15+
"value": {
16+
"$openapi_transformer_template": "{\"data\": {\"attributes\": {\"formulas\": [{\"formula\": \"top(a, 1, 'max', 'desc')\"}], \"from\": {{ timestamp('now - 1h') }}000, \"queries\": [{\"data_source\": \"metrics\", \"query\": \"avg:system.cpu.user{*} by {host}\", \"name\": \"a\"}], \"to\": {{ timestamp('now') }}000}, \"type\": \"timeseries_request\"}}"
17+
}
18+
},
19+
"content_type": "application/json",
20+
"method": "POST",
21+
"pagination": false,
22+
"parameters": [],
23+
"path": "/api/v2/query/timeseries"
24+
},
25+
"scenario": "Timeseries query with top function metadata returns \"OK\" response",
26+
"schema_version": 1,
27+
"version": "v2"
28+
}

‎src/test/resources/generated-test/test-server-data/v2/metrics.json‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5061,6 +5061,57 @@
50615061
"scenario": "Timeseries cross product query with spans data source returns \"OK\" response",
50625062
"version": "v2"
50635063
},
5064+
{
5065+
"feature": "Metrics",
5066+
"frozen_at": "2026-12-04T04:15:28.166Z",
5067+
"interactions": [
5068+
{
5069+
"request": {
5070+
"body": {
5071+
"type": "json",
5072+
"value": {
5073+
"data": {
5074+
"attributes": {
5075+
"formulas": [
5076+
{
5077+
"formula": "top(a, 1, 'max', 'desc')"
5078+
}
5079+
],
5080+
"from": 1796354128000,
5081+
"queries": [
5082+
{
5083+
"data_source": "metrics",
5084+
"name": "a",
5085+
"query": "avg:system.cpu.user{*} by {host}"
5086+
}
5087+
],
5088+
"to": 1796357728000
5089+
},
5090+
"type": "timeseries_request"
5091+
}
5092+
}
5093+
},
5094+
"content_type": "application/json",
5095+
"method": "POST",
5096+
"path": "/api/v2/query/timeseries",
5097+
"query": []
5098+
},
5099+
"response": {
5100+
"body": {
5101+
"encoding": "text",
5102+
"value": "{\"data\":{\"id\":\"0\",\"type\":\"timeseries_response\",\"attributes\":{\"series\":[{\"attributes\":{\"top\":{\"method\":[\"max\"],\"order\":[\"desc\"],\"value\":[50.92276144904113]}},\"group_tags\":[\"host:control-0-17181f25-581c-43a1-8f25-529c288125a8\"],\"query_index\":0,\"unit\":[{\"family\":\"percentage\",\"name\":\"percent\",\"plural\":\"percent\",\"scale_factor\":1.0,\"short_name\":\"%\",\"id\":17},null]}],\"times\":[1796354140000,1796354160000,1796354180000,1796354200000,1796354220000,1796354240000,1796354260000,1796354280000,1796354300000,1796354320000,1796354340000,1796354360000,1796354380000,1796354400000,1796354420000,1796354440000,1796354460000,1796354480000,1796354500000,1796354520000,1796354540000,1796354560000,1796354580000,1796354600000,1796354620000,1796354640000,1796354660000,1796354680000,1796354700000,1796354720000,1796354740000,1796354760000,1796354780000,1796354800000,1796354820000,1796354840000,1796354860000,1796354880000,1796354900000,1796354920000,1796354940000,1796354960000,1796354980000,1796355000000,1796355020000,1796355040000,1796355060000,1796355080000,1796355100000,1796355120000,1796355140000,1796355160000,1796355180000,1796355200000,1796355220000,1796355240000,1796355260000,1796355280000,1796355300000,1796355320000,1796355340000,1796355360000,1796355380000,1796355400000,1796355420000,1796355440000,1796355460000,1796355480000,1796355500000,1796355520000,1796355540000,1796355560000,1796355580000,1796355600000,1796355620000,1796355640000,1796355660000,1796355680000,1796355700000,1796355720000,1796355740000,1796355760000,1796355780000,1796355800000,1796355820000,1796355840000,1796355860000,1796355880000,1796355900000,1796355920000,1796355940000,1796355960000,1796355980000,1796356000000,1796356020000,1796356040000,1796356060000,1796356080000,1796356100000,1796356120000,1796356140000,1796356160000,1796356180000,1796356200000,1796356220000,1796356240000,1796356260000,1796356280000,1796356300000,1796356320000,1796356340000,1796356360000,1796356380000,1796356400000,1796356420000,1796356440000,1796356460000,1796356480000,1796356500000,1796356520000,1796356540000,1796356560000,1796356580000,1796356600000,1796356620000,1796356640000,1796356660000,1796356680000,1796356700000,1796356720000,1796356740000,1796356760000,1796356780000,1796356800000,1796356820000,1796356840000,1796356860000,1796356880000,1796356900000,1796356920000,1796356940000,1796356960000,1796356980000,1796357000000,1796357020000,1796357040000,1796357060000,1796357080000,1796357100000,1796357120000,1796357140000,1796357160000,1796357180000,1796357200000,1796357220000,1796357240000,1796357260000,1796357280000,1796357300000,1796357320000,1796357340000,1796357360000,1796357380000,1796357400000,1796357420000,1796357440000,1796357460000,1796357480000,1796357500000,1796357520000,1796357540000,1796357560000,1796357580000,1796357600000,1796357620000,1796357640000,1796357660000,1796357680000,1796357700000,1796357720000],\"values\":[[28.263889,14.875744,36.446551,28.675958,15.222729,32.112247,28.760908,16.812609,34.640022,31.668712,25.726091,47.093223,24.886562,21.438793,41.952055,22.754282,25.052699,50.922761,18.25784,25.400124,42.69046,20.475192,22.12068,43.245101,32.607625,21.970149,42.935717,12.469352,27.408567,43.039724,29.301356,20.26273,43.816741,18.35443,24.321521,41.867677,12.176991,26.623137,39.547038,31.416769,23.2865,33.587786,35.421016,20.573436,41.050449,13.156966,26.280722,27.250608,31.537133,21.391728,36.809176,19.971871,26.205062,33.956386,27.63503,21.313673,41.704036,26.447814,23.791304,25.347705,26.405323,30.339806,26.273552,28.221635,21.935033,32.212205,25.528645,24.913013,27.963738,26.791277,26.716807,26.642336,27.153418,25.965889,27.741266,27.643286,21.144452,32.883351,30.165764,20.526316,41.066482,27.62319,23.205575,29.948007,23.865604,25.657599,27.449593,26.773561,25.436148,26.588398,32.533255,15.696466,37.107352,28.817799,12.548467,38.557128,25.995119,16.297857,35.285962,29.826389,30.921958,31.469743,29.208434,11.527581,34.664518,29.331942,26.292057,31.642901,28.878116,11.189802,35.397058,28.05383,12.068966,33.249104,33.763203,34.277301,34.791399,24.912526,15.857947,35.256513,26.463457,15.646018,30.889762,28.511967,16.022292,22.960379,27.301255,26.350645,34.449832,33.973165,33.496499,33.019832,25.730181,11.394197,34.978489,26.798749,13.822285,34.761215,29.661903,11.698774,34.888199,27.464545,26.281163,35.122618,30.475236,21.180471,35.330579,28.086744,18.626728,40.910659,26.0478,17.469893,45.532942,28.241065,17.824521,43.825249,27.8826,18.506566,47.509447,34.640985,21.772522,37.358101,22.245467,20.571234,48.464164,27.529658,26.265237,28.313671,29.587236,21.877614,44.506259,25.200979,33.108333,43.921703,32.526328,21.130952,49.811837,37.585734,22.997085,22.997085]]}}}\n"
5103+
},
5104+
"headers": {
5105+
"content-type": "application/vnd.api+json"
5106+
},
5107+
"reason": "OK",
5108+
"status": 200
5109+
}
5110+
}
5111+
],
5112+
"scenario": "Timeseries query with top function metadata returns \"OK\" response",
5113+
"version": "v2"
5114+
},
50645115
{
50655116
"feature": "Metrics",
50665117
"frozen_at": "2026-10-13T19:38:48.794Z",

0 commit comments

Comments
 (0)