diff --git a/.apigentools-info b/.apigentools-info index e8a2762c8..ef966c796 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-02-20 18:33:29.867322", - "spec_repo_commit": "d3fcdb89" + "regenerated": "2025-02-21 08:00:35.115496", + "spec_repo_commit": "8f2d39c3" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-02-20 18:33:29.882630", - "spec_repo_commit": "d3fcdb89" + "regenerated": "2025-02-21 08:00:35.131024", + "spec_repo_commit": "8f2d39c3" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index f38bee54f..ffdec05dc 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -17396,11 +17396,13 @@ components: enum: - number - bar + - trend example: number type: string x-enum-varnames: - NUMBER - BAR + - TREND TableWidgetDefinition: description: The table visualization is available on timeboards and screenboards. It displays columns of metrics grouped by tag key. @@ -23089,6 +23091,8 @@ components: type: string cell_display_mode: $ref: '#/components/schemas/TableWidgetCellDisplayMode' + cell_display_mode_options: + $ref: '#/components/schemas/WidgetFormulaCellDisplayModeOptions' conditional_formats: description: List of conditional formats. items: @@ -23107,6 +23111,37 @@ components: required: - formula type: object + WidgetFormulaCellDisplayModeOptions: + description: Cell display mode options for the widget formula. (only if `cell_display_mode` + is set to `trend`). + properties: + trend_type: + $ref: '#/components/schemas/WidgetFormulaCellDisplayModeOptionsTrendType' + y_scale: + $ref: '#/components/schemas/WidgetFormulaCellDisplayModeOptionsYScale' + type: object + WidgetFormulaCellDisplayModeOptionsTrendType: + description: Trend type for the cell display mode options. + enum: + - area + - line + - bars + example: area + type: string + x-enum-varnames: + - AREA + - LINE + - BARS + WidgetFormulaCellDisplayModeOptionsYScale: + description: Y scale for the cell display mode options. + enum: + - shared + - independent + example: shared + type: string + x-enum-varnames: + - SHARED + - INDEPENDENT WidgetFormulaLimit: description: Options for limiting results returned. properties: diff --git a/examples/v1_dashboards_CreateDashboard_1490099434.rs b/examples/v1_dashboards_CreateDashboard_1490099434.rs new file mode 100644 index 000000000..ba6c4d89f --- /dev/null +++ b/examples/v1_dashboards_CreateDashboard_1490099434.rs @@ -0,0 +1,117 @@ +// Create a new dashboard with query_table widget and cell_display_mode is trend +use datadog_api_client::datadog; +use datadog_api_client::datadogV1::api_dashboards::DashboardsAPI; +use datadog_api_client::datadogV1::model::Dashboard; +use datadog_api_client::datadogV1::model::DashboardLayoutType; +use datadog_api_client::datadogV1::model::FormulaAndFunctionMetricAggregation; +use datadog_api_client::datadogV1::model::FormulaAndFunctionMetricDataSource; +use datadog_api_client::datadogV1::model::FormulaAndFunctionMetricQueryDefinition; +use datadog_api_client::datadogV1::model::FormulaAndFunctionQueryDefinition; +use datadog_api_client::datadogV1::model::FormulaAndFunctionResponseFormat; +use datadog_api_client::datadogV1::model::FormulaType; +use datadog_api_client::datadogV1::model::TableWidgetCellDisplayMode; +use datadog_api_client::datadogV1::model::TableWidgetDefinition; +use datadog_api_client::datadogV1::model::TableWidgetDefinitionType; +use datadog_api_client::datadogV1::model::TableWidgetHasSearchBar; +use datadog_api_client::datadogV1::model::TableWidgetRequest; +use datadog_api_client::datadogV1::model::Widget; +use datadog_api_client::datadogV1::model::WidgetDefinition; +use datadog_api_client::datadogV1::model::WidgetFormula; +use datadog_api_client::datadogV1::model::WidgetFormulaCellDisplayModeOptions; +use datadog_api_client::datadogV1::model::WidgetFormulaCellDisplayModeOptionsTrendType; +use datadog_api_client::datadogV1::model::WidgetFormulaCellDisplayModeOptionsYScale; +use datadog_api_client::datadogV1::model::WidgetFormulaSort; +use datadog_api_client::datadogV1::model::WidgetLayout; +use datadog_api_client::datadogV1::model::WidgetLegacyLiveSpan; +use datadog_api_client::datadogV1::model::WidgetSort; +use datadog_api_client::datadogV1::model::WidgetSortBy; +use datadog_api_client::datadogV1::model::WidgetSortOrderBy; +use datadog_api_client::datadogV1::model::WidgetTextAlign; +use datadog_api_client::datadogV1::model::WidgetTime; + +#[tokio::main] +async fn main() { + let body = + Dashboard::new( + DashboardLayoutType::FREE, + "Example-Dashboard".to_string(), + vec![ + Widget::new( + WidgetDefinition::TableWidgetDefinition( + Box::new( + TableWidgetDefinition::new( + vec![ + TableWidgetRequest::new() + .formulas( + vec![ + WidgetFormula::new("query1".to_string()) + .cell_display_mode(TableWidgetCellDisplayMode::TREND) + .cell_display_mode_options( + WidgetFormulaCellDisplayModeOptions::new() + .trend_type( + WidgetFormulaCellDisplayModeOptionsTrendType::LINE, + ) + .y_scale( + WidgetFormulaCellDisplayModeOptionsYScale::SHARED, + ), + ) + .conditional_formats(vec![]) + ], + ) + .queries( + vec![ + FormulaAndFunctionQueryDefinition + ::FormulaAndFunctionMetricQueryDefinition( + Box::new( + FormulaAndFunctionMetricQueryDefinition::new( + FormulaAndFunctionMetricDataSource::METRICS, + "query1".to_string(), + "avg:system.cpu.user{*} by {host}".to_string(), + ).aggregator(FormulaAndFunctionMetricAggregation::AVG), + ), + ) + ], + ) + .response_format(FormulaAndFunctionResponseFormat::SCALAR) + .sort( + WidgetSortBy::new() + .count(500) + .order_by( + vec![ + WidgetSortOrderBy::WidgetFormulaSort( + Box::new( + WidgetFormulaSort::new( + 0, + WidgetSort::DESCENDING, + FormulaType::FORMULA, + ), + ), + ) + ], + ), + ) + ], + TableWidgetDefinitionType::QUERY_TABLE, + ) + .has_search_bar(TableWidgetHasSearchBar::AUTO) + .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new()))) + .title("".to_string()) + .title_align(WidgetTextAlign::LEFT) + .title_size("16".to_string()), + ), + ), + ).layout(WidgetLayout::new(32, 54, 0, 0)) + ], + ) + .description(Some("".to_string())) + .notify_list(Some(vec![])) + .template_variables(Some(vec![])); + let configuration = datadog::Configuration::new(); + let api = DashboardsAPI::with_config(configuration); + let resp = api.create_dashboard(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV1/model/mod.rs b/src/datadogV1/model/mod.rs index 3c97aabf8..b3244463c 100644 --- a/src/datadogV1/model/mod.rs +++ b/src/datadogV1/model/mod.rs @@ -152,6 +152,12 @@ pub mod model_widget_formula; pub use self::model_widget_formula::WidgetFormula; pub mod model_table_widget_cell_display_mode; pub use self::model_table_widget_cell_display_mode::TableWidgetCellDisplayMode; +pub mod model_widget_formula_cell_display_mode_options; +pub use self::model_widget_formula_cell_display_mode_options::WidgetFormulaCellDisplayModeOptions; +pub mod model_widget_formula_cell_display_mode_options_trend_type; +pub use self::model_widget_formula_cell_display_mode_options_trend_type::WidgetFormulaCellDisplayModeOptionsTrendType; +pub mod model_widget_formula_cell_display_mode_options_y_scale; +pub use self::model_widget_formula_cell_display_mode_options_y_scale::WidgetFormulaCellDisplayModeOptionsYScale; pub mod model_widget_conditional_format; pub use self::model_widget_conditional_format::WidgetConditionalFormat; pub mod model_widget_comparator; diff --git a/src/datadogV1/model/model_table_widget_cell_display_mode.rs b/src/datadogV1/model/model_table_widget_cell_display_mode.rs index 83c38597f..80746b025 100644 --- a/src/datadogV1/model/model_table_widget_cell_display_mode.rs +++ b/src/datadogV1/model/model_table_widget_cell_display_mode.rs @@ -9,6 +9,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; pub enum TableWidgetCellDisplayMode { NUMBER, BAR, + TREND, UnparsedObject(crate::datadog::UnparsedObject), } @@ -17,6 +18,7 @@ impl ToString for TableWidgetCellDisplayMode { match self { Self::NUMBER => String::from("number"), Self::BAR => String::from("bar"), + Self::TREND => String::from("trend"), Self::UnparsedObject(v) => v.value.to_string(), } } @@ -43,6 +45,7 @@ impl<'de> Deserialize<'de> for TableWidgetCellDisplayMode { Ok(match s.as_str() { "number" => Self::NUMBER, "bar" => Self::BAR, + "trend" => Self::TREND, _ => Self::UnparsedObject(crate::datadog::UnparsedObject { value: serde_json::Value::String(s.into()), }), diff --git a/src/datadogV1/model/model_widget_formula.rs b/src/datadogV1/model/model_widget_formula.rs index 11526b47f..c638764d0 100644 --- a/src/datadogV1/model/model_widget_formula.rs +++ b/src/datadogV1/model/model_widget_formula.rs @@ -17,6 +17,10 @@ pub struct WidgetFormula { /// Define a display mode for the table cell. #[serde(rename = "cell_display_mode")] pub cell_display_mode: Option, + /// Cell display mode options for the widget formula. (only if `cell_display_mode` is set to `trend`). + #[serde(rename = "cell_display_mode_options")] + pub cell_display_mode_options: + Option, /// List of conditional formats. #[serde(rename = "conditional_formats")] pub conditional_formats: Option>, @@ -44,6 +48,7 @@ impl WidgetFormula { WidgetFormula { alias: None, cell_display_mode: None, + cell_display_mode_options: None, conditional_formats: None, formula, limit: None, @@ -67,6 +72,14 @@ impl WidgetFormula { self } + pub fn cell_display_mode_options( + mut self, + value: crate::datadogV1::model::WidgetFormulaCellDisplayModeOptions, + ) -> Self { + self.cell_display_mode_options = Some(value); + self + } + pub fn conditional_formats( mut self, value: Vec, @@ -120,6 +133,9 @@ impl<'de> Deserialize<'de> for WidgetFormula { let mut cell_display_mode: Option< crate::datadogV1::model::TableWidgetCellDisplayMode, > = None; + let mut cell_display_mode_options: Option< + crate::datadogV1::model::WidgetFormulaCellDisplayModeOptions, + > = None; let mut conditional_formats: Option< Vec, > = None; @@ -156,6 +172,13 @@ impl<'de> Deserialize<'de> for WidgetFormula { } } } + "cell_display_mode_options" => { + if v.is_null() { + continue; + } + cell_display_mode_options = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "conditional_formats" => { if v.is_null() { continue; @@ -197,6 +220,7 @@ impl<'de> Deserialize<'de> for WidgetFormula { let content = WidgetFormula { alias, cell_display_mode, + cell_display_mode_options, conditional_formats, formula, limit, diff --git a/src/datadogV1/model/model_widget_formula_cell_display_mode_options.rs b/src/datadogV1/model/model_widget_formula_cell_display_mode_options.rs new file mode 100644 index 000000000..f0c1cbc7f --- /dev/null +++ b/src/datadogV1/model/model_widget_formula_cell_display_mode_options.rs @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Cell display mode options for the widget formula. (only if `cell_display_mode` is set to `trend`). +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WidgetFormulaCellDisplayModeOptions { + /// Trend type for the cell display mode options. + #[serde(rename = "trend_type")] + pub trend_type: Option, + /// Y scale for the cell display mode options. + #[serde(rename = "y_scale")] + pub y_scale: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WidgetFormulaCellDisplayModeOptions { + pub fn new() -> WidgetFormulaCellDisplayModeOptions { + WidgetFormulaCellDisplayModeOptions { + trend_type: None, + y_scale: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn trend_type( + mut self, + value: crate::datadogV1::model::WidgetFormulaCellDisplayModeOptionsTrendType, + ) -> Self { + self.trend_type = Some(value); + self + } + + pub fn y_scale( + mut self, + value: crate::datadogV1::model::WidgetFormulaCellDisplayModeOptionsYScale, + ) -> Self { + self.y_scale = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for WidgetFormulaCellDisplayModeOptions { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WidgetFormulaCellDisplayModeOptions { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WidgetFormulaCellDisplayModeOptionsVisitor; + impl<'a> Visitor<'a> for WidgetFormulaCellDisplayModeOptionsVisitor { + type Value = WidgetFormulaCellDisplayModeOptions; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut trend_type: Option< + crate::datadogV1::model::WidgetFormulaCellDisplayModeOptionsTrendType, + > = None; + let mut y_scale: Option< + crate::datadogV1::model::WidgetFormulaCellDisplayModeOptionsYScale, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "trend_type" => { + if v.is_null() { + continue; + } + trend_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _trend_type) = trend_type { + match _trend_type { + crate::datadogV1::model::WidgetFormulaCellDisplayModeOptionsTrendType::UnparsedObject(_trend_type) => { + _unparsed = true; + }, + _ => {} + } + } + } + "y_scale" => { + if v.is_null() { + continue; + } + y_scale = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _y_scale) = y_scale { + match _y_scale { + crate::datadogV1::model::WidgetFormulaCellDisplayModeOptionsYScale::UnparsedObject(_y_scale) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = WidgetFormulaCellDisplayModeOptions { + trend_type, + y_scale, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(WidgetFormulaCellDisplayModeOptionsVisitor) + } +} diff --git a/src/datadogV1/model/model_widget_formula_cell_display_mode_options_trend_type.rs b/src/datadogV1/model/model_widget_formula_cell_display_mode_options_trend_type.rs new file mode 100644 index 000000000..6edf9752a --- /dev/null +++ b/src/datadogV1/model/model_widget_formula_cell_display_mode_options_trend_type.rs @@ -0,0 +1,54 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum WidgetFormulaCellDisplayModeOptionsTrendType { + AREA, + LINE, + BARS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for WidgetFormulaCellDisplayModeOptionsTrendType { + fn to_string(&self) -> String { + match self { + Self::AREA => String::from("area"), + Self::LINE => String::from("line"), + Self::BARS => String::from("bars"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for WidgetFormulaCellDisplayModeOptionsTrendType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for WidgetFormulaCellDisplayModeOptionsTrendType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "area" => Self::AREA, + "line" => Self::LINE, + "bars" => Self::BARS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV1/model/model_widget_formula_cell_display_mode_options_y_scale.rs b/src/datadogV1/model/model_widget_formula_cell_display_mode_options_y_scale.rs new file mode 100644 index 000000000..67da69da7 --- /dev/null +++ b/src/datadogV1/model/model_widget_formula_cell_display_mode_options_y_scale.rs @@ -0,0 +1,51 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum WidgetFormulaCellDisplayModeOptionsYScale { + SHARED, + INDEPENDENT, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for WidgetFormulaCellDisplayModeOptionsYScale { + fn to_string(&self) -> String { + match self { + Self::SHARED => String::from("shared"), + Self::INDEPENDENT => String::from("independent"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for WidgetFormulaCellDisplayModeOptionsYScale { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for WidgetFormulaCellDisplayModeOptionsYScale { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "shared" => Self::SHARED, + "independent" => Self::INDEPENDENT, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-query-table-widget-and-cell-display-mode-is-trend.frozen b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-query-table-widget-and-cell-display-mode-is-trend.frozen new file mode 100644 index 000000000..2e182a324 --- /dev/null +++ b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-query-table-widget-and-cell-display-mode-is-trend.frozen @@ -0,0 +1 @@ +2025-02-14T13:36:57.006Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-query-table-widget-and-cell-display-mode-is-trend.json b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-query-table-widget-and-cell-display-mode-is-trend.json new file mode 100644 index 000000000..18fbdb8cb --- /dev/null +++ b/tests/scenarios/cassettes/v1/dashboards/Create-a-new-dashboard-with-query-table-widget-and-cell-display-mode-is-trend.json @@ -0,0 +1,67 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"description\":\"\",\"layout_type\":\"free\",\"notify_list\":[],\"template_variables\":[],\"title\":\"Test-Create_a_new_dashboard_with_query_table_widget_and_cell_display_mode_is_trend-1739540217\",\"widgets\":[{\"definition\":{\"has_search_bar\":\"auto\",\"requests\":[{\"formulas\":[{\"cell_display_mode\":\"trend\",\"cell_display_mode_options\":{\"trend_type\":\"line\",\"y_scale\":\"shared\"},\"conditional_formats\":[],\"formula\":\"query1\"}],\"queries\":[{\"aggregator\":\"avg\",\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*} by {host}\"}],\"response_format\":\"scalar\",\"sort\":{\"count\":500,\"order_by\":[{\"index\":0,\"order\":\"desc\",\"type\":\"formula\"}]}}],\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"query_table\"},\"layout\":{\"height\":32,\"width\":54,\"x\":0,\"y\":0}}]}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v1/dashboard" + }, + "response": { + "body": { + "string": "{\"id\":\"qw6-574-sem\",\"title\":\"Test-Create_a_new_dashboard_with_query_table_widget_and_cell_display_mode_is_trend-1739540217\",\"description\":\"\",\"author_handle\":\"frog@datadoghq.com\",\"author_name\":\"frog\",\"layout_type\":\"free\",\"url\":\"/dashboard/qw6-574-sem/test-createanewdashboardwithquerytablewidgetandcelldisplaymodeistrend-1739540217\",\"is_read_only\":false,\"template_variables\":[],\"widgets\":[{\"definition\":{\"has_search_bar\":\"auto\",\"requests\":[{\"formulas\":[{\"cell_display_mode\":\"trend\",\"cell_display_mode_options\":{\"trend_type\":\"line\",\"y_scale\":\"shared\"},\"conditional_formats\":[],\"formula\":\"query1\"}],\"queries\":[{\"aggregator\":\"avg\",\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*} by {host}\"}],\"response_format\":\"scalar\",\"sort\":{\"count\":500,\"order_by\":[{\"index\":0,\"order\":\"desc\",\"type\":\"formula\"}]}}],\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"query_table\"},\"layout\":{\"height\":32,\"width\":54,\"x\":0,\"y\":0},\"id\":6048610427342909}],\"notify_list\":[],\"created_at\":\"2025-02-14T13:36:57.493950+00:00\",\"modified_at\":\"2025-02-14T13:36:57.493950+00:00\",\"restricted_roles\":[]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Fri, 14 Feb 2025 13:36:57 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v1/dashboard/qw6-574-sem" + }, + "response": { + "body": { + "string": "{\"deleted_dashboard_id\":\"qw6-574-sem\"}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Fri, 14 Feb 2025 13:36:57 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v1/dashboards.feature b/tests/scenarios/features/v1/dashboards.feature index 49b4659a8..fbc89cc98 100644 --- a/tests/scenarios/features/v1/dashboards.feature +++ b/tests/scenarios/features/v1/dashboards.feature @@ -610,6 +610,17 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].sort.order_by[0].type" is equal to "formula" And the response "widgets[0].definition.requests[0].sort.order_by[0].index" is equal to 0 + @team:DataDog/dashboards-backend + Scenario: Create a new dashboard with query_table widget and cell_display_mode is trend + Given new "CreateDashboard" request + And body from file "dashboards_json_payload/query_table_widget_cell_display_mode_trend.json" + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.type" is equal to "query_table" + And the response "widgets[0].definition.requests[0].formulas[0].cell_display_mode" is equal to "trend" + And the response "widgets[0].definition.requests[0].formulas[0].cell_display_mode_options.trend_type" is equal to "line" + And the response "widgets[0].definition.requests[0].formulas[0].cell_display_mode_options.y_scale" is equal to "shared" + @team:DataDog/dashboards-backend Scenario: Create a new dashboard with query_table widget and text formatting Given new "CreateDashboard" request diff --git a/tests/scenarios/features/v1/dashboards_json_payload/query_table_widget_cell_display_mode_trend.json b/tests/scenarios/features/v1/dashboards_json_payload/query_table_widget_cell_display_mode_trend.json new file mode 100644 index 000000000..e61ad116c --- /dev/null +++ b/tests/scenarios/features/v1/dashboards_json_payload/query_table_widget_cell_display_mode_trend.json @@ -0,0 +1,67 @@ +{ + "title":"{{ unique }}", + "description":"", + "widgets":[ + { + "layout":{ + "x":0, + "y":0, + "width":54, + "height":32 + }, + "definition":{ + "title":"", + "title_size":"16", + "title_align":"left", + "time":{ + + }, + "type":"query_table", + "requests":[ + { + "queries":[ + { + "data_source":"metrics", + "name":"query1", + "query":"avg:system.cpu.user{*} by {host}", + "aggregator":"avg" + } + ], + "formulas":[ + { + "formula":"query1", + "conditional_formats":[ + + ], + "cell_display_mode": "trend", + "cell_display_mode_options": { + "trend_type": "line", + "y_scale": "shared" + } + } + ], + "sort": { + "count":500, + "order_by":[ + { + "type":"formula", + "index":0, + "order":"desc" + } + ] + }, + "response_format":"scalar" + } + ], + "has_search_bar":"auto" + } + } + ], + "template_variables":[ + + ], + "layout_type":"free", + "notify_list":[ + + ] +} \ No newline at end of file