Skip to content

Commit 4294bda

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit d3dcccbe of spec repo
1 parent 8b1a54a commit 4294bda

14 files changed

+876
-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-10 13:52:26.139488",
8-
"spec_repo_commit": "4f71be94"
7+
"regenerated": "2024-12-10 15:24:15.489313",
8+
"spec_repo_commit": "d3dcccbe"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-12-10 13:52:26.158620",
13-
"spec_repo_commit": "4f71be94"
12+
"regenerated": "2024-12-10 15:24:15.510725",
13+
"spec_repo_commit": "d3dcccbe"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15905,6 +15905,36 @@ components:
1590515905
- COUNT
1590615906
- RATE
1590715907
- GAUGE
15908+
MetricMetaPage:
15909+
description: Paging attributes. Only present if pagination query parameters
15910+
were provided.
15911+
properties:
15912+
cursor:
15913+
description: The cursor used to get the current results, if any.
15914+
nullable: true
15915+
type: string
15916+
limit:
15917+
description: Number of results returned
15918+
format: int32
15919+
maximum: 20000
15920+
minimum: 0
15921+
type: integer
15922+
next_cursor:
15923+
description: The cursor used to get the next results, if any.
15924+
nullable: true
15925+
type: string
15926+
type:
15927+
$ref: '#/components/schemas/MetricMetaPageType'
15928+
type: object
15929+
MetricMetaPageType:
15930+
default: cursor_limit
15931+
description: Type of metric pagination.
15932+
enum:
15933+
- cursor_limit
15934+
example: cursor_limit
15935+
type: string
15936+
x-enum-varnames:
15937+
- CURSOR_LIMIT
1590815938
MetricMetadata:
1590915939
description: Metadata for the metric.
1591015940
properties:
@@ -15987,6 +16017,12 @@ components:
1598716017
maximum: 1000
1598816018
type: integer
1598916019
type: object
16020+
MetricPaginationMeta:
16021+
description: Response metadata object.
16022+
properties:
16023+
pagination:
16024+
$ref: '#/components/schemas/MetricMetaPage'
16025+
type: object
1599016026
MetricPayload:
1599116027
description: The metrics' payload.
1599216028
properties:
@@ -16463,6 +16499,10 @@ components:
1646316499
items:
1646416500
$ref: '#/components/schemas/MetricsAndMetricTagConfigurations'
1646516501
type: array
16502+
links:
16503+
$ref: '#/components/schemas/MetricsListResponseLinks'
16504+
meta:
16505+
$ref: '#/components/schemas/MetricPaginationMeta'
1646616506
readOnly: true
1646716507
type: object
1646816508
MetricsDataSource:
@@ -16476,6 +16516,29 @@ components:
1647616516
x-enum-varnames:
1647716517
- METRICS
1647816518
- CLOUD_COST
16519+
MetricsListResponseLinks:
16520+
description: Pagination links. Only present if pagination query parameters were
16521+
provided.
16522+
properties:
16523+
first:
16524+
description: Link to the first page.
16525+
type: string
16526+
last:
16527+
description: Link to the last page.
16528+
nullable: true
16529+
type: string
16530+
next:
16531+
description: Link to the next page.
16532+
nullable: true
16533+
type: string
16534+
prev:
16535+
description: Link to previous page.
16536+
nullable: true
16537+
type: string
16538+
self:
16539+
description: Link to current page.
16540+
type: string
16541+
type: object
1647916542
MetricsScalarQuery:
1648016543
description: An individual scalar metrics query.
1648116544
properties:
@@ -35691,7 +35754,12 @@ paths:
3569135754
get:
3569235755
description: "Returns all metrics that can be configured in the Metrics Summary
3569335756
page or with Metrics without Limits\u2122 (matching additional filters if
35694-
specified)."
35757+
specified).\nOptionally, paginate by using the `page[cursor]` and/or `page[size]`
35758+
query parameters.\nTo fetch the first page, pass in a query parameter with
35759+
either a valid `page[size]` or an empty cursor like `page[cursor]=`. To fetch
35760+
the next page, pass in the `next_cursor` value from the response as the new
35761+
`page[cursor]` value.\nOnce the `meta.pagination.next_cursor` value is null,
35762+
all pages have been retrieved."
3569535763
operationId: ListTagConfigurations
3569635764
parameters:
3569735765
- description: Filter custom metrics that have configured tags.
@@ -35756,6 +35824,27 @@ paths:
3575635824
schema:
3575735825
format: int64
3575835826
type: integer
35827+
- description: Maximum number of results returned.
35828+
in: query
35829+
name: page[size]
35830+
required: false
35831+
schema:
35832+
default: 10000
35833+
format: int32
35834+
maximum: 10000
35835+
minimum: 1
35836+
type: integer
35837+
- description: 'String to query the next page of results.
35838+
35839+
This key is provided with each valid response from the API in `meta.pagination.next_cursor`.
35840+
35841+
Once the `meta.pagination.next_cursor` key is null, all pages have been
35842+
retrieved.'
35843+
in: query
35844+
name: page[cursor]
35845+
required: false
35846+
schema:
35847+
type: string
3575935848
responses:
3576035849
'200':
3576135850
content:
@@ -35789,6 +35878,11 @@ paths:
3578935878
summary: Get a list of metrics
3579035879
tags:
3579135880
- Metrics
35881+
x-pagination:
35882+
cursorParam: page[cursor]
35883+
cursorPath: meta.pagination.next_cursor
35884+
limitParam: page[size]
35885+
resultsPath: data
3579235886
x-permission:
3579335887
operator: OR
3579435888
permissions:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Get a list of metrics returns "Success" response with pagination
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_metrics::ListTagConfigurationsOptionalParams;
4+
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
5+
use futures_util::pin_mut;
6+
use futures_util::stream::StreamExt;
7+
8+
#[tokio::main]
9+
async fn main() {
10+
let configuration = datadog::Configuration::new();
11+
let api = MetricsAPI::with_config(configuration);
12+
let response = api.list_tag_configurations_with_pagination(
13+
ListTagConfigurationsOptionalParams::default().page_size(2),
14+
);
15+
pin_mut!(response);
16+
while let Some(resp) = response.next().await {
17+
if let Ok(value) = resp {
18+
println!("{:#?}", value);
19+
} else {
20+
println!("{:#?}", resp.unwrap_err());
21+
}
22+
}
23+
}

src/datadogV2/api/api_metrics.rs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
// This product includes software developed at Datadog (https://www.datadoghq.com/).
33
// Copyright 2019-Present Datadog, Inc.
44
use crate::datadog;
5+
use async_stream::try_stream;
56
use flate2::{
67
write::{GzEncoder, ZlibEncoder},
78
Compression,
89
};
10+
use futures_core::stream::Stream;
911
use reqwest::header::{HeaderMap, HeaderValue};
1012
use serde::{Deserialize, Serialize};
1113
use std::io::Write;
@@ -95,6 +97,12 @@ pub struct ListTagConfigurationsOptionalParams {
9597
/// The number of seconds of look back (from now) to apply to a filter[tag] or filter[queried] query.
9698
/// Default value is 3600 (1 hour), maximum value is 2,592,000 (30 days).
9799
pub window_seconds: Option<i64>,
100+
/// Maximum number of results returned.
101+
pub page_size: Option<i32>,
102+
/// String to query the next page of results.
103+
/// This key is provided with each valid response from the API in `meta.pagination.next_cursor`.
104+
/// Once the `meta.pagination.next_cursor` key is null, all pages have been retrieved.
105+
pub page_cursor: Option<String>,
98106
}
99107

100108
impl ListTagConfigurationsOptionalParams {
@@ -140,6 +148,18 @@ impl ListTagConfigurationsOptionalParams {
140148
self.window_seconds = Some(value);
141149
self
142150
}
151+
/// Maximum number of results returned.
152+
pub fn page_size(mut self, value: i32) -> Self {
153+
self.page_size = Some(value);
154+
self
155+
}
156+
/// String to query the next page of results.
157+
/// This key is provided with each valid response from the API in `meta.pagination.next_cursor`.
158+
/// Once the `meta.pagination.next_cursor` key is null, all pages have been retrieved.
159+
pub fn page_cursor(mut self, value: String) -> Self {
160+
self.page_cursor = Some(value);
161+
self
162+
}
143163
}
144164

145165
/// SubmitMetricsOptionalParams is a struct for passing parameters to the method [`MetricsAPI::submit_metrics`]
@@ -1440,6 +1460,9 @@ impl MetricsAPI {
14401460
}
14411461

14421462
/// Returns all metrics that can be configured in the Metrics Summary page or with Metrics without Limits™ (matching additional filters if specified).
1463+
/// Optionally, paginate by using the `page[cursor]` and/or `page[size]` query parameters.
1464+
/// 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.
1465+
/// Once the `meta.pagination.next_cursor` value is null, all pages have been retrieved.
14431466
pub async fn list_tag_configurations(
14441467
&self,
14451468
params: ListTagConfigurationsOptionalParams,
@@ -1461,7 +1484,48 @@ impl MetricsAPI {
14611484
}
14621485
}
14631486

1487+
pub fn list_tag_configurations_with_pagination(
1488+
&self,
1489+
mut params: ListTagConfigurationsOptionalParams,
1490+
) -> impl Stream<
1491+
Item = Result<
1492+
crate::datadogV2::model::MetricsAndMetricTagConfigurations,
1493+
datadog::Error<ListTagConfigurationsError>,
1494+
>,
1495+
> + '_ {
1496+
try_stream! {
1497+
let mut page_size: i32 = 10000;
1498+
if params.page_size.is_none() {
1499+
params.page_size = Some(page_size);
1500+
} else {
1501+
page_size = params.page_size.unwrap().clone();
1502+
}
1503+
loop {
1504+
let resp = self.list_tag_configurations(params.clone()).await?;
1505+
let Some(data) = resp.data else { break };
1506+
1507+
let r = data;
1508+
let count = r.len();
1509+
for team in r {
1510+
yield team;
1511+
}
1512+
1513+
if count < page_size as usize {
1514+
break;
1515+
}
1516+
let Some(meta) = resp.meta else { break };
1517+
let Some(pagination) = meta.pagination else { break };
1518+
let Some(next_cursor) = pagination.next_cursor.unwrap() else { break };
1519+
1520+
params.page_cursor = Some(next_cursor);
1521+
}
1522+
}
1523+
}
1524+
14641525
/// Returns all metrics that can be configured in the Metrics Summary page or with Metrics without Limits™ (matching additional filters if specified).
1526+
/// Optionally, paginate by using the `page[cursor]` and/or `page[size]` query parameters.
1527+
/// 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.
1528+
/// Once the `meta.pagination.next_cursor` value is null, all pages have been retrieved.
14651529
pub async fn list_tag_configurations_with_http_info(
14661530
&self,
14671531
params: ListTagConfigurationsOptionalParams,
@@ -1482,6 +1546,8 @@ impl MetricsAPI {
14821546
let filter_queried = params.filter_queried;
14831547
let filter_tags = params.filter_tags;
14841548
let window_seconds = params.window_seconds;
1549+
let page_size = params.page_size;
1550+
let page_cursor = params.page_cursor;
14851551

14861552
let local_client = &self.client;
14871553

@@ -1522,6 +1588,14 @@ impl MetricsAPI {
15221588
local_req_builder =
15231589
local_req_builder.query(&[("window[seconds]", &local_query_param.to_string())]);
15241590
};
1591+
if let Some(ref local_query_param) = page_size {
1592+
local_req_builder =
1593+
local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
1594+
};
1595+
if let Some(ref local_query_param) = page_cursor {
1596+
local_req_builder =
1597+
local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
1598+
};
15251599

15261600
// build headers
15271601
let mut headers = HeaderMap::new();

src/datadogV2/model/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,14 @@ pub mod model_metric_tag_configuration_type;
19101910
pub use self::model_metric_tag_configuration_type::MetricTagConfigurationType;
19111911
pub mod model_metrics_and_metric_tag_configurations;
19121912
pub use self::model_metrics_and_metric_tag_configurations::MetricsAndMetricTagConfigurations;
1913+
pub mod model_metrics_list_response_links;
1914+
pub use self::model_metrics_list_response_links::MetricsListResponseLinks;
1915+
pub mod model_metric_pagination_meta;
1916+
pub use self::model_metric_pagination_meta::MetricPaginationMeta;
1917+
pub mod model_metric_meta_page;
1918+
pub use self::model_metric_meta_page::MetricMetaPage;
1919+
pub mod model_metric_meta_page_type;
1920+
pub use self::model_metric_meta_page_type::MetricMetaPageType;
19131921
pub mod model_metric_bulk_tag_config_delete_request;
19141922
pub use self::model_metric_bulk_tag_config_delete_request::MetricBulkTagConfigDeleteRequest;
19151923
pub mod model_metric_bulk_tag_config_delete;

0 commit comments

Comments
 (0)