Skip to content

Commit 9a57288

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Update template variable schemas with type field in dashboards and shared dashboards endpoints for group by template variables (#752)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 30645a4 commit 9a57288

14 files changed

+576
-7
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": "2025-06-30 10:29:36.333199",
8-
"spec_repo_commit": "be63084a"
7+
"regenerated": "2025-06-30 17:05:08.769740",
8+
"spec_repo_commit": "d8e7ee77"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-06-30 10:29:36.349093",
13-
"spec_repo_commit": "be63084a"
12+
"regenerated": "2025-06-30 17:05:08.786526",
13+
"spec_repo_commit": "d8e7ee77"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,13 @@ components:
15501550
example: host
15511551
nullable: true
15521552
type: string
1553+
type:
1554+
description: The type of variable. This is to differentiate between filter
1555+
variables (interpolated in query) and group by variables (interpolated
1556+
into group by).
1557+
example: group
1558+
nullable: true
1559+
type: string
15531560
required:
15541561
- name
15551562
type: object
@@ -12578,6 +12585,12 @@ components:
1257812585
prefix:
1257912586
description: The tag/attribute key associated with the template variable.
1258012587
type: string
12588+
type:
12589+
description: The type of variable. This is to differentiate between filter
12590+
variables (interpolated in query) and group by variables (interpolated
12591+
into group by).
12592+
nullable: true
12593+
type: string
1258112594
visible_tags:
1258212595
description: List of visible tag values on the shared dashboard.
1258312596
items:
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Create a new dashboard with template variable type field returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV1::api_dashboards::DashboardsAPI;
4+
use datadog_api_client::datadogV1::model::Dashboard;
5+
use datadog_api_client::datadogV1::model::DashboardLayoutType;
6+
use datadog_api_client::datadogV1::model::DashboardReflowType;
7+
use datadog_api_client::datadogV1::model::DashboardTemplateVariable;
8+
use datadog_api_client::datadogV1::model::HostMapRequest;
9+
use datadog_api_client::datadogV1::model::HostMapWidgetDefinition;
10+
use datadog_api_client::datadogV1::model::HostMapWidgetDefinitionRequests;
11+
use datadog_api_client::datadogV1::model::HostMapWidgetDefinitionType;
12+
use datadog_api_client::datadogV1::model::Widget;
13+
use datadog_api_client::datadogV1::model::WidgetDefinition;
14+
15+
#[tokio::main]
16+
async fn main() {
17+
let body = Dashboard::new(
18+
DashboardLayoutType::ORDERED,
19+
"".to_string(),
20+
vec![Widget::new(WidgetDefinition::HostMapWidgetDefinition(
21+
Box::new(HostMapWidgetDefinition::new(
22+
HostMapWidgetDefinitionRequests::new()
23+
.fill(HostMapRequest::new().q("avg:system.cpu.user{*}".to_string())),
24+
HostMapWidgetDefinitionType::HOSTMAP,
25+
)),
26+
))],
27+
)
28+
.description(None)
29+
.notify_list(Some(vec![]))
30+
.reflow_type(DashboardReflowType::AUTO)
31+
.restricted_roles(vec![])
32+
.template_variables(Some(vec![DashboardTemplateVariable::new(
33+
"group_by_var".to_string(),
34+
)
35+
.available_values(Some(vec![
36+
"service".to_string(),
37+
"datacenter".to_string(),
38+
"env".to_string(),
39+
]))
40+
.defaults(vec!["service".to_string(), "datacenter".to_string()])
41+
.type_(Some("group".to_string()))]));
42+
let configuration = datadog::Configuration::new();
43+
let api = DashboardsAPI::with_config(configuration);
44+
let resp = api.create_dashboard(body).await;
45+
if let Ok(value) = resp {
46+
println!("{:#?}", value);
47+
} else {
48+
println!("{:#?}", resp.unwrap_err());
49+
}
50+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Create a shared dashboard with a group template variable returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV1::api_dashboards::DashboardsAPI;
4+
use datadog_api_client::datadogV1::model::DashboardGlobalTime;
5+
use datadog_api_client::datadogV1::model::DashboardGlobalTimeLiveSpan;
6+
use datadog_api_client::datadogV1::model::DashboardShareType;
7+
use datadog_api_client::datadogV1::model::DashboardType;
8+
use datadog_api_client::datadogV1::model::SelectableTemplateVariableItems;
9+
use datadog_api_client::datadogV1::model::SharedDashboard;
10+
11+
#[tokio::main]
12+
async fn main() {
13+
// there is a valid "dashboard" in the system
14+
let dashboard_id = std::env::var("DASHBOARD_ID").unwrap();
15+
let body = SharedDashboard::new(dashboard_id.clone(), DashboardType::CUSTOM_TIMEBOARD)
16+
.global_time(
17+
DashboardGlobalTime::new().live_span(DashboardGlobalTimeLiveSpan::PAST_ONE_HOUR),
18+
)
19+
.selectable_template_vars(Some(vec![SelectableTemplateVariableItems::new()
20+
.default_value("*".to_string())
21+
.name("group_by_var".to_string())
22+
.type_(Some("group".to_string()))
23+
.visible_tags(Some(vec![
24+
"selectableValue1".to_string(),
25+
"selectableValue2".to_string(),
26+
]))]))
27+
.share_type(Some(DashboardShareType::OPEN));
28+
let configuration = datadog::Configuration::new();
29+
let api = DashboardsAPI::with_config(configuration);
30+
let resp = api.create_public_dashboard(body).await;
31+
if let Ok(value) = resp {
32+
println!("{:#?}", value);
33+
} else {
34+
println!("{:#?}", resp.unwrap_err());
35+
}
36+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Update a shared dashboard with selectable_template_vars returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV1::api_dashboards::DashboardsAPI;
4+
use datadog_api_client::datadogV1::model::DashboardGlobalTimeLiveSpan;
5+
use datadog_api_client::datadogV1::model::DashboardShareType;
6+
use datadog_api_client::datadogV1::model::SelectableTemplateVariableItems;
7+
use datadog_api_client::datadogV1::model::SharedDashboardUpdateRequest;
8+
use datadog_api_client::datadogV1::model::SharedDashboardUpdateRequestGlobalTime;
9+
10+
#[tokio::main]
11+
async fn main() {
12+
// there is a valid "shared_dashboard" in the system
13+
let shared_dashboard_token = std::env::var("SHARED_DASHBOARD_TOKEN").unwrap();
14+
let body = SharedDashboardUpdateRequest::new()
15+
.global_time(Some(
16+
SharedDashboardUpdateRequestGlobalTime::new()
17+
.live_span(DashboardGlobalTimeLiveSpan::PAST_FIFTEEN_MINUTES),
18+
))
19+
.selectable_template_vars(Some(vec![SelectableTemplateVariableItems::new()
20+
.default_value("*".to_string())
21+
.name("group_by_var".to_string())
22+
.type_(Some("group".to_string()))
23+
.visible_tags(Some(vec![
24+
"selectableValue1".to_string(),
25+
"selectableValue2".to_string(),
26+
]))]))
27+
.share_list(Some(vec![]))
28+
.share_type(Some(DashboardShareType::OPEN));
29+
let configuration = datadog::Configuration::new();
30+
let api = DashboardsAPI::with_config(configuration);
31+
let resp = api
32+
.update_public_dashboard(shared_dashboard_token.clone(), body)
33+
.await;
34+
if let Ok(value) = resp {
35+
println!("{:#?}", value);
36+
} else {
37+
println!("{:#?}", resp.unwrap_err());
38+
}
39+
}

src/datadogV1/model/model_dashboard_template_variable.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ pub struct DashboardTemplateVariable {
3535
/// The tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down.
3636
#[serde(rename = "prefix", default, with = "::serde_with::rust::double_option")]
3737
pub prefix: Option<Option<String>>,
38+
/// The type of variable. This is to differentiate between filter variables (interpolated in query) and group by variables (interpolated into group by).
39+
#[serde(rename = "type", default, with = "::serde_with::rust::double_option")]
40+
pub type_: Option<Option<String>>,
3841
#[serde(flatten)]
3942
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
4043
#[serde(skip)]
@@ -51,6 +54,7 @@ impl DashboardTemplateVariable {
5154
defaults: None,
5255
name,
5356
prefix: None,
57+
type_: None,
5458
additional_properties: std::collections::BTreeMap::new(),
5559
_unparsed: false,
5660
}
@@ -80,6 +84,12 @@ impl DashboardTemplateVariable {
8084
self
8185
}
8286

87+
#[allow(deprecated)]
88+
pub fn type_(mut self, value: Option<String>) -> Self {
89+
self.type_ = Some(value);
90+
self
91+
}
92+
8393
pub fn additional_properties(
8494
mut self,
8595
value: std::collections::BTreeMap<String, serde_json::Value>,
@@ -111,6 +121,7 @@ impl<'de> Deserialize<'de> for DashboardTemplateVariable {
111121
let mut defaults: Option<Vec<String>> = None;
112122
let mut name: Option<String> = None;
113123
let mut prefix: Option<Option<String>> = None;
124+
let mut type_: Option<Option<String>> = None;
114125
let mut additional_properties: std::collections::BTreeMap<
115126
String,
116127
serde_json::Value,
@@ -138,6 +149,9 @@ impl<'de> Deserialize<'de> for DashboardTemplateVariable {
138149
"prefix" => {
139150
prefix = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
140151
}
152+
"type" => {
153+
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
154+
}
141155
&_ => {
142156
if let Ok(value) = serde_json::from_value(v.clone()) {
143157
additional_properties.insert(k, value);
@@ -154,6 +168,7 @@ impl<'de> Deserialize<'de> for DashboardTemplateVariable {
154168
defaults,
155169
name,
156170
prefix,
171+
type_,
157172
additional_properties,
158173
_unparsed,
159174
};

src/datadogV1/model/model_selectable_template_variable_items.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ pub struct SelectableTemplateVariableItems {
2020
/// The tag/attribute key associated with the template variable.
2121
#[serde(rename = "prefix")]
2222
pub prefix: Option<String>,
23+
/// The type of variable. This is to differentiate between filter variables (interpolated in query) and group by variables (interpolated into group by).
24+
#[serde(rename = "type", default, with = "::serde_with::rust::double_option")]
25+
pub type_: Option<Option<String>>,
2326
/// List of visible tag values on the shared dashboard.
2427
#[serde(
2528
rename = "visible_tags",
@@ -40,6 +43,7 @@ impl SelectableTemplateVariableItems {
4043
default_value: None,
4144
name: None,
4245
prefix: None,
46+
type_: None,
4347
visible_tags: None,
4448
additional_properties: std::collections::BTreeMap::new(),
4549
_unparsed: false,
@@ -61,6 +65,11 @@ impl SelectableTemplateVariableItems {
6165
self
6266
}
6367

68+
pub fn type_(mut self, value: Option<String>) -> Self {
69+
self.type_ = Some(value);
70+
self
71+
}
72+
6473
pub fn visible_tags(mut self, value: Option<Vec<String>>) -> Self {
6574
self.visible_tags = Some(value);
6675
self
@@ -101,6 +110,7 @@ impl<'de> Deserialize<'de> for SelectableTemplateVariableItems {
101110
let mut default_value: Option<String> = None;
102111
let mut name: Option<String> = None;
103112
let mut prefix: Option<String> = None;
113+
let mut type_: Option<Option<String>> = None;
104114
let mut visible_tags: Option<Option<Vec<String>>> = None;
105115
let mut additional_properties: std::collections::BTreeMap<
106116
String,
@@ -129,6 +139,9 @@ impl<'de> Deserialize<'de> for SelectableTemplateVariableItems {
129139
}
130140
prefix = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
131141
}
142+
"type" => {
143+
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
144+
}
132145
"visible_tags" => {
133146
visible_tags =
134147
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
@@ -145,6 +158,7 @@ impl<'de> Deserialize<'de> for SelectableTemplateVariableItems {
145158
default_value,
146159
name,
147160
prefix,
161+
type_,
148162
visible_tags,
149163
additional_properties,
150164
_unparsed,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-06-30T15:47:16.966Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"http_interactions": [
3+
{
4+
"request": {
5+
"body": {
6+
"string": "{\"description\":null,\"layout_type\":\"ordered\",\"notify_list\":[],\"reflow_type\":\"auto\",\"restricted_roles\":[],\"template_variables\":[{\"available_values\":[\"service\",\"datacenter\",\"env\"],\"defaults\":[\"service\",\"datacenter\"],\"name\":\"group_by_var\",\"type\":\"group\"}],\"title\":\"\",\"widgets\":[{\"definition\":{\"requests\":{\"fill\":{\"q\":\"avg:system.cpu.user{*}\"}},\"type\":\"hostmap\"}}]}",
7+
"encoding": null
8+
},
9+
"headers": {
10+
"Accept": [
11+
"application/json"
12+
],
13+
"Content-Type": [
14+
"application/json"
15+
]
16+
},
17+
"method": "post",
18+
"uri": "https://api.datadoghq.com/api/v1/dashboard"
19+
},
20+
"response": {
21+
"body": {
22+
"string": "{\"id\":\"zb6-rsj-zej\",\"title\":\"\",\"description\":null,\"author_handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"author_name\":\"CI Account\",\"layout_type\":\"ordered\",\"url\":\"/dashboard/zb6-rsj-zej/\",\"template_variables\":[{\"available_values\":[\"service\",\"datacenter\",\"env\"],\"defaults\":[\"service\",\"datacenter\"],\"name\":\"group_by_var\",\"type\":\"group\"}],\"widgets\":[{\"definition\":{\"requests\":{\"fill\":{\"q\":\"avg:system.cpu.user{*}\"}},\"type\":\"hostmap\"},\"id\":2230877325217406}],\"notify_list\":[],\"created_at\":\"2025-06-30T15:47:17.444093+00:00\",\"modified_at\":\"2025-06-30T15:47:17.444093+00:00\",\"reflow_type\":\"auto\",\"restricted_roles\":[]}\n",
23+
"encoding": null
24+
},
25+
"headers": {
26+
"Content-Type": [
27+
"application/json"
28+
]
29+
},
30+
"status": {
31+
"code": 200,
32+
"message": "OK"
33+
}
34+
},
35+
"recorded_at": "Mon, 30 Jun 2025 15:47:16 GMT"
36+
},
37+
{
38+
"request": {
39+
"body": "",
40+
"headers": {
41+
"Accept": [
42+
"application/json"
43+
]
44+
},
45+
"method": "delete",
46+
"uri": "https://api.datadoghq.com/api/v1/dashboard/zb6-rsj-zej"
47+
},
48+
"response": {
49+
"body": {
50+
"string": "{\"deleted_dashboard_id\":\"zb6-rsj-zej\"}\n",
51+
"encoding": null
52+
},
53+
"headers": {
54+
"Content-Type": [
55+
"application/json"
56+
]
57+
},
58+
"status": {
59+
"code": 200,
60+
"message": "OK"
61+
}
62+
},
63+
"recorded_at": "Mon, 30 Jun 2025 15:47:16 GMT"
64+
}
65+
],
66+
"recorded_with": "VCR 6.0.0"
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-06-30T15:47:18.224Z

0 commit comments

Comments
 (0)