Skip to content

Commit 2cca9ba

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 335acc5 of spec repo
1 parent 97a134c commit 2cca9ba

5 files changed

Lines changed: 294 additions & 2 deletions

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,10 @@ components:
14431443
format: date-time
14441444
readOnly: true
14451445
type: string
1446+
default_timeframe:
1447+
allOf:
1448+
- $ref: "#/components/schemas/DashboardDefaultTimeframe"
1449+
description: The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe.
14461450
description:
14471451
description: Description of the dashboard.
14481452
nullable: true
@@ -1557,6 +1561,39 @@ components:
15571561
required:
15581562
- data
15591563
type: object
1564+
DashboardDefaultTimeframe:
1565+
description: The default timeframe applied when opening the dashboard.
1566+
nullable: true
1567+
properties:
1568+
from:
1569+
description: Start time in milliseconds since epoch. Required when `type` is `fixed`.
1570+
format: int64
1571+
type: integer
1572+
to:
1573+
description: End time in milliseconds since epoch. Required when `type` is `fixed`.
1574+
format: int64
1575+
type: integer
1576+
type:
1577+
$ref: "#/components/schemas/DashboardDefaultTimeframeType"
1578+
unit:
1579+
$ref: "#/components/schemas/WidgetLiveSpanUnit"
1580+
value:
1581+
description: Value of the live timeframe span. Required when `type` is `live`.
1582+
format: int64
1583+
type: integer
1584+
required:
1585+
- type
1586+
type: object
1587+
DashboardDefaultTimeframeType:
1588+
description: Type of timeframe.
1589+
enum:
1590+
- live
1591+
- fixed
1592+
example: live
1593+
type: string
1594+
x-enum-varnames:
1595+
- LIVE
1596+
- FIXED
15601597
DashboardDeleteResponse:
15611598
description: Response from the delete dashboard call.
15621599
properties:

src/datadogV1/model/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ pub mod model_dashboard_restore_request;
8888
pub use self::model_dashboard_restore_request::DashboardRestoreRequest;
8989
pub mod model_dashboard;
9090
pub use self::model_dashboard::Dashboard;
91+
pub mod model_dashboard_default_timeframe;
92+
pub use self::model_dashboard_default_timeframe::DashboardDefaultTimeframe;
93+
pub mod model_dashboard_default_timeframe_type;
94+
pub use self::model_dashboard_default_timeframe_type::DashboardDefaultTimeframeType;
95+
pub mod model_widget_live_span_unit;
96+
pub use self::model_widget_live_span_unit::WidgetLiveSpanUnit;
9197
pub mod model_dashboard_reflow_type;
9298
pub use self::model_dashboard_reflow_type::DashboardReflowType;
9399
pub mod model_dashboard_tab;
@@ -110,8 +116,6 @@ pub mod model_widget_new_live_span;
110116
pub use self::model_widget_new_live_span::WidgetNewLiveSpan;
111117
pub mod model_widget_new_live_span_type;
112118
pub use self::model_widget_new_live_span_type::WidgetNewLiveSpanType;
113-
pub mod model_widget_live_span_unit;
114-
pub use self::model_widget_live_span_unit::WidgetLiveSpanUnit;
115119
pub mod model_widget_new_fixed_span;
116120
pub use self::model_widget_new_fixed_span::WidgetNewFixedSpan;
117121
pub mod model_widget_new_fixed_span_type;

src/datadogV1/model/model_dashboard.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ pub struct Dashboard {
2525
/// Creation date of the dashboard.
2626
#[serde(rename = "created_at")]
2727
pub created_at: Option<chrono::DateTime<chrono::Utc>>,
28+
/// The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe.
29+
#[serde(rename = "default_timeframe")]
30+
pub default_timeframe: Option<serde_json::Value>,
2831
/// Description of the dashboard.
2932
#[serde(
3033
rename = "description",
@@ -110,6 +113,7 @@ impl Dashboard {
110113
author_handle: None,
111114
author_name: None,
112115
created_at: None,
116+
default_timeframe: None,
113117
description: None,
114118
id: None,
115119
is_read_only: None,
@@ -148,6 +152,12 @@ impl Dashboard {
148152
self
149153
}
150154

155+
#[allow(deprecated)]
156+
pub fn default_timeframe(mut self, value: serde_json::Value) -> Self {
157+
self.default_timeframe = Some(value);
158+
self
159+
}
160+
151161
#[allow(deprecated)]
152162
pub fn description(mut self, value: Option<String>) -> Self {
153163
self.description = Some(value);
@@ -255,6 +265,7 @@ impl<'de> Deserialize<'de> for Dashboard {
255265
let mut author_handle: Option<String> = None;
256266
let mut author_name: Option<Option<String>> = None;
257267
let mut created_at: Option<chrono::DateTime<chrono::Utc>> = None;
268+
let mut default_timeframe: Option<serde_json::Value> = None;
258269
let mut description: Option<Option<String>> = None;
259270
let mut id: Option<String> = None;
260271
let mut is_read_only: Option<bool> = None;
@@ -299,6 +310,13 @@ impl<'de> Deserialize<'de> for Dashboard {
299310
}
300311
created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
301312
}
313+
"default_timeframe" => {
314+
if v.is_null() {
315+
continue;
316+
}
317+
default_timeframe =
318+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
319+
}
302320
"description" => {
303321
description =
304322
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
@@ -404,6 +422,7 @@ impl<'de> Deserialize<'de> for Dashboard {
404422
author_handle,
405423
author_name,
406424
created_at,
425+
default_timeframe,
407426
description,
408427
id,
409428
is_read_only,
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
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+
/// The default timeframe applied when opening the dashboard.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct DashboardDefaultTimeframe {
14+
/// Start time in milliseconds since epoch. Required when `type` is `fixed`.
15+
#[serde(rename = "from")]
16+
pub from: Option<i64>,
17+
/// End time in milliseconds since epoch. Required when `type` is `fixed`.
18+
#[serde(rename = "to")]
19+
pub to: Option<i64>,
20+
/// Type of timeframe.
21+
#[serde(rename = "type")]
22+
pub type_: crate::datadogV1::model::DashboardDefaultTimeframeType,
23+
/// Unit of the time span.
24+
#[serde(rename = "unit")]
25+
pub unit: Option<crate::datadogV1::model::WidgetLiveSpanUnit>,
26+
/// Value of the live timeframe span. Required when `type` is `live`.
27+
#[serde(rename = "value")]
28+
pub value: Option<i64>,
29+
#[serde(flatten)]
30+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
31+
#[serde(skip)]
32+
#[serde(default)]
33+
pub(crate) _unparsed: bool,
34+
}
35+
36+
impl DashboardDefaultTimeframe {
37+
pub fn new(
38+
type_: crate::datadogV1::model::DashboardDefaultTimeframeType,
39+
) -> DashboardDefaultTimeframe {
40+
DashboardDefaultTimeframe {
41+
from: None,
42+
to: None,
43+
type_,
44+
unit: None,
45+
value: None,
46+
additional_properties: std::collections::BTreeMap::new(),
47+
_unparsed: false,
48+
}
49+
}
50+
51+
pub fn from(mut self, value: i64) -> Self {
52+
self.from = Some(value);
53+
self
54+
}
55+
56+
pub fn to(mut self, value: i64) -> Self {
57+
self.to = Some(value);
58+
self
59+
}
60+
61+
pub fn unit(mut self, value: crate::datadogV1::model::WidgetLiveSpanUnit) -> Self {
62+
self.unit = Some(value);
63+
self
64+
}
65+
66+
pub fn value(mut self, value: i64) -> Self {
67+
self.value = Some(value);
68+
self
69+
}
70+
71+
pub fn additional_properties(
72+
mut self,
73+
value: std::collections::BTreeMap<String, serde_json::Value>,
74+
) -> Self {
75+
self.additional_properties = value;
76+
self
77+
}
78+
}
79+
80+
impl<'de> Deserialize<'de> for DashboardDefaultTimeframe {
81+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
82+
where
83+
D: Deserializer<'de>,
84+
{
85+
struct DashboardDefaultTimeframeVisitor;
86+
impl<'a> Visitor<'a> for DashboardDefaultTimeframeVisitor {
87+
type Value = DashboardDefaultTimeframe;
88+
89+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
90+
f.write_str("a mapping")
91+
}
92+
93+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
94+
where
95+
M: MapAccess<'a>,
96+
{
97+
let mut from: Option<i64> = None;
98+
let mut to: Option<i64> = None;
99+
let mut type_: Option<crate::datadogV1::model::DashboardDefaultTimeframeType> =
100+
None;
101+
let mut unit: Option<crate::datadogV1::model::WidgetLiveSpanUnit> = None;
102+
let mut value: Option<i64> = None;
103+
let mut additional_properties: std::collections::BTreeMap<
104+
String,
105+
serde_json::Value,
106+
> = std::collections::BTreeMap::new();
107+
let mut _unparsed = false;
108+
109+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
110+
match k.as_str() {
111+
"from" => {
112+
if v.is_null() {
113+
continue;
114+
}
115+
from = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
116+
}
117+
"to" => {
118+
if v.is_null() {
119+
continue;
120+
}
121+
to = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
122+
}
123+
"type" => {
124+
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
125+
if let Some(ref _type_) = type_ {
126+
match _type_ {
127+
crate::datadogV1::model::DashboardDefaultTimeframeType::UnparsedObject(_type_) => {
128+
_unparsed = true;
129+
},
130+
_ => {}
131+
}
132+
}
133+
}
134+
"unit" => {
135+
if v.is_null() {
136+
continue;
137+
}
138+
unit = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
139+
if let Some(ref _unit) = unit {
140+
match _unit {
141+
crate::datadogV1::model::WidgetLiveSpanUnit::UnparsedObject(
142+
_unit,
143+
) => {
144+
_unparsed = true;
145+
}
146+
_ => {}
147+
}
148+
}
149+
}
150+
"value" => {
151+
if v.is_null() {
152+
continue;
153+
}
154+
value = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
155+
}
156+
&_ => {
157+
if let Ok(value) = serde_json::from_value(v.clone()) {
158+
additional_properties.insert(k, value);
159+
}
160+
}
161+
}
162+
}
163+
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;
164+
165+
let content = DashboardDefaultTimeframe {
166+
from,
167+
to,
168+
type_,
169+
unit,
170+
value,
171+
additional_properties,
172+
_unparsed,
173+
};
174+
175+
Ok(content)
176+
}
177+
}
178+
179+
deserializer.deserialize_any(DashboardDefaultTimeframeVisitor)
180+
}
181+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
5+
use serde::{Deserialize, Deserializer, Serialize, Serializer};
6+
7+
#[non_exhaustive]
8+
#[derive(Clone, Debug, Eq, PartialEq)]
9+
pub enum DashboardDefaultTimeframeType {
10+
LIVE,
11+
FIXED,
12+
UnparsedObject(crate::datadog::UnparsedObject),
13+
}
14+
15+
impl ToString for DashboardDefaultTimeframeType {
16+
fn to_string(&self) -> String {
17+
match self {
18+
Self::LIVE => String::from("live"),
19+
Self::FIXED => String::from("fixed"),
20+
Self::UnparsedObject(v) => v.value.to_string(),
21+
}
22+
}
23+
}
24+
25+
impl Serialize for DashboardDefaultTimeframeType {
26+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
27+
where
28+
S: Serializer,
29+
{
30+
match self {
31+
Self::UnparsedObject(v) => v.serialize(serializer),
32+
_ => serializer.serialize_str(self.to_string().as_str()),
33+
}
34+
}
35+
}
36+
37+
impl<'de> Deserialize<'de> for DashboardDefaultTimeframeType {
38+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
39+
where
40+
D: Deserializer<'de>,
41+
{
42+
let s: String = String::deserialize(deserializer)?;
43+
Ok(match s.as_str() {
44+
"live" => Self::LIVE,
45+
"fixed" => Self::FIXED,
46+
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
47+
value: serde_json::Value::String(s.into()),
48+
}),
49+
})
50+
}
51+
}

0 commit comments

Comments
 (0)