Skip to content

Commit

Permalink
add docs for pagination in /api/v2/metrics endpoint (#1829)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <[email protected]>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Dec 12, 2024
1 parent ca2ba6c commit 4b4a8ae
Show file tree
Hide file tree
Showing 15 changed files with 608 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-12-11 20:35:42.884984",
"spec_repo_commit": "7b62d196"
"regenerated": "2024-12-12 13:29:32.071714",
"spec_repo_commit": "f0c3c0f4"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-12-11 20:35:42.906308",
"spec_repo_commit": "7b62d196"
"regenerated": "2024-12-12 13:29:32.090710",
"spec_repo_commit": "f0c3c0f4"
}
}
}
96 changes: 95 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16012,6 +16012,36 @@ components:
- COUNT
- RATE
- GAUGE
MetricMetaPage:
description: Paging attributes. Only present if pagination query parameters
were provided.
properties:
cursor:
description: The cursor used to get the current results, if any.
nullable: true
type: string
limit:
description: Number of results returned
format: int32
maximum: 20000
minimum: 0
type: integer
next_cursor:
description: The cursor used to get the next results, if any.
nullable: true
type: string
type:
$ref: '#/components/schemas/MetricMetaPageType'
type: object
MetricMetaPageType:
default: cursor_limit
description: Type of metric pagination.
enum:
- cursor_limit
example: cursor_limit
type: string
x-enum-varnames:
- CURSOR_LIMIT
MetricMetadata:
description: Metadata for the metric.
properties:
Expand Down Expand Up @@ -16094,6 +16124,12 @@ components:
maximum: 1000
type: integer
type: object
MetricPaginationMeta:
description: Response metadata object.
properties:
pagination:
$ref: '#/components/schemas/MetricMetaPage'
type: object
MetricPayload:
description: The metrics' payload.
properties:
Expand Down Expand Up @@ -16570,6 +16606,10 @@ components:
items:
$ref: '#/components/schemas/MetricsAndMetricTagConfigurations'
type: array
links:
$ref: '#/components/schemas/MetricsListResponseLinks'
meta:
$ref: '#/components/schemas/MetricPaginationMeta'
readOnly: true
type: object
MetricsDataSource:
Expand All @@ -16583,6 +16623,29 @@ components:
x-enum-varnames:
- METRICS
- CLOUD_COST
MetricsListResponseLinks:
description: Pagination links. Only present if pagination query parameters were
provided.
properties:
first:
description: Link to the first page.
type: string
last:
description: Link to the last page.
nullable: true
type: string
next:
description: Link to the next page.
nullable: true
type: string
prev:
description: Link to previous page.
nullable: true
type: string
self:
description: Link to current page.
type: string
type: object
MetricsScalarQuery:
description: An individual scalar metrics query.
properties:
Expand Down Expand Up @@ -35773,7 +35836,12 @@ paths:
get:
description: "Returns all metrics that can be configured in the Metrics Summary
page or with Metrics without Limits\u2122 (matching additional filters if
specified)."
specified).\nOptionally, paginate by using the `page[cursor]` and/or `page[size]`
query parameters.\nTo fetch the first page, pass in a query parameter with
either a valid `page[size]` or an empty cursor like `page[cursor]=`. To fetch
the next page, pass in the `next_cursor` value from the response as the new
`page[cursor]` value.\nOnce the `meta.pagination.next_cursor` value is null,
all pages have been retrieved."
operationId: ListTagConfigurations
parameters:
- description: Filter custom metrics that have configured tags.
Expand Down Expand Up @@ -35838,6 +35906,27 @@ paths:
schema:
format: int64
type: integer
- description: Maximum number of results returned.
in: query
name: page[size]
required: false
schema:
default: 10000
format: int32
maximum: 10000
minimum: 1
type: integer
- description: 'String to query the next page of results.

This key is provided with each valid response from the API in `meta.pagination.next_cursor`.

Once the `meta.pagination.next_cursor` key is null, all pages have been
retrieved.'
in: query
name: page[cursor]
required: false
schema:
type: string
responses:
'200':
content:
Expand Down Expand Up @@ -35871,6 +35960,11 @@ paths:
summary: Get a list of metrics
tags:
- Metrics
x-pagination:
cursorParam: page[cursor]
cursorPath: meta.pagination.next_cursor
limitParam: page[size]
resultsPath: data
x-permission:
operator: OR
permissions:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2024-12-06T19:12:25.667Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"log": {
"_recordingName": "Metrics/Get a list of metrics returns \"Success\" response with pagination",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.5"
},
"entries": [
{
"_id": "8ebd8c6fc837a7c834914fdf3447ba1d",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
}
],
"headersSize": 526,
"httpVersion": "HTTP/1.1",
"method": "GET",
"queryString": [
{
"name": "page",
"value": {
"size": "1"
}
}
],
"url": "https://api.datadoghq.com/api/v2/metrics?page%5Bsize%5D=2"
},
"response": {
"bodySize": 1644,
"content": {
"mimeType": "application/json",
"size": 1644,
"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"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 653,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-12-06T19:12:25.678Z",
"time": 167
},
{
"_id": "71ffa01cdf3d18b9be9f8b8bdf93efa0",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
}
],
"headersSize": 1168,
"httpVersion": "HTTP/1.1",
"method": "GET",
"queryString": [
{
"name": "page",
"value": {
"cursor": "6354566d64454633525642695631597759323173616d4d784f5768614d6d52355748704265455a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c5752555642526d787355314e756233686c617a56575656526b52465273516c6456526c5a74557a427756574a73525546425155464251554642526c705464316455566b354a5658706e4e574d7863465669565852465657316b576b354962464a566257733156564642516b5a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c57525556425155453950546f365a474630595752765a79356c63335270625746305a57526664584e685a3255755a585a6c626e527a4c6d6c755a32567a6447566b583256325a573530637977324c6a67794e7a677a4e3255724d44593d",
"size": "1"
}
}
],
"url": "https://api.datadoghq.com/api/v2/metrics?page%5Bsize%5D=2&page%5Bcursor%5D=6354566d64454633525642695631597759323173616d4d784f5768614d6d52355748704265455a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c5752555642526d787355314e756233686c617a56575656526b52465273516c6456526c5a74557a427756574a73525546425155464251554642526c705464316455566b354a5658706e4e574d7863465669565852465657316b576b354962464a566257733156564642516b5a7561453154526b704554315a4f616c5577566b685862456f305455646e6557517a526e6c57525556425155453950546f365a474630595752765a79356c63335270625746305a57526664584e685a3255755a585a6c626e527a4c6d6c755a32567a6447566b583256325a573530637977324c6a67794e7a677a4e3255724d44593d"
},
"response": {
"bodySize": 2922,
"content": {
"mimeType": "application/json",
"size": 2922,
"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"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 653,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-12-06T19:12:25.859Z",
"time": 121
}
],
"pages": [],
"version": "1.2"
}
}
24 changes: 24 additions & 0 deletions examples/v2/metrics/ListTagConfigurations_3969783727.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Get a list of metrics returns "Success" response with pagination
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.MetricsApi(configuration);

const params: v2.MetricsApiListTagConfigurationsRequest = {
pageSize: 2,
};

(async () => {
try {
for await (const item of apiInstance.listTagConfigurationsWithPagination(
params
)) {
console.log(item);
}
} catch (error) {
console.error(error);
}
})();
8 changes: 8 additions & 0 deletions features/support/scenarios_model_mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4462,6 +4462,14 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
"type": "number",
"format": "int64",
},
"pageSize": {
"type": "number",
"format": "int32",
},
"pageCursor": {
"type": "string",
"format": "",
},
"operationResponseType": "MetricsAndMetricTagConfigurationsResponse",
},
"v2.DeleteBulkTagsMetricsConfiguration": {
Expand Down
9 changes: 9 additions & 0 deletions features/v2/metrics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ Feature: Metrics
When the request is sent
Then the response status is 200 Success

@replay-only @skip-validation @team:DataDog/metrics-experience @with-pagination
Scenario: Get a list of metrics returns "Success" response with pagination
Given a valid "appKeyAuth" key in the system
And new "ListTagConfigurations" request
And request contains "page[size]" parameter with value 2
When the request with pagination is sent
Then the response status is 200 Success
And the response has 3 items

@team:DataDog/metrics-experience
Scenario: Get a list of metrics with a tag filter returns "Success" response
Given a valid "appKeyAuth" key in the system
Expand Down
Loading

0 comments on commit 4b4a8ae

Please sign in to comment.