Skip to content

Commit 4b4a8ae

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
add docs for pagination in /api/v2/metrics endpoint (#1829)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent ca2ba6c commit 4b4a8ae

File tree

15 files changed

+608
-5
lines changed

15 files changed

+608
-5
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2024-12-11 20:35:42.884984",
8-
"spec_repo_commit": "7b62d196"
7+
"regenerated": "2024-12-12 13:29:32.071714",
8+
"spec_repo_commit": "f0c3c0f4"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-12-11 20:35:42.906308",
13-
"spec_repo_commit": "7b62d196"
12+
"regenerated": "2024-12-12 13:29:32.090710",
13+
"spec_repo_commit": "f0c3c0f4"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16012,6 +16012,36 @@ components:
1601216012
- COUNT
1601316013
- RATE
1601416014
- GAUGE
16015+
MetricMetaPage:
16016+
description: Paging attributes. Only present if pagination query parameters
16017+
were provided.
16018+
properties:
16019+
cursor:
16020+
description: The cursor used to get the current results, if any.
16021+
nullable: true
16022+
type: string
16023+
limit:
16024+
description: Number of results returned
16025+
format: int32
16026+
maximum: 20000
16027+
minimum: 0
16028+
type: integer
16029+
next_cursor:
16030+
description: The cursor used to get the next results, if any.
16031+
nullable: true
16032+
type: string
16033+
type:
16034+
$ref: '#/components/schemas/MetricMetaPageType'
16035+
type: object
16036+
MetricMetaPageType:
16037+
default: cursor_limit
16038+
description: Type of metric pagination.
16039+
enum:
16040+
- cursor_limit
16041+
example: cursor_limit
16042+
type: string
16043+
x-enum-varnames:
16044+
- CURSOR_LIMIT
1601516045
MetricMetadata:
1601616046
description: Metadata for the metric.
1601716047
properties:
@@ -16094,6 +16124,12 @@ components:
1609416124
maximum: 1000
1609516125
type: integer
1609616126
type: object
16127+
MetricPaginationMeta:
16128+
description: Response metadata object.
16129+
properties:
16130+
pagination:
16131+
$ref: '#/components/schemas/MetricMetaPage'
16132+
type: object
1609716133
MetricPayload:
1609816134
description: The metrics' payload.
1609916135
properties:
@@ -16570,6 +16606,10 @@ components:
1657016606
items:
1657116607
$ref: '#/components/schemas/MetricsAndMetricTagConfigurations'
1657216608
type: array
16609+
links:
16610+
$ref: '#/components/schemas/MetricsListResponseLinks'
16611+
meta:
16612+
$ref: '#/components/schemas/MetricPaginationMeta'
1657316613
readOnly: true
1657416614
type: object
1657516615
MetricsDataSource:
@@ -16583,6 +16623,29 @@ components:
1658316623
x-enum-varnames:
1658416624
- METRICS
1658516625
- CLOUD_COST
16626+
MetricsListResponseLinks:
16627+
description: Pagination links. Only present if pagination query parameters were
16628+
provided.
16629+
properties:
16630+
first:
16631+
description: Link to the first page.
16632+
type: string
16633+
last:
16634+
description: Link to the last page.
16635+
nullable: true
16636+
type: string
16637+
next:
16638+
description: Link to the next page.
16639+
nullable: true
16640+
type: string
16641+
prev:
16642+
description: Link to previous page.
16643+
nullable: true
16644+
type: string
16645+
self:
16646+
description: Link to current page.
16647+
type: string
16648+
type: object
1658616649
MetricsScalarQuery:
1658716650
description: An individual scalar metrics query.
1658816651
properties:
@@ -35773,7 +35836,12 @@ paths:
3577335836
get:
3577435837
description: "Returns all metrics that can be configured in the Metrics Summary
3577535838
page or with Metrics without Limits\u2122 (matching additional filters if
35776-
specified)."
35839+
specified).\nOptionally, paginate by using the `page[cursor]` and/or `page[size]`
35840+
query parameters.\nTo fetch the first page, pass in a query parameter with
35841+
either a valid `page[size]` or an empty cursor like `page[cursor]=`. To fetch
35842+
the next page, pass in the `next_cursor` value from the response as the new
35843+
`page[cursor]` value.\nOnce the `meta.pagination.next_cursor` value is null,
35844+
all pages have been retrieved."
3577735845
operationId: ListTagConfigurations
3577835846
parameters:
3577935847
- description: Filter custom metrics that have configured tags.
@@ -35838,6 +35906,27 @@ paths:
3583835906
schema:
3583935907
format: int64
3584035908
type: integer
35909+
- description: Maximum number of results returned.
35910+
in: query
35911+
name: page[size]
35912+
required: false
35913+
schema:
35914+
default: 10000
35915+
format: int32
35916+
maximum: 10000
35917+
minimum: 1
35918+
type: integer
35919+
- description: 'String to query the next page of results.
35920+
35921+
This key is provided with each valid response from the API in `meta.pagination.next_cursor`.
35922+
35923+
Once the `meta.pagination.next_cursor` key is null, all pages have been
35924+
retrieved.'
35925+
in: query
35926+
name: page[cursor]
35927+
required: false
35928+
schema:
35929+
type: string
3584135930
responses:
3584235931
'200':
3584335932
content:
@@ -35871,6 +35960,11 @@ paths:
3587135960
summary: Get a list of metrics
3587235961
tags:
3587335962
- Metrics
35963+
x-pagination:
35964+
cursorParam: page[cursor]
35965+
cursorPath: meta.pagination.next_cursor
35966+
limitParam: page[size]
35967+
resultsPath: data
3587435968
x-permission:
3587535969
operator: OR
3587635970
permissions:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2024-12-06T19:12:25.667Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"log": {
3+
"_recordingName": "Metrics/Get a list of metrics returns \"Success\" response with pagination",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "8ebd8c6fc837a7c834914fdf3447ba1d",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 0,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
}
23+
],
24+
"headersSize": 526,
25+
"httpVersion": "HTTP/1.1",
26+
"method": "GET",
27+
"queryString": [
28+
{
29+
"name": "page",
30+
"value": {
31+
"size": "1"
32+
}
33+
}
34+
],
35+
"url": "https://api.datadoghq.com/api/v2/metrics?page%5Bsize%5D=2"
36+
},
37+
"response": {
38+
"bodySize": 1644,
39+
"content": {
40+
"mimeType": "application/json",
41+
"size": 1644,
42+
"text": "{\"data\":[{\"type\":\"metrics\",\"id\":\"datadog.event.tracking.indexation.audit.events\"},{\"type\":\"metrics\",\"id\":\"datadog.estimated_usage.events.ingested_events\"}],\"meta\":{\"pagination\":{\"cursor\":null,\"next_cursor\":\"6354566d64454633525642695631597759323173616d4d784f5768614d6d52355748704265455a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c5752555642526d787355314e756233686c617a56575656526b52465273516c6456526c5a74557a427756574a73525546425155464251554642526c705464316455566b354a5658706e4e574d7863465669565852465657316b576b354962464a566257733156564642516b5a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c57525556425155453950546f365a474630595752765a79356c63335270625746305a57526664584e685a3255755a585a6c626e527a4c6d6c755a32567a6447566b583256325a573530637977324c6a67794e7a677a4e3255724d44593d\",\"limit\":1,\"type\":\"cursor_limit\"}},\"links\":{\"self\":\"https://api.datadoghq.com/api/v2/metrics?page[size]=1\",\"last\":null,\"next\":\"https://api.datadoghq.com/api/v2/metrics?page[cursor]=6354566d64454633525642695631597759323173616d4d784f5768614d6d52355748704265455a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c5752555642526d787355314e756233686c617a56575656526b52465273516c6456526c5a74557a427756574a73525546425155464251554642526c705464316455566b354a5658706e4e574d7863465669565852465657316b576b354962464a566257733156564642516b5a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c57525556425155453950546f365a474630595752765a79356c63335270625746305a57526664584e685a3255755a585a6c626e527a4c6d6c755a32567a6447566b583256325a573530637977324c6a67794e7a677a4e3255724d44593d\",\"prev\":null,\"first\":\"https://api.datadoghq.com/api/v2/metrics?page[size]=1\"}}\n"
43+
},
44+
"cookies": [],
45+
"headers": [
46+
{
47+
"name": "content-type",
48+
"value": "application/json"
49+
}
50+
],
51+
"headersSize": 653,
52+
"httpVersion": "HTTP/1.1",
53+
"redirectURL": "",
54+
"status": 200,
55+
"statusText": "OK"
56+
},
57+
"startedDateTime": "2024-12-06T19:12:25.678Z",
58+
"time": 167
59+
},
60+
{
61+
"_id": "71ffa01cdf3d18b9be9f8b8bdf93efa0",
62+
"_order": 0,
63+
"cache": {},
64+
"request": {
65+
"bodySize": 0,
66+
"cookies": [],
67+
"headers": [
68+
{
69+
"_fromType": "array",
70+
"name": "accept",
71+
"value": "application/json"
72+
}
73+
],
74+
"headersSize": 1168,
75+
"httpVersion": "HTTP/1.1",
76+
"method": "GET",
77+
"queryString": [
78+
{
79+
"name": "page",
80+
"value": {
81+
"cursor": "6354566d64454633525642695631597759323173616d4d784f5768614d6d52355748704265455a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c5752555642526d787355314e756233686c617a56575656526b52465273516c6456526c5a74557a427756574a73525546425155464251554642526c705464316455566b354a5658706e4e574d7863465669565852465657316b576b354962464a566257733156564642516b5a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c57525556425155453950546f365a474630595752765a79356c63335270625746305a57526664584e685a3255755a585a6c626e527a4c6d6c755a32567a6447566b583256325a573530637977324c6a67794e7a677a4e3255724d44593d",
82+
"size": "1"
83+
}
84+
}
85+
],
86+
"url": "https://api.datadoghq.com/api/v2/metrics?page%5Bsize%5D=2&page%5Bcursor%5D=6354566d64454633525642695631597759323173616d4d784f5768614d6d52355748704265455a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c5752555642526d787355314e756233686c617a56575656526b52465273516c6456526c5a74557a427756574a73525546425155464251554642526c705464316455566b354a5658706e4e574d7863465669565852465657316b576b354962464a566257733156564642516b5a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c57525556425155453950546f365a474630595752765a79356c63335270625746305a57526664584e685a3255755a585a6c626e527a4c6d6c755a32567a6447566b583256325a573530637977324c6a67794e7a677a4e3255724d44593d"
87+
},
88+
"response": {
89+
"bodySize": 2922,
90+
"content": {
91+
"mimeType": "application/json",
92+
"size": 2922,
93+
"text": "{\"data\":[{\"type\":\"metrics\",\"id\":\"datadog.estimated_usage.synthetics.api_test_runs\"}],\"meta\":{\"pagination\":{\"cursor\":\"6354566d64454633525642695631597759323173616d4d784f5768614d6d52355748704265455a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c5752555642526d787355314e756233686c617a56575656526b52465273516c6456526c5a74557a427756574a73525546425155464251554642526c705464316455566b354a5658706e4e574d7863465669565852465657316b576b354962464a566257733156564642516b5a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c57525556425155453950546f365a474630595752765a79356c63335270625746305a57526664584e685a3255755a585a6c626e527a4c6d6c755a32567a6447566b583256325a573530637977324c6a67794e7a677a4e3255724d44593d\",\"next_cursor\":\"6354566d64454633525642695631597759323173616d4d784f5768614d6d52355748704265455a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c5752555642526d787355314e756233686c617a56575656526b52465273516c6456526c5a74557a427756574a73525546425155464251554642526c705464316455566b354a5658706e4e574d7863465669565852465657316b576b354962464a566257733156564642516b5a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c57525556425155453950546f365a474630595752765a79356c63335270625746305a57526664584e685a32557563336c756447686c64476c6a6379356863476c666447567a644639796457357a4c4445754d44417a4e6a4d795a5373774e673d3d\",\"limit\":1,\"type\":\"cursor_limit\"}},\"links\":{\"self\":\"https://api.datadoghq.com/api/v2/metrics?page[cursor]=6354566d64454633525642695631597759323173616d4d784f5768614d6d52355748704265455a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c5752555642526d787355314e756233686c617a56575656526b52465273516c6456526c5a74557a427756574a73525546425155464251554642526c705464316455566b354a5658706e4e574d7863465669565852465657316b576b354962464a566257733156564642516b5a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c57525556425155453950546f365a474630595752765a79356c63335270625746305a57526664584e685a3255755a585a6c626e527a4c6d6c755a32567a6447566b583256325a573530637977324c6a67794e7a677a4e3255724d44593d&page[size]=1\",\"last\":null,\"next\":\"https://api.datadoghq.com/api/v2/metrics?page[cursor]=6354566d64454633525642695631597759323173616d4d784f5768614d6d52355748704265455a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c5752555642526d787355314e756233686c617a56575656526b52465273516c6456526c5a74557a427756574a73525546425155464251554642526c705464316455566b354a5658706e4e574d7863465669565852465657316b576b354962464a566257733156564642516b5a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c57525556425155453950546f365a474630595752765a79356c63335270625746305a57526664584e685a32557563336c756447686c64476c6a6379356863476c666447567a644639796457357a4c4445754d44417a4e6a4d795a5373774e673d3d\",\"prev\":null,\"first\":\"https://api.datadoghq.com/api/v2/metrics?page[size]=1\"}}\n"
94+
},
95+
"cookies": [],
96+
"headers": [
97+
{
98+
"name": "content-type",
99+
"value": "application/json"
100+
}
101+
],
102+
"headersSize": 653,
103+
"httpVersion": "HTTP/1.1",
104+
"redirectURL": "",
105+
"status": 200,
106+
"statusText": "OK"
107+
},
108+
"startedDateTime": "2024-12-06T19:12:25.859Z",
109+
"time": 121
110+
}
111+
],
112+
"pages": [],
113+
"version": "1.2"
114+
}
115+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Get a list of metrics returns "Success" response with pagination
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.MetricsApi(configuration);
9+
10+
const params: v2.MetricsApiListTagConfigurationsRequest = {
11+
pageSize: 2,
12+
};
13+
14+
(async () => {
15+
try {
16+
for await (const item of apiInstance.listTagConfigurationsWithPagination(
17+
params
18+
)) {
19+
console.log(item);
20+
}
21+
} catch (error) {
22+
console.error(error);
23+
}
24+
})();

features/support/scenarios_model_mapping.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4462,6 +4462,14 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
44624462
"type": "number",
44634463
"format": "int64",
44644464
},
4465+
"pageSize": {
4466+
"type": "number",
4467+
"format": "int32",
4468+
},
4469+
"pageCursor": {
4470+
"type": "string",
4471+
"format": "",
4472+
},
44654473
"operationResponseType": "MetricsAndMetricTagConfigurationsResponse",
44664474
},
44674475
"v2.DeleteBulkTagsMetricsConfiguration": {

features/v2/metrics.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ Feature: Metrics
125125
When the request is sent
126126
Then the response status is 200 Success
127127

128+
@replay-only @skip-validation @team:DataDog/metrics-experience @with-pagination
129+
Scenario: Get a list of metrics returns "Success" response with pagination
130+
Given a valid "appKeyAuth" key in the system
131+
And new "ListTagConfigurations" request
132+
And request contains "page[size]" parameter with value 2
133+
When the request with pagination is sent
134+
Then the response status is 200 Success
135+
And the response has 3 items
136+
128137
@team:DataDog/metrics-experience
129138
Scenario: Get a list of metrics with a tag filter returns "Success" response
130139
Given a valid "appKeyAuth" key in the system

0 commit comments

Comments
 (0)