Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docs for pagination in /api/v2/metrics endpoint #2701

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-09-23 19:10:10.010692",
"spec_repo_commit": "41592dc6"
"regenerated": "2024-09-24 14:49:07.421285",
"spec_repo_commit": "53c64681"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-09-23 19:10:10.024754",
"spec_repo_commit": "41592dc6"
"regenerated": "2024-09-24 14:49:07.435987",
"spec_repo_commit": "53c64681"
}
}
}
94 changes: 93 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14207,6 +14207,35 @@ 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.
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 @@ -14289,6 +14318,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 @@ -14754,6 +14789,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 @@ -14767,6 +14806,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 @@ -32472,7 +32534,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 @@ -32537,6 +32604,26 @@ 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 @@ -32570,6 +32657,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
81 changes: 81 additions & 0 deletions api/datadogV2/api_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,8 @@ type ListTagConfigurationsOptionalParameters struct {
FilterQueried *bool
FilterTags *string
WindowSeconds *int64
PageSize *int32
PageCursor *string
}

// NewListTagConfigurationsOptionalParameters creates an empty struct for parameters.
Expand Down Expand Up @@ -752,8 +754,23 @@ func (r *ListTagConfigurationsOptionalParameters) WithWindowSeconds(windowSecond
return r
}

// WithPageSize sets the corresponding parameter name and returns the struct.
func (r *ListTagConfigurationsOptionalParameters) WithPageSize(pageSize int32) *ListTagConfigurationsOptionalParameters {
r.PageSize = &pageSize
return r
}

// WithPageCursor sets the corresponding parameter name and returns the struct.
func (r *ListTagConfigurationsOptionalParameters) WithPageCursor(pageCursor string) *ListTagConfigurationsOptionalParameters {
r.PageCursor = &pageCursor
return r
}

// ListTagConfigurations Get a list of metrics.
// Returns all metrics that can be configured in the Metrics Summary page or with Metrics without Limits™ (matching additional filters if specified).
// Optionally, paginate by using the page[cursor] and/or page[size] query parameters.
// To 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.
// Once the meta.pagination.next_cursor value is null, all pages have been retrieved.
func (a *MetricsApi) ListTagConfigurations(ctx _context.Context, o ...ListTagConfigurationsOptionalParameters) (MetricsAndMetricTagConfigurationsResponse, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
Expand Down Expand Up @@ -800,6 +817,12 @@ func (a *MetricsApi) ListTagConfigurations(ctx _context.Context, o ...ListTagCon
if optionalParams.WindowSeconds != nil {
localVarQueryParams.Add("window[seconds]", datadog.ParameterToString(*optionalParams.WindowSeconds, ""))
}
if optionalParams.PageSize != nil {
localVarQueryParams.Add("page[size]", datadog.ParameterToString(*optionalParams.PageSize, ""))
}
if optionalParams.PageCursor != nil {
localVarQueryParams.Add("page[cursor]", datadog.ParameterToString(*optionalParams.PageCursor, ""))
}
localVarHeaderParams["Accept"] = "application/json"

datadog.SetAuthKeys(
Expand Down Expand Up @@ -851,6 +874,64 @@ func (a *MetricsApi) ListTagConfigurations(ctx _context.Context, o ...ListTagCon
return localVarReturnValue, localVarHTTPResponse, nil
}

// ListTagConfigurationsWithPagination provides a paginated version of ListTagConfigurations returning a channel with all items.
func (a *MetricsApi) ListTagConfigurationsWithPagination(ctx _context.Context, o ...ListTagConfigurationsOptionalParameters) (<-chan datadog.PaginationResult[MetricsAndMetricTagConfigurations], func()) {
ctx, cancel := _context.WithCancel(ctx)
pageSize_ := int32(10000)
if len(o) == 0 {
o = append(o, ListTagConfigurationsOptionalParameters{})
}
if o[0].PageSize != nil {
pageSize_ = *o[0].PageSize
}
o[0].PageSize = &pageSize_

items := make(chan datadog.PaginationResult[MetricsAndMetricTagConfigurations], pageSize_)
go func() {
for {
resp, _, err := a.ListTagConfigurations(ctx, o...)
if err != nil {
var returnItem MetricsAndMetricTagConfigurations
items <- datadog.PaginationResult[MetricsAndMetricTagConfigurations]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
if !ok {
break
}
results := *respData

for _, item := range results {
select {
case items <- datadog.PaginationResult[MetricsAndMetricTagConfigurations]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
}
}
if len(results) < int(pageSize_) {
break
}
cursorMeta, ok := resp.GetMetaOk()
if !ok {
break
}
cursorMetaPagination, ok := cursorMeta.GetPaginationOk()
if !ok {
break
}
cursorMetaPaginationNextCursor, ok := cursorMetaPagination.GetNextCursorOk()
if !ok {
break
}

o[0].PageCursor = cursorMetaPaginationNextCursor
}
close(items)
}()
return items, cancel
}

// ListTagsByMetricName List tags by metric name.
// View indexed tag key-value pairs for a given metric name.
func (a *MetricsApi) ListTagsByMetricName(ctx _context.Context, metricName string) (MetricAllTagsResponse, *_nethttp.Response, error) {
Expand Down
Loading
Loading