Skip to content

Commit c144181

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 6905dc7 of spec repo
1 parent 97a134c commit c144181

9 files changed

Lines changed: 517 additions & 5 deletions

.generator/schemas/v1/openapi.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,8 @@ components:
14431443
format: date-time
14441444
readOnly: true
14451445
type: string
1446+
default_timeframe:
1447+
$ref: "#/components/schemas/DashboardDefaultTimeframeSetting"
14461448
description:
14471449
description: Description of the dashboard.
14481450
nullable: true
@@ -1557,13 +1559,55 @@ components:
15571559
required:
15581560
- data
15591561
type: object
1562+
DashboardDefaultTimeframeSetting:
1563+
description: The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe.
1564+
discriminator:
1565+
mapping:
1566+
fixed: "#/components/schemas/DashboardFixedTimeframe"
1567+
live: "#/components/schemas/DashboardLiveTimeframe"
1568+
propertyName: type
1569+
nullable: true
1570+
oneOf:
1571+
- $ref: "#/components/schemas/DashboardLiveTimeframe"
1572+
- $ref: "#/components/schemas/DashboardFixedTimeframe"
1573+
type: object
15601574
DashboardDeleteResponse:
15611575
description: Response from the delete dashboard call.
15621576
properties:
15631577
deleted_dashboard_id:
15641578
description: ID of the deleted dashboard.
15651579
type: string
15661580
type: object
1581+
DashboardFixedTimeframe:
1582+
description: A fixed dashboard timeframe.
1583+
properties:
1584+
from:
1585+
description: Start time in milliseconds since epoch.
1586+
example: 1712080128000
1587+
format: int64
1588+
minimum: 0
1589+
type: integer
1590+
to:
1591+
description: End time in milliseconds since epoch.
1592+
example: 1712083128000
1593+
format: int64
1594+
minimum: 0
1595+
type: integer
1596+
type:
1597+
$ref: "#/components/schemas/DashboardFixedTimeframeType"
1598+
required:
1599+
- type
1600+
- from
1601+
- to
1602+
type: object
1603+
DashboardFixedTimeframeType:
1604+
description: Type of fixed timeframe.
1605+
enum:
1606+
- fixed
1607+
example: fixed
1608+
type: string
1609+
x-enum-varnames:
1610+
- FIXED
15671611
DashboardGlobalTime:
15681612
description: Object containing the live span selection for the dashboard.
15691613
properties:
@@ -1672,6 +1716,32 @@ components:
16721716
$ref: "#/components/schemas/DashboardList"
16731717
type: array
16741718
type: object
1719+
DashboardLiveTimeframe:
1720+
description: A live dashboard timeframe.
1721+
properties:
1722+
type:
1723+
$ref: "#/components/schemas/DashboardLiveTimeframeType"
1724+
unit:
1725+
$ref: "#/components/schemas/WidgetLiveSpanUnit"
1726+
value:
1727+
description: Value of the live timeframe span.
1728+
example: 4
1729+
format: int64
1730+
minimum: 1
1731+
type: integer
1732+
required:
1733+
- type
1734+
- value
1735+
- unit
1736+
type: object
1737+
DashboardLiveTimeframeType:
1738+
description: Type of live timeframe.
1739+
enum:
1740+
- live
1741+
example: live
1742+
type: string
1743+
x-enum-varnames:
1744+
- LIVE
16751745
DashboardReflowType:
16761746
description: |-
16771747
Reflow type for a **new dashboard layout** dashboard. Set this only when layout type is 'ordered'.

src/datadogV1/model/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ 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_live_timeframe;
92+
pub use self::model_dashboard_live_timeframe::DashboardLiveTimeframe;
93+
pub mod model_dashboard_live_timeframe_type;
94+
pub use self::model_dashboard_live_timeframe_type::DashboardLiveTimeframeType;
95+
pub mod model_widget_live_span_unit;
96+
pub use self::model_widget_live_span_unit::WidgetLiveSpanUnit;
97+
pub mod model_dashboard_fixed_timeframe;
98+
pub use self::model_dashboard_fixed_timeframe::DashboardFixedTimeframe;
99+
pub mod model_dashboard_fixed_timeframe_type;
100+
pub use self::model_dashboard_fixed_timeframe_type::DashboardFixedTimeframeType;
101+
pub mod model_dashboard_default_timeframe_setting;
102+
pub use self::model_dashboard_default_timeframe_setting::DashboardDefaultTimeframeSetting;
91103
pub mod model_dashboard_reflow_type;
92104
pub use self::model_dashboard_reflow_type::DashboardReflowType;
93105
pub mod model_dashboard_tab;
@@ -110,8 +122,6 @@ pub mod model_widget_new_live_span;
110122
pub use self::model_widget_new_live_span::WidgetNewLiveSpan;
111123
pub mod model_widget_new_live_span_type;
112124
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;
115125
pub mod model_widget_new_fixed_span;
116126
pub use self::model_widget_new_fixed_span::WidgetNewFixedSpan;
117127
pub mod model_widget_new_fixed_span_type;

src/datadogV1/model/model_dashboard.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ 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(
30+
rename = "default_timeframe",
31+
default,
32+
with = "::serde_with::rust::double_option"
33+
)]
34+
pub default_timeframe:
35+
Option<Option<crate::datadogV1::model::DashboardDefaultTimeframeSetting>>,
2836
/// Description of the dashboard.
2937
#[serde(
3038
rename = "description",
@@ -110,6 +118,7 @@ impl Dashboard {
110118
author_handle: None,
111119
author_name: None,
112120
created_at: None,
121+
default_timeframe: None,
113122
description: None,
114123
id: None,
115124
is_read_only: None,
@@ -148,6 +157,15 @@ impl Dashboard {
148157
self
149158
}
150159

160+
#[allow(deprecated)]
161+
pub fn default_timeframe(
162+
mut self,
163+
value: Option<crate::datadogV1::model::DashboardDefaultTimeframeSetting>,
164+
) -> Self {
165+
self.default_timeframe = Some(value);
166+
self
167+
}
168+
151169
#[allow(deprecated)]
152170
pub fn description(mut self, value: Option<String>) -> Self {
153171
self.description = Some(value);
@@ -255,6 +273,9 @@ impl<'de> Deserialize<'de> for Dashboard {
255273
let mut author_handle: Option<String> = None;
256274
let mut author_name: Option<Option<String>> = None;
257275
let mut created_at: Option<chrono::DateTime<chrono::Utc>> = None;
276+
let mut default_timeframe: Option<
277+
Option<crate::datadogV1::model::DashboardDefaultTimeframeSetting>,
278+
> = None;
258279
let mut description: Option<Option<String>> = None;
259280
let mut id: Option<String> = None;
260281
let mut is_read_only: Option<bool> = None;
@@ -299,6 +320,18 @@ impl<'de> Deserialize<'de> for Dashboard {
299320
}
300321
created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
301322
}
323+
"default_timeframe" => {
324+
default_timeframe =
325+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
326+
if let Some(ref _default_timeframe) = default_timeframe {
327+
match _default_timeframe {
328+
Some(crate::datadogV1::model::DashboardDefaultTimeframeSetting::UnparsedObject(_default_timeframe)) => {
329+
_unparsed = true;
330+
},
331+
_ => {}
332+
}
333+
}
334+
}
302335
"description" => {
303336
description =
304337
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
@@ -404,6 +437,7 @@ impl<'de> Deserialize<'de> for Dashboard {
404437
author_handle,
405438
author_name,
406439
created_at,
440+
default_timeframe,
407441
description,
408442
id,
409443
is_read_only,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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::{Deserialize, Deserializer, Serialize};
5+
6+
/// The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe.
7+
#[non_exhaustive]
8+
#[derive(Clone, Debug, PartialEq, Serialize)]
9+
#[serde(untagged)]
10+
pub enum DashboardDefaultTimeframeSetting {
11+
DashboardLiveTimeframe(Box<crate::datadogV1::model::DashboardLiveTimeframe>),
12+
DashboardFixedTimeframe(Box<crate::datadogV1::model::DashboardFixedTimeframe>),
13+
UnparsedObject(crate::datadog::UnparsedObject),
14+
}
15+
16+
impl<'de> Deserialize<'de> for DashboardDefaultTimeframeSetting {
17+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
18+
where
19+
D: Deserializer<'de>,
20+
{
21+
let value: serde_json::Value = Deserialize::deserialize(deserializer)?;
22+
if let Ok(_v) = serde_json::from_value::<Box<crate::datadogV1::model::DashboardLiveTimeframe>>(
23+
value.clone(),
24+
) {
25+
if !_v._unparsed {
26+
return Ok(DashboardDefaultTimeframeSetting::DashboardLiveTimeframe(_v));
27+
}
28+
}
29+
if let Ok(_v) = serde_json::from_value::<
30+
Box<crate::datadogV1::model::DashboardFixedTimeframe>,
31+
>(value.clone())
32+
{
33+
if !_v._unparsed {
34+
return Ok(DashboardDefaultTimeframeSetting::DashboardFixedTimeframe(
35+
_v,
36+
));
37+
}
38+
}
39+
40+
return Ok(DashboardDefaultTimeframeSetting::UnparsedObject(
41+
crate::datadog::UnparsedObject { value },
42+
));
43+
}
44+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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+
/// A fixed dashboard timeframe.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct DashboardFixedTimeframe {
14+
/// Start time in milliseconds since epoch.
15+
#[serde(rename = "from")]
16+
pub from: i64,
17+
/// End time in milliseconds since epoch.
18+
#[serde(rename = "to")]
19+
pub to: i64,
20+
/// Type of fixed timeframe.
21+
#[serde(rename = "type")]
22+
pub type_: crate::datadogV1::model::DashboardFixedTimeframeType,
23+
#[serde(flatten)]
24+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
25+
#[serde(skip)]
26+
#[serde(default)]
27+
pub(crate) _unparsed: bool,
28+
}
29+
30+
impl DashboardFixedTimeframe {
31+
pub fn new(
32+
from: i64,
33+
to: i64,
34+
type_: crate::datadogV1::model::DashboardFixedTimeframeType,
35+
) -> DashboardFixedTimeframe {
36+
DashboardFixedTimeframe {
37+
from,
38+
to,
39+
type_,
40+
additional_properties: std::collections::BTreeMap::new(),
41+
_unparsed: false,
42+
}
43+
}
44+
45+
pub fn additional_properties(
46+
mut self,
47+
value: std::collections::BTreeMap<String, serde_json::Value>,
48+
) -> Self {
49+
self.additional_properties = value;
50+
self
51+
}
52+
}
53+
54+
impl<'de> Deserialize<'de> for DashboardFixedTimeframe {
55+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
56+
where
57+
D: Deserializer<'de>,
58+
{
59+
struct DashboardFixedTimeframeVisitor;
60+
impl<'a> Visitor<'a> for DashboardFixedTimeframeVisitor {
61+
type Value = DashboardFixedTimeframe;
62+
63+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
64+
f.write_str("a mapping")
65+
}
66+
67+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
68+
where
69+
M: MapAccess<'a>,
70+
{
71+
let mut from: Option<i64> = None;
72+
let mut to: Option<i64> = None;
73+
let mut type_: Option<crate::datadogV1::model::DashboardFixedTimeframeType> = None;
74+
let mut additional_properties: std::collections::BTreeMap<
75+
String,
76+
serde_json::Value,
77+
> = std::collections::BTreeMap::new();
78+
let mut _unparsed = false;
79+
80+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
81+
match k.as_str() {
82+
"from" => {
83+
from = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
84+
}
85+
"to" => {
86+
to = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
87+
}
88+
"type" => {
89+
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
90+
if let Some(ref _type_) = type_ {
91+
match _type_ {
92+
crate::datadogV1::model::DashboardFixedTimeframeType::UnparsedObject(_type_) => {
93+
_unparsed = true;
94+
},
95+
_ => {}
96+
}
97+
}
98+
}
99+
&_ => {
100+
if let Ok(value) = serde_json::from_value(v.clone()) {
101+
additional_properties.insert(k, value);
102+
}
103+
}
104+
}
105+
}
106+
let from = from.ok_or_else(|| M::Error::missing_field("from"))?;
107+
let to = to.ok_or_else(|| M::Error::missing_field("to"))?;
108+
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;
109+
110+
let content = DashboardFixedTimeframe {
111+
from,
112+
to,
113+
type_,
114+
additional_properties,
115+
_unparsed,
116+
};
117+
118+
Ok(content)
119+
}
120+
}
121+
122+
deserializer.deserialize_any(DashboardFixedTimeframeVisitor)
123+
}
124+
}

0 commit comments

Comments
 (0)