Skip to content

Commit 887b919

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add edited_before and viewed_before filters to ListDashboardsUsage (#1690)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 4c49a56 commit 887b919

15 files changed

Lines changed: 268 additions & 15 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27293,7 +27293,7 @@ components:
2729327293
- attributes
2729427294
type: object
2729527295
DashboardUsageAttributes:
27296-
description: Usage statistics for a dashboard.
27296+
description: Usage statistics for a dashboard. The `viewer` field and all view-count fields (`total_views`, `viewed_at`, `total_views_by_type`) are populated only when Real User Monitoring (RUM) is active for the org.
2729727297
properties:
2729827298
author:
2729927299
$ref: "#/components/schemas/DashboardUsageUser"
@@ -27332,7 +27332,7 @@ components:
2733227332
example: My production overview
2733327333
type: string
2733427334
total_views:
27335-
description: The total number of times the dashboard has been viewed.
27335+
description: Total view count for the dashboard. Counts only views captured by Real User Monitoring (RUM); `0` in orgs without RUM.
2733627336
example: 42
2733727337
format: int64
2733827338
type: integer
@@ -27341,11 +27341,11 @@ components:
2734127341
description: View count for that view type.
2734227342
format: int64
2734327343
type: integer
27344-
description: View counts keyed by view type. Possible keys are `in_app`, `embed`, `public`, `shared`, `api`, and `unknown`.
27344+
description: View counts keyed by view type (`in_app`, `embed`, `public`, `shared`, `api`, `unknown`). Counts only views captured by Real User Monitoring (RUM); empty in orgs without RUM.
2734527345
nullable: true
2734627346
type: object
2734727347
viewed_at:
27348-
description: When the dashboard was most recently viewed.
27348+
description: When the dashboard was most recently viewed. Populated only when Real User Monitoring (RUM) is active for the org; `null` in orgs without RUM.
2734927349
example: "2026-05-01T14:22:10.000Z"
2735027350
format: date-time
2735127351
nullable: true
@@ -117452,7 +117452,7 @@ paths:
117452117452
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
117453117453
/api/v2/dashboards/usage:
117454117454
get:
117455-
description: Get paginated usage statistics for every dashboard in the caller's organization. Use `page[limit]` and `page[offset]` to walk the result set.
117455+
description: Get paginated usage statistics for every dashboard in the caller's organization. Use `page[limit]` and `page[offset]` to walk the result set. Use `filter[edited_before]` or `filter[viewed_before]` to narrow results by recency. View-count fields depend on Real User Monitoring (RUM) and are `null` or `0` in orgs without RUM.
117456117456
operationId: ListDashboardsUsage
117457117457
parameters:
117458117458
- description: Maximum number of dashboards to return per page. Server-side maximum is 500; values above 500 return a 400 Bad Request.
@@ -117472,6 +117472,20 @@ paths:
117472117472
format: int64
117473117473
minimum: 0
117474117474
type: integer
117475+
- description: Return only dashboards whose last edit (`edited_at`) is strictly before this ISO 8601 timestamp (`edited_at < value`; boundary matches are excluded). Must include a timezone offset (for example, `Z` or `+00:00`); naive timestamps return HTTP 400.
117476+
in: query
117477+
name: filter[edited_before]
117478+
required: false
117479+
schema:
117480+
example: "2025-04-26T00:00:00Z"
117481+
type: string
117482+
- description: Return only dashboards whose most recent view (`viewed_at`) is strictly before this ISO 8601 timestamp, including dashboards that have never been viewed. Must include a timezone offset; naive timestamps return HTTP 400. Orgs without Real User Monitoring (RUM) will see all dashboards returned by this filter.
117483+
in: query
117484+
name: filter[viewed_before]
117485+
required: false
117486+
schema:
117487+
example: "2025-04-26T00:00:00Z"
117488+
type: string
117475117489
responses:
117476117490
"200":
117477117491
content:
@@ -117553,7 +117567,7 @@ paths:
117553117567
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
117554117568
/api/v2/dashboards/{dashboard_id}/usage:
117555117569
get:
117556-
description: Get usage statistics for a single dashboard. The response includes view counts, the most recent view and edit times, widget counts, and the dashboard quality score.
117570+
description: Get usage statistics for a single dashboard. The response includes view counts, the most recent view and edit times, widget counts, and the dashboard quality score. View-count fields depend on Real User Monitoring (RUM) and are `null` or `0` in orgs without RUM.
117557117571
operationId: GetDashboardUsage
117558117572
parameters:
117559117573
- description: The ID of the dashboard.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Get usage stats for all dashboards with edited_before filter returns "OK"
2+
// response
3+
use datadog_api_client::datadog;
4+
use datadog_api_client::datadogV2::api_dashboards::DashboardsAPI;
5+
use datadog_api_client::datadogV2::api_dashboards::ListDashboardsUsageOptionalParams;
6+
7+
#[tokio::main]
8+
async fn main() {
9+
let mut configuration = datadog::Configuration::new();
10+
configuration.set_unstable_operation_enabled("v2.ListDashboardsUsage", true);
11+
let api = DashboardsAPI::with_config(configuration);
12+
let resp = api
13+
.list_dashboards_usage(
14+
ListDashboardsUsageOptionalParams::default()
15+
.filter_edited_before("2025-04-26T00:00:00Z".to_string()),
16+
)
17+
.await;
18+
if let Ok(value) = resp {
19+
println!("{:#?}", value);
20+
} else {
21+
println!("{:#?}", resp.unwrap_err());
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Get usage stats for all dashboards with viewed_before filter returns "OK"
2+
// response
3+
use datadog_api_client::datadog;
4+
use datadog_api_client::datadogV2::api_dashboards::DashboardsAPI;
5+
use datadog_api_client::datadogV2::api_dashboards::ListDashboardsUsageOptionalParams;
6+
7+
#[tokio::main]
8+
async fn main() {
9+
let mut configuration = datadog::Configuration::new();
10+
configuration.set_unstable_operation_enabled("v2.ListDashboardsUsage", true);
11+
let api = DashboardsAPI::with_config(configuration);
12+
let resp = api
13+
.list_dashboards_usage(
14+
ListDashboardsUsageOptionalParams::default()
15+
.filter_viewed_before("2025-04-26T00:00:00Z".to_string()),
16+
)
17+
.await;
18+
if let Ok(value) = resp {
19+
println!("{:#?}", value);
20+
} else {
21+
println!("{:#?}", resp.unwrap_err());
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Get usage stats for all dashboards with both filters returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_dashboards::DashboardsAPI;
4+
use datadog_api_client::datadogV2::api_dashboards::ListDashboardsUsageOptionalParams;
5+
6+
#[tokio::main]
7+
async fn main() {
8+
let mut configuration = datadog::Configuration::new();
9+
configuration.set_unstable_operation_enabled("v2.ListDashboardsUsage", true);
10+
let api = DashboardsAPI::with_config(configuration);
11+
let resp = api
12+
.list_dashboards_usage(
13+
ListDashboardsUsageOptionalParams::default()
14+
.filter_edited_before("2025-04-26T00:00:00Z".to_string())
15+
.filter_viewed_before("2025-04-26T00:00:00Z".to_string()),
16+
)
17+
.await;
18+
if let Ok(value) = resp {
19+
println!("{:#?}", value);
20+
} else {
21+
println!("{:#?}", resp.unwrap_err());
22+
}
23+
}

src/datadogV2/api/api_dashboards.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ pub struct ListDashboardsUsageOptionalParams {
1616
pub page_limit: Option<i64>,
1717
/// Zero-based offset into the result set.
1818
pub page_offset: Option<i64>,
19+
/// Return only dashboards whose last edit (`edited_at`) is strictly before this ISO 8601 timestamp (`edited_at < value`; boundary matches are excluded). Must include a timezone offset (for example, `Z` or `+00:00`); naive timestamps return HTTP 400.
20+
pub filter_edited_before: Option<String>,
21+
/// Return only dashboards whose most recent view (`viewed_at`) is strictly before this ISO 8601 timestamp, including dashboards that have never been viewed. Must include a timezone offset; naive timestamps return HTTP 400. Orgs without Real User Monitoring (RUM) will see all dashboards returned by this filter.
22+
pub filter_viewed_before: Option<String>,
1923
}
2024

2125
impl ListDashboardsUsageOptionalParams {
@@ -29,6 +33,16 @@ impl ListDashboardsUsageOptionalParams {
2933
self.page_offset = Some(value);
3034
self
3135
}
36+
/// Return only dashboards whose last edit (`edited_at`) is strictly before this ISO 8601 timestamp (`edited_at < value`; boundary matches are excluded). Must include a timezone offset (for example, `Z` or `+00:00`); naive timestamps return HTTP 400.
37+
pub fn filter_edited_before(mut self, value: String) -> Self {
38+
self.filter_edited_before = Some(value);
39+
self
40+
}
41+
/// Return only dashboards whose most recent view (`viewed_at`) is strictly before this ISO 8601 timestamp, including dashboards that have never been viewed. Must include a timezone offset; naive timestamps return HTTP 400. Orgs without Real User Monitoring (RUM) will see all dashboards returned by this filter.
42+
pub fn filter_viewed_before(mut self, value: String) -> Self {
43+
self.filter_viewed_before = Some(value);
44+
self
45+
}
3246
}
3347

3448
/// GetDashboardUsageError is a struct for typed errors of method [`DashboardsAPI::get_dashboard_usage`]
@@ -124,7 +138,7 @@ impl DashboardsAPI {
124138
Self { config, client }
125139
}
126140

127-
/// Get usage statistics for a single dashboard. The response includes view counts, the most recent view and edit times, widget counts, and the dashboard quality score.
141+
/// Get usage statistics for a single dashboard. The response includes view counts, the most recent view and edit times, widget counts, and the dashboard quality score. View-count fields depend on Real User Monitoring (RUM) and are `null` or `0` in orgs without RUM.
128142
pub async fn get_dashboard_usage(
129143
&self,
130144
dashboard_id: String,
@@ -146,7 +160,7 @@ impl DashboardsAPI {
146160
}
147161
}
148162

149-
/// Get usage statistics for a single dashboard. The response includes view counts, the most recent view and edit times, widget counts, and the dashboard quality score.
163+
/// Get usage statistics for a single dashboard. The response includes view counts, the most recent view and edit times, widget counts, and the dashboard quality score. View-count fields depend on Real User Monitoring (RUM) and are `null` or `0` in orgs without RUM.
150164
pub async fn get_dashboard_usage_with_http_info(
151165
&self,
152166
dashboard_id: String,
@@ -241,7 +255,7 @@ impl DashboardsAPI {
241255
}
242256
}
243257

244-
/// Get paginated usage statistics for every dashboard in the caller's organization. Use `page[limit]` and `page[offset]` to walk the result set.
258+
/// Get paginated usage statistics for every dashboard in the caller's organization. Use `page[limit]` and `page[offset]` to walk the result set. Use `filter[edited_before]` or `filter[viewed_before]` to narrow results by recency. View-count fields depend on Real User Monitoring (RUM) and are `null` or `0` in orgs without RUM.
245259
pub async fn list_dashboards_usage(
246260
&self,
247261
params: ListDashboardsUsageOptionalParams,
@@ -299,7 +313,7 @@ impl DashboardsAPI {
299313
}
300314
}
301315

302-
/// Get paginated usage statistics for every dashboard in the caller's organization. Use `page[limit]` and `page[offset]` to walk the result set.
316+
/// Get paginated usage statistics for every dashboard in the caller's organization. Use `page[limit]` and `page[offset]` to walk the result set. Use `filter[edited_before]` or `filter[viewed_before]` to narrow results by recency. View-count fields depend on Real User Monitoring (RUM) and are `null` or `0` in orgs without RUM.
303317
pub async fn list_dashboards_usage_with_http_info(
304318
&self,
305319
params: ListDashboardsUsageOptionalParams,
@@ -321,6 +335,8 @@ impl DashboardsAPI {
321335
// unbox and build optional parameters
322336
let page_limit = params.page_limit;
323337
let page_offset = params.page_offset;
338+
let filter_edited_before = params.filter_edited_before;
339+
let filter_viewed_before = params.filter_viewed_before;
324340

325341
let local_client = &self.client;
326342

@@ -339,6 +355,14 @@ impl DashboardsAPI {
339355
local_req_builder =
340356
local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]);
341357
};
358+
if let Some(ref local_query_param) = filter_edited_before {
359+
local_req_builder = local_req_builder
360+
.query(&[("filter[edited_before]", &local_query_param.to_string())]);
361+
};
362+
if let Some(ref local_query_param) = filter_viewed_before {
363+
local_req_builder = local_req_builder
364+
.query(&[("filter[viewed_before]", &local_query_param.to_string())]);
365+
};
342366

343367
// build headers
344368
let mut headers = HeaderMap::new();

src/datadogV2/model/model_dashboard_usage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::fmt::{self, Formatter};
1111
#[skip_serializing_none]
1212
#[derive(Clone, Debug, PartialEq, Serialize)]
1313
pub struct DashboardUsage {
14-
/// Usage statistics for a dashboard.
14+
/// Usage statistics for a dashboard. The `viewer` field and all view-count fields (`total_views`, `viewed_at`, `total_views_by_type`) are populated only when Real User Monitoring (RUM) is active for the org.
1515
#[serde(rename = "attributes")]
1616
pub attributes: crate::datadogV2::model::DashboardUsageAttributes,
1717
/// The dashboard ID.

src/datadogV2/model/model_dashboard_usage_attributes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize};
66
use serde_with::skip_serializing_none;
77
use std::fmt::{self, Formatter};
88

9-
/// Usage statistics for a dashboard.
9+
/// Usage statistics for a dashboard. The `viewer` field and all view-count fields (`total_views`, `viewed_at`, `total_views_by_type`) are populated only when Real User Monitoring (RUM) is active for the org.
1010
#[non_exhaustive]
1111
#[skip_serializing_none]
1212
#[derive(Clone, Debug, PartialEq, Serialize)]
@@ -44,17 +44,17 @@ pub struct DashboardUsageAttributes {
4444
/// The dashboard title.
4545
#[serde(rename = "title")]
4646
pub title: Option<String>,
47-
/// The total number of times the dashboard has been viewed.
47+
/// Total view count for the dashboard. Counts only views captured by Real User Monitoring (RUM); `0` in orgs without RUM.
4848
#[serde(rename = "total_views")]
4949
pub total_views: Option<i64>,
50-
/// View counts keyed by view type. Possible keys are `in_app`, `embed`, `public`, `shared`, `api`, and `unknown`.
50+
/// View counts keyed by view type (`in_app`, `embed`, `public`, `shared`, `api`, `unknown`). Counts only views captured by Real User Monitoring (RUM); empty in orgs without RUM.
5151
#[serde(
5252
rename = "total_views_by_type",
5353
default,
5454
with = "::serde_with::rust::double_option"
5555
)]
5656
pub total_views_by_type: Option<Option<std::collections::BTreeMap<String, i64>>>,
57-
/// When the dashboard was most recently viewed.
57+
/// When the dashboard was most recently viewed. Populated only when Real User Monitoring (RUM) is active for the org; `null` in orgs without RUM.
5858
#[serde(
5959
rename = "viewed_at",
6060
default,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-06-01T18:15:39.812Z

tests/scenarios/cassettes/v2/dashboards/Get-usage-stats-for-all-dashboards-with-both-filters-returns-OK-response.json

Lines changed: 33 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-06-01T18:14:52.307Z

0 commit comments

Comments
 (0)