Skip to content

Document extra parameter for metric volumes endpoint #754

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

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": "2025-06-26 17:56:17.758022",
"spec_repo_commit": "76086f13"
"regenerated": "2025-06-30 08:48:14.436273",
"spec_repo_commit": "36849030"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-06-26 17:56:17.774479",
"spec_repo_commit": "76086f13"
"regenerated": "2025-06-30 08:48:14.452070",
"spec_repo_commit": "36849030"
}
}
}
11 changes: 11 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52633,6 +52633,17 @@ paths:
operationId: ListVolumesByMetricName
parameters:
- $ref: '#/components/parameters/MetricName'
- description: 'The number of seconds of look back (from now).

Default value is 604,800 (1 week), minimum value is 7200 (2 hours), maximum
value is 2,630,000 (1 month).'
example: 7200
in: query
name: window[seconds]
required: false
schema:
format: int64
type: integer
responses:
'200':
content:
Expand Down
6 changes: 5 additions & 1 deletion examples/v2_metrics_ListVolumesByMetricName.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// List distinct metric volumes by metric name returns "Success" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::ListVolumesByMetricNameOptionalParams;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.list_volumes_by_metric_name("static_test_metric_donotdelete".to_string())
.list_volumes_by_metric_name(
"static_test_metric_donotdelete".to_string(),
ListVolumesByMetricNameOptionalParams::default(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
Expand Down
30 changes: 29 additions & 1 deletion src/datadogV2/api/api_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,24 @@ impl ListTagConfigurationsOptionalParams {
}
}

/// ListVolumesByMetricNameOptionalParams is a struct for passing parameters to the method [`MetricsAPI::list_volumes_by_metric_name`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListVolumesByMetricNameOptionalParams {
/// The number of seconds of look back (from now).
/// Default value is 604,800 (1 week), minimum value is 7200 (2 hours), maximum value is 2,630,000 (1 month).
pub window_seconds: Option<i64>,
}

impl ListVolumesByMetricNameOptionalParams {
/// The number of seconds of look back (from now).
/// Default value is 604,800 (1 week), minimum value is 7200 (2 hours), maximum value is 2,630,000 (1 month).
pub fn window_seconds(mut self, value: i64) -> Self {
self.window_seconds = Some(value);
self
}
}

/// SubmitMetricsOptionalParams is a struct for passing parameters to the method [`MetricsAPI::submit_metrics`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
Expand Down Expand Up @@ -1794,12 +1812,13 @@ impl MetricsAPI {
pub async fn list_volumes_by_metric_name(
&self,
metric_name: String,
params: ListVolumesByMetricNameOptionalParams,
) -> Result<
crate::datadogV2::model::MetricVolumesResponse,
datadog::Error<ListVolumesByMetricNameError>,
> {
match self
.list_volumes_by_metric_name_with_http_info(metric_name)
.list_volumes_by_metric_name_with_http_info(metric_name, params)
.await
{
Ok(response_content) => {
Expand All @@ -1821,13 +1840,17 @@ impl MetricsAPI {
pub async fn list_volumes_by_metric_name_with_http_info(
&self,
metric_name: String,
params: ListVolumesByMetricNameOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::MetricVolumesResponse>,
datadog::Error<ListVolumesByMetricNameError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_volumes_by_metric_name";

// unbox and build optional parameters
let window_seconds = params.window_seconds;

let local_client = &self.client;

let local_uri_str = format!(
Expand All @@ -1838,6 +1861,11 @@ impl MetricsAPI {
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());

if let Some(ref local_query_param) = window_seconds {
local_req_builder =
local_req_builder.query(&[("window[seconds]", &local_query_param.to_string())]);
};

// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));
Expand Down
32 changes: 19 additions & 13 deletions tests/scenarios/function_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22236,20 +22236,26 @@ fn test_v2_list_volumes_by_metric_name(
.expect("api instance not found");
let metric_name =
serde_json::from_value(_parameters.get("metric_name").unwrap().clone()).unwrap();
let response = match block_on(api.list_volumes_by_metric_name_with_http_info(metric_name)) {
Ok(response) => response,
Err(error) => {
return match error {
Error::ResponseError(e) => {
world.response.code = e.status.as_u16();
if let Some(entity) = e.entity {
world.response.object = serde_json::to_value(entity).unwrap();
let window_seconds = _parameters
.get("window[seconds]")
.and_then(|param| Some(serde_json::from_value(param.clone()).unwrap()));
let mut params = datadogV2::api_metrics::ListVolumesByMetricNameOptionalParams::default();
params.window_seconds = window_seconds;
let response =
match block_on(api.list_volumes_by_metric_name_with_http_info(metric_name, params)) {
Ok(response) => response,
Err(error) => {
return match error {
Error::ResponseError(e) => {
world.response.code = e.status.as_u16();
if let Some(entity) = e.entity {
world.response.object = serde_json::to_value(entity).unwrap();
}
}
}
_ => panic!("error parsing response: {error}"),
};
}
};
_ => panic!("error parsing response: {error}"),
};
}
};
world.response.object = serde_json::to_value(response.entity).unwrap();
world.response.code = response.status.as_u16();
}
Expand Down
Loading