Skip to content

Commit 23808e4

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit ce29bccf of spec repo
1 parent d949e0d commit 23808e4

9 files changed

+213
-16
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-10-02 11:36:04.629320",
8-
"spec_repo_commit": "c09e55c6"
7+
"regenerated": "2024-10-02 13:56:31.817308",
8+
"spec_repo_commit": "ce29bccf"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-10-02 11:36:04.643479",
13-
"spec_repo_commit": "c09e55c6"
12+
"regenerated": "2024-10-02 13:56:31.831512",
13+
"spec_repo_commit": "ce29bccf"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18088,7 +18088,6 @@ components:
1808818088
$ref: '#/components/schemas/ToplistWidgetStackedType'
1808918089
required:
1809018090
- type
18091-
- legend
1809218091
type: object
1809318092
ToplistWidgetStackedType:
1809418093
default: stacked

examples/v1_dashboards_CreateDashboard_1213075383.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ async fn main() {
8585
ToplistWidgetDisplay::ToplistWidgetStacked(
8686
Box::new(
8787
ToplistWidgetStacked::new(
88-
ToplistWidgetLegend::INLINE,
8988
ToplistWidgetStackedType::STACKED,
90-
),
89+
).legend(ToplistWidgetLegend::INLINE),
9190
),
9291
),
9392
)
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// Create a new dashboard with a toplist widget with stacked type and no legend
2+
// specified
3+
use datadog_api_client::datadog;
4+
use datadog_api_client::datadogV1::api_dashboards::DashboardsAPI;
5+
use datadog_api_client::datadogV1::model::Dashboard;
6+
use datadog_api_client::datadogV1::model::DashboardLayoutType;
7+
use datadog_api_client::datadogV1::model::FormulaAndFunctionMetricAggregation;
8+
use datadog_api_client::datadogV1::model::FormulaAndFunctionMetricDataSource;
9+
use datadog_api_client::datadogV1::model::FormulaAndFunctionMetricQueryDefinition;
10+
use datadog_api_client::datadogV1::model::FormulaAndFunctionQueryDefinition;
11+
use datadog_api_client::datadogV1::model::FormulaAndFunctionResponseFormat;
12+
use datadog_api_client::datadogV1::model::GroupType;
13+
use datadog_api_client::datadogV1::model::ToplistWidgetDefinition;
14+
use datadog_api_client::datadogV1::model::ToplistWidgetDefinitionType;
15+
use datadog_api_client::datadogV1::model::ToplistWidgetDisplay;
16+
use datadog_api_client::datadogV1::model::ToplistWidgetRequest;
17+
use datadog_api_client::datadogV1::model::ToplistWidgetScaling;
18+
use datadog_api_client::datadogV1::model::ToplistWidgetStacked;
19+
use datadog_api_client::datadogV1::model::ToplistWidgetStackedType;
20+
use datadog_api_client::datadogV1::model::ToplistWidgetStyle;
21+
use datadog_api_client::datadogV1::model::Widget;
22+
use datadog_api_client::datadogV1::model::WidgetDefinition;
23+
use datadog_api_client::datadogV1::model::WidgetFormula;
24+
use datadog_api_client::datadogV1::model::WidgetGroupSort;
25+
use datadog_api_client::datadogV1::model::WidgetLayout;
26+
use datadog_api_client::datadogV1::model::WidgetLegacyLiveSpan;
27+
use datadog_api_client::datadogV1::model::WidgetSort;
28+
use datadog_api_client::datadogV1::model::WidgetSortBy;
29+
use datadog_api_client::datadogV1::model::WidgetSortOrderBy;
30+
use datadog_api_client::datadogV1::model::WidgetTextAlign;
31+
use datadog_api_client::datadogV1::model::WidgetTime;
32+
33+
#[tokio::main]
34+
async fn main() {
35+
let body =
36+
Dashboard::new(
37+
DashboardLayoutType::FREE,
38+
"Example-Dashboard".to_string(),
39+
vec![
40+
Widget::new(
41+
WidgetDefinition::ToplistWidgetDefinition(
42+
Box::new(
43+
ToplistWidgetDefinition::new(
44+
vec![
45+
ToplistWidgetRequest::new()
46+
.formulas(vec![WidgetFormula::new("query1".to_string())])
47+
.queries(
48+
vec![
49+
FormulaAndFunctionQueryDefinition
50+
::FormulaAndFunctionMetricQueryDefinition(
51+
Box::new(
52+
FormulaAndFunctionMetricQueryDefinition::new(
53+
FormulaAndFunctionMetricDataSource::METRICS,
54+
"query1".to_string(),
55+
"avg:system.cpu.user{*} by {service}".to_string(),
56+
).aggregator(FormulaAndFunctionMetricAggregation::AVG),
57+
),
58+
)
59+
],
60+
)
61+
.response_format(FormulaAndFunctionResponseFormat::SCALAR)
62+
.sort(
63+
WidgetSortBy::new()
64+
.count(10)
65+
.order_by(
66+
vec![
67+
WidgetSortOrderBy::WidgetGroupSort(
68+
Box::new(
69+
WidgetGroupSort::new(
70+
"service".to_string(),
71+
WidgetSort::ASCENDING,
72+
GroupType::GROUP,
73+
),
74+
),
75+
)
76+
],
77+
),
78+
)
79+
],
80+
ToplistWidgetDefinitionType::TOPLIST,
81+
)
82+
.style(
83+
ToplistWidgetStyle::new()
84+
.display(
85+
ToplistWidgetDisplay::ToplistWidgetStacked(
86+
Box::new(
87+
ToplistWidgetStacked::new(ToplistWidgetStackedType::STACKED),
88+
),
89+
),
90+
)
91+
.palette("dog_classic".to_string())
92+
.scaling(ToplistWidgetScaling::RELATIVE),
93+
)
94+
.time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
95+
.title("".to_string())
96+
.title_align(WidgetTextAlign::LEFT)
97+
.title_size("16".to_string()),
98+
),
99+
),
100+
).layout(WidgetLayout::new(15, 47, 0, 0))
101+
],
102+
)
103+
.description(Some("".to_string()))
104+
.is_read_only(false)
105+
.notify_list(Some(vec![]))
106+
.template_variables(Some(vec![]));
107+
let configuration = datadog::Configuration::new();
108+
let api = DashboardsAPI::with_config(configuration);
109+
let resp = api.create_dashboard(body).await;
110+
if let Ok(value) = resp {
111+
println!("{:#?}", value);
112+
} else {
113+
println!("{:#?}", resp.unwrap_err());
114+
}
115+
}

examples/v1_dashboards_CreateDashboard_2563642929.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ async fn main() {
8585
ToplistWidgetDisplay::ToplistWidgetStacked(
8686
Box::new(
8787
ToplistWidgetStacked::new(
88-
ToplistWidgetLegend::INLINE,
8988
ToplistWidgetStackedType::STACKED,
90-
),
89+
).legend(ToplistWidgetLegend::INLINE),
9190
),
9291
),
9392
)

src/datadogV1/model/model_toplist_widget_stacked.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::fmt::{self, Formatter};
1313
pub struct ToplistWidgetStacked {
1414
/// Top list widget stacked legend behavior.
1515
#[serde(rename = "legend")]
16-
pub legend: crate::datadogV1::model::ToplistWidgetLegend,
16+
pub legend: Option<crate::datadogV1::model::ToplistWidgetLegend>,
1717
/// Top list widget stacked display type.
1818
#[serde(rename = "type")]
1919
pub type_: crate::datadogV1::model::ToplistWidgetStackedType,
@@ -25,18 +25,20 @@ pub struct ToplistWidgetStacked {
2525
}
2626

2727
impl ToplistWidgetStacked {
28-
pub fn new(
29-
legend: crate::datadogV1::model::ToplistWidgetLegend,
30-
type_: crate::datadogV1::model::ToplistWidgetStackedType,
31-
) -> ToplistWidgetStacked {
28+
pub fn new(type_: crate::datadogV1::model::ToplistWidgetStackedType) -> ToplistWidgetStacked {
3229
ToplistWidgetStacked {
33-
legend,
30+
legend: None,
3431
type_,
3532
additional_properties: std::collections::BTreeMap::new(),
3633
_unparsed: false,
3734
}
3835
}
3936

37+
pub fn legend(mut self, value: crate::datadogV1::model::ToplistWidgetLegend) -> Self {
38+
self.legend = Some(value);
39+
self
40+
}
41+
4042
pub fn additional_properties(
4143
mut self,
4244
value: std::collections::BTreeMap<String, serde_json::Value>,
@@ -74,6 +76,9 @@ impl<'de> Deserialize<'de> for ToplistWidgetStacked {
7476
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
7577
match k.as_str() {
7678
"legend" => {
79+
if v.is_null() {
80+
continue;
81+
}
7782
legend = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
7883
if let Some(ref _legend) = legend {
7984
match _legend {
@@ -102,7 +107,6 @@ impl<'de> Deserialize<'de> for ToplistWidgetStacked {
102107
}
103108
}
104109
}
105-
let legend = legend.ok_or_else(|| M::Error::missing_field("legend"))?;
106110
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;
107111

108112
let content = ToplistWidgetStacked {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2024-09-30T17:24:52.299Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"http_interactions": [
3+
{
4+
"request": {
5+
"body": {
6+
"string": "{\"description\":\"\",\"is_read_only\":false,\"layout_type\":\"free\",\"notify_list\":[],\"template_variables\":[],\"title\":\"Test-Create_a_new_dashboard_with_a_toplist_widget_with_stacked_type_and_no_legend_specified-1727717092\",\"widgets\":[{\"definition\":{\"requests\":[{\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"aggregator\":\"avg\",\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*} by {service}\"}],\"response_format\":\"scalar\",\"sort\":{\"count\":10,\"order_by\":[{\"name\":\"service\",\"order\":\"asc\",\"type\":\"group\"}]}}],\"style\":{\"display\":{\"type\":\"stacked\"},\"palette\":\"dog_classic\",\"scaling\":\"relative\"},\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"toplist\"},\"layout\":{\"height\":15,\"width\":47,\"x\":0,\"y\":0}}]}",
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\":\"2az-xeg-xar\",\"title\":\"Test-Create_a_new_dashboard_with_a_toplist_widget_with_stacked_type_and_no_legend_specified-1727717092\",\"description\":\"\",\"author_handle\":\"[email protected]\",\"author_name\":null,\"layout_type\":\"free\",\"url\":\"/dashboard/2az-xeg-xar/test-createanewdashboardwithatoplistwidgetwithstackedtypeandnolegendspecified-17\",\"is_read_only\":false,\"template_variables\":[],\"widgets\":[{\"definition\":{\"requests\":[{\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"aggregator\":\"avg\",\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*} by {service}\"}],\"response_format\":\"scalar\",\"sort\":{\"count\":10,\"order_by\":[{\"name\":\"service\",\"order\":\"asc\",\"type\":\"group\"}]}}],\"style\":{\"display\":{\"type\":\"stacked\"},\"palette\":\"dog_classic\",\"scaling\":\"relative\"},\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"toplist\"},\"layout\":{\"height\":15,\"width\":47,\"x\":0,\"y\":0},\"id\":688132644515996}],\"notify_list\":[],\"created_at\":\"2024-09-30T17:24:52.542207+00:00\",\"modified_at\":\"2024-09-30T17:24:52.542207+00:00\",\"experience_type\":\"default\",\"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 Sep 2024 17:24:52 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/2az-xeg-xar"
47+
},
48+
"response": {
49+
"body": {
50+
"string": "{\"deleted_dashboard_id\":\"2az-xeg-xar\"}\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 Sep 2024 17:24:52 GMT"
64+
}
65+
],
66+
"recorded_with": "VCR 6.0.0"
67+
}

tests/scenarios/features/v1/dashboards.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,19 @@ Feature: Dashboards
206206
And the response "widgets[0].definition.requests[0].sort.order_by[0].type" is equal to "group"
207207
And the response "widgets[0].definition.requests[0].sort.order_by[0].name" is equal to "service"
208208

209+
@skip-typescript @team:DataDog/dashboards-backend
210+
Scenario: Create a new dashboard with a toplist widget with stacked type and no legend specified
211+
Given new "CreateDashboard" request
212+
And body with value {"title":"{{ unique }}","description":"","widgets":[{"layout":{"x":0,"y":0,"width":47,"height":15},"definition":{"title":"","title_size":"16","title_align":"left","time":{},"style":{"display": {"type": "stacked"},"scaling": "relative","palette": "dog_classic"},"type":"toplist","requests":[{"queries":[{"data_source":"metrics","name":"query1","query":"avg:system.cpu.user{*} by {service}","aggregator":"avg"}],"formulas":[{"formula":"query1"}],"sort":{"count":10,"order_by":[{"type":"group","name":"service","order":"asc"}]},"response_format":"scalar"}]}}],"template_variables":[],"layout_type":"free","is_read_only":false,"notify_list":[]}
213+
When the request is sent
214+
Then the response status is 200 OK
215+
And the response "widgets[0].definition.type" is equal to "toplist"
216+
And the response "widgets[0].definition.requests[0].sort.order_by[0].order" is equal to "asc"
217+
And the response "widgets[0].definition.requests[0].sort.order_by[0].type" is equal to "group"
218+
And the response "widgets[0].definition.requests[0].sort.order_by[0].name" is equal to "service"
219+
And the response "widgets[0].definition.style.display.type" is equal to "stacked"
220+
And the response "widgets[0].definition.style.display" does not have field "legend"
221+
209222
@team:DataDog/dashboards-backend
210223
Scenario: Create a new dashboard with alert_graph widget
211224
Given there is a valid "monitor" in the system

0 commit comments

Comments
 (0)