Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,8 @@ components:
format: date-time
readOnly: true
type: string
default_timeframe:
$ref: "#/components/schemas/DashboardDefaultTimeframeSetting"
description:
description: Description of the dashboard.
nullable: true
Expand Down Expand Up @@ -1557,13 +1559,55 @@ components:
required:
- data
type: object
DashboardDefaultTimeframeSetting:
description: The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe.
discriminator:
mapping:
fixed: "#/components/schemas/DashboardFixedTimeframe"
live: "#/components/schemas/DashboardLiveTimeframe"
propertyName: type
nullable: true
oneOf:
- $ref: "#/components/schemas/DashboardLiveTimeframe"
- $ref: "#/components/schemas/DashboardFixedTimeframe"
type: object
DashboardDeleteResponse:
description: Response from the delete dashboard call.
properties:
deleted_dashboard_id:
description: ID of the deleted dashboard.
type: string
type: object
DashboardFixedTimeframe:
description: A fixed dashboard timeframe.
properties:
from:
description: Start time in milliseconds since epoch.
example: 1712080128000
format: int64
minimum: 0
type: integer
to:
description: End time in milliseconds since epoch.
example: 1712083128000
format: int64
minimum: 0
type: integer
type:
$ref: "#/components/schemas/DashboardFixedTimeframeType"
required:
- type
- from
- to
type: object
DashboardFixedTimeframeType:
description: Type of fixed timeframe.
enum:
- fixed
example: fixed
type: string
x-enum-varnames:
- FIXED
DashboardGlobalTime:
description: Object containing the live span selection for the dashboard.
properties:
Expand Down Expand Up @@ -1672,6 +1716,32 @@ components:
$ref: "#/components/schemas/DashboardList"
type: array
type: object
DashboardLiveTimeframe:
description: A live dashboard timeframe.
properties:
type:
$ref: "#/components/schemas/DashboardLiveTimeframeType"
unit:
$ref: "#/components/schemas/WidgetLiveSpanUnit"
value:
description: Value of the live timeframe span.
example: 4
format: int64
minimum: 1
type: integer
required:
- type
- value
- unit
type: object
DashboardLiveTimeframeType:
description: Type of live timeframe.
enum:
- live
example: live
type: string
x-enum-varnames:
- LIVE
DashboardReflowType:
description: |-
Reflow type for a **new dashboard layout** dashboard. Set this only when layout type is 'ordered'.
Expand Down
14 changes: 12 additions & 2 deletions src/datadogV1/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ pub mod model_dashboard_restore_request;
pub use self::model_dashboard_restore_request::DashboardRestoreRequest;
pub mod model_dashboard;
pub use self::model_dashboard::Dashboard;
pub mod model_dashboard_live_timeframe;
pub use self::model_dashboard_live_timeframe::DashboardLiveTimeframe;
pub mod model_dashboard_live_timeframe_type;
pub use self::model_dashboard_live_timeframe_type::DashboardLiveTimeframeType;
pub mod model_widget_live_span_unit;
pub use self::model_widget_live_span_unit::WidgetLiveSpanUnit;
pub mod model_dashboard_fixed_timeframe;
pub use self::model_dashboard_fixed_timeframe::DashboardFixedTimeframe;
pub mod model_dashboard_fixed_timeframe_type;
pub use self::model_dashboard_fixed_timeframe_type::DashboardFixedTimeframeType;
pub mod model_dashboard_default_timeframe_setting;
pub use self::model_dashboard_default_timeframe_setting::DashboardDefaultTimeframeSetting;
pub mod model_dashboard_reflow_type;
pub use self::model_dashboard_reflow_type::DashboardReflowType;
pub mod model_dashboard_tab;
Expand All @@ -110,8 +122,6 @@ pub mod model_widget_new_live_span;
pub use self::model_widget_new_live_span::WidgetNewLiveSpan;
pub mod model_widget_new_live_span_type;
pub use self::model_widget_new_live_span_type::WidgetNewLiveSpanType;
pub mod model_widget_live_span_unit;
pub use self::model_widget_live_span_unit::WidgetLiveSpanUnit;
pub mod model_widget_new_fixed_span;
pub use self::model_widget_new_fixed_span::WidgetNewFixedSpan;
pub mod model_widget_new_fixed_span_type;
Expand Down
34 changes: 34 additions & 0 deletions src/datadogV1/model/model_dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ pub struct Dashboard {
/// Creation date of the dashboard.
#[serde(rename = "created_at")]
pub created_at: Option<chrono::DateTime<chrono::Utc>>,
/// The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe.
#[serde(
rename = "default_timeframe",
default,
with = "::serde_with::rust::double_option"
)]
pub default_timeframe:
Option<Option<crate::datadogV1::model::DashboardDefaultTimeframeSetting>>,
/// Description of the dashboard.
#[serde(
rename = "description",
Expand Down Expand Up @@ -110,6 +118,7 @@ impl Dashboard {
author_handle: None,
author_name: None,
created_at: None,
default_timeframe: None,
description: None,
id: None,
is_read_only: None,
Expand Down Expand Up @@ -148,6 +157,15 @@ impl Dashboard {
self
}

#[allow(deprecated)]
pub fn default_timeframe(
mut self,
value: Option<crate::datadogV1::model::DashboardDefaultTimeframeSetting>,
) -> Self {
self.default_timeframe = Some(value);
self
}

#[allow(deprecated)]
pub fn description(mut self, value: Option<String>) -> Self {
self.description = Some(value);
Expand Down Expand Up @@ -255,6 +273,9 @@ impl<'de> Deserialize<'de> for Dashboard {
let mut author_handle: Option<String> = None;
let mut author_name: Option<Option<String>> = None;
let mut created_at: Option<chrono::DateTime<chrono::Utc>> = None;
let mut default_timeframe: Option<
Option<crate::datadogV1::model::DashboardDefaultTimeframeSetting>,
> = None;
let mut description: Option<Option<String>> = None;
let mut id: Option<String> = None;
let mut is_read_only: Option<bool> = None;
Expand Down Expand Up @@ -299,6 +320,18 @@ impl<'de> Deserialize<'de> for Dashboard {
}
created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"default_timeframe" => {
default_timeframe =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _default_timeframe) = default_timeframe {
match _default_timeframe {
Some(crate::datadogV1::model::DashboardDefaultTimeframeSetting::UnparsedObject(_default_timeframe)) => {
_unparsed = true;
},
_ => {}
}
}
}
"description" => {
description =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
Expand Down Expand Up @@ -404,6 +437,7 @@ impl<'de> Deserialize<'de> for Dashboard {
author_handle,
author_name,
created_at,
default_timeframe,
description,
id,
is_read_only,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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};

/// The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe.
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq, Serialize)]
#[serde(untagged)]
pub enum DashboardDefaultTimeframeSetting {
DashboardLiveTimeframe(Box<crate::datadogV1::model::DashboardLiveTimeframe>),
DashboardFixedTimeframe(Box<crate::datadogV1::model::DashboardFixedTimeframe>),
UnparsedObject(crate::datadog::UnparsedObject),
}

impl<'de> Deserialize<'de> for DashboardDefaultTimeframeSetting {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let value: serde_json::Value = Deserialize::deserialize(deserializer)?;
if let Ok(_v) = serde_json::from_value::<Box<crate::datadogV1::model::DashboardLiveTimeframe>>(
value.clone(),
) {
if !_v._unparsed {
return Ok(DashboardDefaultTimeframeSetting::DashboardLiveTimeframe(_v));
}
}
if let Ok(_v) = serde_json::from_value::<
Box<crate::datadogV1::model::DashboardFixedTimeframe>,
>(value.clone())
{
if !_v._unparsed {
return Ok(DashboardDefaultTimeframeSetting::DashboardFixedTimeframe(
_v,
));
}
}

return Ok(DashboardDefaultTimeframeSetting::UnparsedObject(
crate::datadog::UnparsedObject { value },
));
}
}
124 changes: 124 additions & 0 deletions src/datadogV1/model/model_dashboard_fixed_timeframe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// 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};

/// A fixed dashboard timeframe.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct DashboardFixedTimeframe {
/// Start time in milliseconds since epoch.
#[serde(rename = "from")]
pub from: i64,
/// End time in milliseconds since epoch.
#[serde(rename = "to")]
pub to: i64,
/// Type of fixed timeframe.
#[serde(rename = "type")]
pub type_: crate::datadogV1::model::DashboardFixedTimeframeType,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl DashboardFixedTimeframe {
pub fn new(
from: i64,
to: i64,
type_: crate::datadogV1::model::DashboardFixedTimeframeType,
) -> DashboardFixedTimeframe {
DashboardFixedTimeframe {
from,
to,
type_,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
) -> Self {
self.additional_properties = value;
self
}
}

impl<'de> Deserialize<'de> for DashboardFixedTimeframe {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct DashboardFixedTimeframeVisitor;
impl<'a> Visitor<'a> for DashboardFixedTimeframeVisitor {
type Value = DashboardFixedTimeframe;

fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("a mapping")
}

fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'a>,
{
let mut from: Option<i64> = None;
let mut to: Option<i64> = None;
let mut type_: Option<crate::datadogV1::model::DashboardFixedTimeframeType> = 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::<String, serde_json::Value>()? {
match k.as_str() {
"from" => {
from = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"to" => {
to = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"type" => {
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _type_) = type_ {
match _type_ {
crate::datadogV1::model::DashboardFixedTimeframeType::UnparsedObject(_type_) => {
_unparsed = true;
},
_ => {}
}
}
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
}
}
}
}
let from = from.ok_or_else(|| M::Error::missing_field("from"))?;
let to = to.ok_or_else(|| M::Error::missing_field("to"))?;
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;

let content = DashboardFixedTimeframe {
from,
to,
type_,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(DashboardFixedTimeframeVisitor)
}
}
Loading
Loading