Skip to content

Commit c01c9c8

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add WildcardWidgetDefinition to Dashboard spec (#1390)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent df35f8c commit c01c9c8

8 files changed

Lines changed: 603 additions & 0 deletions

.generator/schemas/v1/openapi.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24274,6 +24274,7 @@ components:
2427424274
- $ref: "#/components/schemas/ToplistWidgetDefinition"
2427524275
- $ref: "#/components/schemas/TopologyMapWidgetDefinition"
2427624276
- $ref: "#/components/schemas/TreeMapWidgetDefinition"
24277+
- $ref: "#/components/schemas/WildcardWidgetDefinition"
2427724278
WidgetDisplayType:
2427824279
description: Type of display to use for the request.
2427924280
enum:
@@ -25045,6 +25046,81 @@ components:
2504525046
x-enum-varnames:
2504625047
- TIMESERIES
2504725048
- TOPLIST
25049+
WildcardWidgetDefinition:
25050+
description: >-
25051+
Custom visualization widget using Vega or Vega-Lite specifications. Combines standard Datadog data requests with a Vega or Vega-Lite JSON specification for flexible, custom visualizations.
25052+
properties:
25053+
custom_links:
25054+
description: List of custom links.
25055+
items:
25056+
$ref: "#/components/schemas/WidgetCustomLink"
25057+
type: array
25058+
requests:
25059+
description: List of data requests for the wildcard widget.
25060+
example: [{"formulas": ["formula": "query1"], "queries": [{"aggregator": "avg", "data_source": "metrics", "name": "query1", "query": "avg:system.cpu.user{*} by {env}"}], "response_format": "scalar"}]
25061+
items:
25062+
$ref: "#/components/schemas/WildcardWidgetRequest"
25063+
type: array
25064+
specification:
25065+
$ref: "#/components/schemas/WildcardWidgetSpecification"
25066+
time:
25067+
$ref: "#/components/schemas/WidgetTime"
25068+
title:
25069+
description: Title of the widget.
25070+
type: string
25071+
title_align:
25072+
$ref: "#/components/schemas/WidgetTextAlign"
25073+
title_size:
25074+
description: Size of the title.
25075+
type: string
25076+
type:
25077+
$ref: "#/components/schemas/WildcardWidgetDefinitionType"
25078+
required:
25079+
- type
25080+
- requests
25081+
- specification
25082+
type: object
25083+
WildcardWidgetDefinitionType:
25084+
default: wildcard
25085+
description: Type of the wildcard widget.
25086+
enum:
25087+
- wildcard
25088+
example: wildcard
25089+
type: string
25090+
x-enum-varnames:
25091+
- WILDCARD
25092+
WildcardWidgetRequest:
25093+
description: >-
25094+
Request object for the wildcard widget. Each variant represents a distinct data-fetching pattern: scalar formulas, timeseries formulas, list streams, and histograms.
25095+
oneOf:
25096+
- $ref: "#/components/schemas/TreeMapWidgetRequest"
25097+
- $ref: "#/components/schemas/TimeseriesWidgetRequest"
25098+
- $ref: "#/components/schemas/ListStreamWidgetRequest"
25099+
- $ref: "#/components/schemas/DistributionWidgetRequest"
25100+
WildcardWidgetSpecification:
25101+
description: >-
25102+
Vega or Vega-Lite specification for custom visualization rendering. See https://vega.github.io/vega-lite/ for the full grammar reference.
25103+
properties:
25104+
contents:
25105+
description: The Vega or Vega-Lite JSON specification object.
25106+
example: {"$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": {"name": "table1"}, "description": "A simple bar chart", "encoding": {"x": {"field": "env", "sort": "-y", "type": "nominal"}, "y": {"field": "query1", "type": "quantitative"}}, "mark": "bar"}
25107+
type: object
25108+
type:
25109+
$ref: "#/components/schemas/WildcardWidgetSpecificationType"
25110+
required:
25111+
- type
25112+
- contents
25113+
type: object
25114+
WildcardWidgetSpecificationType:
25115+
description: Type of specification used by the wildcard widget.
25116+
enum:
25117+
- vega
25118+
- vega-lite
25119+
example: vega-lite
25120+
type: string
25121+
x-enum-varnames:
25122+
- VEGA
25123+
- VEGA_LITE
2504825124
securitySchemes:
2504925125
AuthZ:
2505025126
description: This API uses OAuth 2 with the implicit grant flow.

src/datadogV1/model/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,16 @@ pub mod model_topology_request_type;
706706
pub use self::model_topology_request_type::TopologyRequestType;
707707
pub mod model_topology_map_widget_definition_type;
708708
pub use self::model_topology_map_widget_definition_type::TopologyMapWidgetDefinitionType;
709+
pub mod model_wildcard_widget_definition;
710+
pub use self::model_wildcard_widget_definition::WildcardWidgetDefinition;
711+
pub mod model_wildcard_widget_request;
712+
pub use self::model_wildcard_widget_request::WildcardWidgetRequest;
713+
pub mod model_wildcard_widget_specification;
714+
pub use self::model_wildcard_widget_specification::WildcardWidgetSpecification;
715+
pub mod model_wildcard_widget_specification_type;
716+
pub use self::model_wildcard_widget_specification_type::WildcardWidgetSpecificationType;
717+
pub mod model_wildcard_widget_definition_type;
718+
pub use self::model_wildcard_widget_definition_type::WildcardWidgetDefinitionType;
709719
pub mod model_widget_definition;
710720
pub use self::model_widget_definition::WidgetDefinition;
711721
pub mod model_widget_layout;

src/datadogV1/model/model_widget_definition.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub enum WidgetDefinition {
4444
ToplistWidgetDefinition(Box<crate::datadogV1::model::ToplistWidgetDefinition>),
4545
TopologyMapWidgetDefinition(Box<crate::datadogV1::model::TopologyMapWidgetDefinition>),
4646
TreeMapWidgetDefinition(Box<crate::datadogV1::model::TreeMapWidgetDefinition>),
47+
WildcardWidgetDefinition(Box<crate::datadogV1::model::WildcardWidgetDefinition>),
4748
UnparsedObject(crate::datadog::UnparsedObject),
4849
}
4950

@@ -331,6 +332,14 @@ impl<'de> Deserialize<'de> for WidgetDefinition {
331332
return Ok(WidgetDefinition::TreeMapWidgetDefinition(_v));
332333
}
333334
}
335+
if let Ok(_v) = serde_json::from_value::<
336+
Box<crate::datadogV1::model::WildcardWidgetDefinition>,
337+
>(value.clone())
338+
{
339+
if !_v._unparsed {
340+
return Ok(WidgetDefinition::WildcardWidgetDefinition(_v));
341+
}
342+
}
334343

335344
return Ok(WidgetDefinition::UnparsedObject(
336345
crate::datadog::UnparsedObject { value },
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
use serde::de::{Error, MapAccess, Visitor};
5+
use serde::{Deserialize, Deserializer, Serialize};
6+
use serde_with::skip_serializing_none;
7+
use std::fmt::{self, Formatter};
8+
9+
/// Custom visualization widget using Vega or Vega-Lite specifications. Combines standard Datadog data requests with a Vega or Vega-Lite JSON specification for flexible, custom visualizations.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct WildcardWidgetDefinition {
14+
/// List of custom links.
15+
#[serde(rename = "custom_links")]
16+
pub custom_links: Option<Vec<crate::datadogV1::model::WidgetCustomLink>>,
17+
/// List of data requests for the wildcard widget.
18+
#[serde(rename = "requests")]
19+
pub requests: Vec<crate::datadogV1::model::WildcardWidgetRequest>,
20+
/// Vega or Vega-Lite specification for custom visualization rendering. See <https://vega.github.io/vega-lite/> for the full grammar reference.
21+
#[serde(rename = "specification")]
22+
pub specification: crate::datadogV1::model::WildcardWidgetSpecification,
23+
/// Time setting for the widget.
24+
#[serde(rename = "time")]
25+
pub time: Option<crate::datadogV1::model::WidgetTime>,
26+
/// Title of the widget.
27+
#[serde(rename = "title")]
28+
pub title: Option<String>,
29+
/// How to align the text on the widget.
30+
#[serde(rename = "title_align")]
31+
pub title_align: Option<crate::datadogV1::model::WidgetTextAlign>,
32+
/// Size of the title.
33+
#[serde(rename = "title_size")]
34+
pub title_size: Option<String>,
35+
/// Type of the wildcard widget.
36+
#[serde(rename = "type")]
37+
pub type_: crate::datadogV1::model::WildcardWidgetDefinitionType,
38+
#[serde(flatten)]
39+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
40+
#[serde(skip)]
41+
#[serde(default)]
42+
pub(crate) _unparsed: bool,
43+
}
44+
45+
impl WildcardWidgetDefinition {
46+
pub fn new(
47+
requests: Vec<crate::datadogV1::model::WildcardWidgetRequest>,
48+
specification: crate::datadogV1::model::WildcardWidgetSpecification,
49+
type_: crate::datadogV1::model::WildcardWidgetDefinitionType,
50+
) -> WildcardWidgetDefinition {
51+
WildcardWidgetDefinition {
52+
custom_links: None,
53+
requests,
54+
specification,
55+
time: None,
56+
title: None,
57+
title_align: None,
58+
title_size: None,
59+
type_,
60+
additional_properties: std::collections::BTreeMap::new(),
61+
_unparsed: false,
62+
}
63+
}
64+
65+
pub fn custom_links(mut self, value: Vec<crate::datadogV1::model::WidgetCustomLink>) -> Self {
66+
self.custom_links = Some(value);
67+
self
68+
}
69+
70+
pub fn time(mut self, value: crate::datadogV1::model::WidgetTime) -> Self {
71+
self.time = Some(value);
72+
self
73+
}
74+
75+
pub fn title(mut self, value: String) -> Self {
76+
self.title = Some(value);
77+
self
78+
}
79+
80+
pub fn title_align(mut self, value: crate::datadogV1::model::WidgetTextAlign) -> Self {
81+
self.title_align = Some(value);
82+
self
83+
}
84+
85+
pub fn title_size(mut self, value: String) -> Self {
86+
self.title_size = Some(value);
87+
self
88+
}
89+
90+
pub fn additional_properties(
91+
mut self,
92+
value: std::collections::BTreeMap<String, serde_json::Value>,
93+
) -> Self {
94+
self.additional_properties = value;
95+
self
96+
}
97+
}
98+
99+
impl<'de> Deserialize<'de> for WildcardWidgetDefinition {
100+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
101+
where
102+
D: Deserializer<'de>,
103+
{
104+
struct WildcardWidgetDefinitionVisitor;
105+
impl<'a> Visitor<'a> for WildcardWidgetDefinitionVisitor {
106+
type Value = WildcardWidgetDefinition;
107+
108+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
109+
f.write_str("a mapping")
110+
}
111+
112+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
113+
where
114+
M: MapAccess<'a>,
115+
{
116+
let mut custom_links: Option<Vec<crate::datadogV1::model::WidgetCustomLink>> = None;
117+
let mut requests: Option<Vec<crate::datadogV1::model::WildcardWidgetRequest>> =
118+
None;
119+
let mut specification: Option<
120+
crate::datadogV1::model::WildcardWidgetSpecification,
121+
> = None;
122+
let mut time: Option<crate::datadogV1::model::WidgetTime> = None;
123+
let mut title: Option<String> = None;
124+
let mut title_align: Option<crate::datadogV1::model::WidgetTextAlign> = None;
125+
let mut title_size: Option<String> = None;
126+
let mut type_: Option<crate::datadogV1::model::WildcardWidgetDefinitionType> = None;
127+
let mut additional_properties: std::collections::BTreeMap<
128+
String,
129+
serde_json::Value,
130+
> = std::collections::BTreeMap::new();
131+
let mut _unparsed = false;
132+
133+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
134+
match k.as_str() {
135+
"custom_links" => {
136+
if v.is_null() {
137+
continue;
138+
}
139+
custom_links =
140+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
141+
}
142+
"requests" => {
143+
requests = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
144+
}
145+
"specification" => {
146+
specification =
147+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
148+
}
149+
"time" => {
150+
if v.is_null() {
151+
continue;
152+
}
153+
time = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
154+
if let Some(ref _time) = time {
155+
match _time {
156+
crate::datadogV1::model::WidgetTime::UnparsedObject(_time) => {
157+
_unparsed = true;
158+
}
159+
_ => {}
160+
}
161+
}
162+
}
163+
"title" => {
164+
if v.is_null() {
165+
continue;
166+
}
167+
title = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
168+
}
169+
"title_align" => {
170+
if v.is_null() {
171+
continue;
172+
}
173+
title_align =
174+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
175+
if let Some(ref _title_align) = title_align {
176+
match _title_align {
177+
crate::datadogV1::model::WidgetTextAlign::UnparsedObject(
178+
_title_align,
179+
) => {
180+
_unparsed = true;
181+
}
182+
_ => {}
183+
}
184+
}
185+
}
186+
"title_size" => {
187+
if v.is_null() {
188+
continue;
189+
}
190+
title_size = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
191+
}
192+
"type" => {
193+
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
194+
if let Some(ref _type_) = type_ {
195+
match _type_ {
196+
crate::datadogV1::model::WildcardWidgetDefinitionType::UnparsedObject(_type_) => {
197+
_unparsed = true;
198+
},
199+
_ => {}
200+
}
201+
}
202+
}
203+
&_ => {
204+
if let Ok(value) = serde_json::from_value(v.clone()) {
205+
additional_properties.insert(k, value);
206+
}
207+
}
208+
}
209+
}
210+
let requests = requests.ok_or_else(|| M::Error::missing_field("requests"))?;
211+
let specification =
212+
specification.ok_or_else(|| M::Error::missing_field("specification"))?;
213+
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;
214+
215+
let content = WildcardWidgetDefinition {
216+
custom_links,
217+
requests,
218+
specification,
219+
time,
220+
title,
221+
title_align,
222+
title_size,
223+
type_,
224+
additional_properties,
225+
_unparsed,
226+
};
227+
228+
Ok(content)
229+
}
230+
}
231+
232+
deserializer.deserialize_any(WildcardWidgetDefinitionVisitor)
233+
}
234+
}

0 commit comments

Comments
 (0)