Skip to content
Closed
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
43 changes: 43 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27920,6 +27920,42 @@ components:
WidgetBackgroundColor:
description: "Background color of the widget. Supported values are `white`, `blue`, `purple`, `pink`, `orange`, `yellow`, `green`, `gray`, `vivid_blue`, `vivid_purple`, `vivid_pink`, `vivid_orange`, `vivid_yellow`, `vivid_green`, and `transparent`."
type: string
WidgetCalendarAlignedSpan:
description: Used for calendar-aligned time spans, such as the current month or previous year.
properties:
hide_incomplete_cost_data:
description: Whether to hide incomplete cost data in the widget.
type: boolean
offset:
description: Number of completed periods before the current period. 0 represents the current period.
example: 1
format: int64
minimum: 0
type: integer
timezone:
description: Time zone used to align the calendar period.
example: UTC
type: string
type:
$ref: "#/components/schemas/WidgetCalendarAlignedSpanType"
required:
- type
- offset
type: object
WidgetCalendarAlignedSpanType:
description: Calendar-aligned time span type.
enum:
- daily
- weekly
- monthly
- yearly
example: daily
type: string
x-enum-varnames:
- DAILY
- WEEKLY
- MONTHLY
- YEARLY
WidgetChangeType:
description: Show the absolute or the relative change.
enum:
Expand Down Expand Up @@ -28381,6 +28417,9 @@ components:
- month_to_date
- 1y
- alert
- full_week
- full_month
- year_to_date
example: 5m
type: string
x-enum-varnames:
Expand All @@ -28401,6 +28440,9 @@ components:
- MONTH_TO_DATE
- PAST_ONE_YEAR
- ALERT
- FULL_WEEK
- FULL_MONTH
- YEAR_TO_DATE
WidgetLiveSpanUnit:
description: Unit of the time span.
enum:
Expand Down Expand Up @@ -28784,6 +28826,7 @@ components:
- $ref: "#/components/schemas/WidgetLegacyLiveSpan"
- $ref: "#/components/schemas/WidgetNewLiveSpan"
- $ref: "#/components/schemas/WidgetNewFixedSpan"
- $ref: "#/components/schemas/WidgetCalendarAlignedSpan"
WidgetTimeWindows:
description: Define a time window.
enum:
Expand Down
4 changes: 4 additions & 0 deletions src/datadogV1/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ pub mod model_widget_new_fixed_span;
pub use self::model_widget_new_fixed_span::WidgetNewFixedSpan;
pub mod model_widget_new_fixed_span_type;
pub use self::model_widget_new_fixed_span_type::WidgetNewFixedSpanType;
pub mod model_widget_calendar_aligned_span;
pub use self::model_widget_calendar_aligned_span::WidgetCalendarAlignedSpan;
pub mod model_widget_calendar_aligned_span_type;
pub use self::model_widget_calendar_aligned_span_type::WidgetCalendarAlignedSpanType;
pub mod model_widget_time;
pub use self::model_widget_time::WidgetTime;
pub mod model_widget_text_align;
Expand Down
149 changes: 149 additions & 0 deletions src/datadogV1/model/model_widget_calendar_aligned_span.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// 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};

/// Used for calendar-aligned time spans, such as the current month or previous year.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct WidgetCalendarAlignedSpan {
/// Whether to hide incomplete cost data in the widget.
#[serde(rename = "hide_incomplete_cost_data")]
pub hide_incomplete_cost_data: Option<bool>,
/// Number of completed periods before the current period. 0 represents the current period.
#[serde(rename = "offset")]
pub offset: i64,
/// Time zone used to align the calendar period.
#[serde(rename = "timezone")]
pub timezone: Option<String>,
/// Calendar-aligned time span type.
#[serde(rename = "type")]
pub type_: crate::datadogV1::model::WidgetCalendarAlignedSpanType,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl WidgetCalendarAlignedSpan {
pub fn new(
offset: i64,
type_: crate::datadogV1::model::WidgetCalendarAlignedSpanType,
) -> WidgetCalendarAlignedSpan {
WidgetCalendarAlignedSpan {
hide_incomplete_cost_data: None,
offset,
timezone: None,
type_,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn hide_incomplete_cost_data(mut self, value: bool) -> Self {
self.hide_incomplete_cost_data = Some(value);
self
}

pub fn timezone(mut self, value: String) -> Self {
self.timezone = Some(value);
self
}

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 WidgetCalendarAlignedSpan {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct WidgetCalendarAlignedSpanVisitor;
impl<'a> Visitor<'a> for WidgetCalendarAlignedSpanVisitor {
type Value = WidgetCalendarAlignedSpan;

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 hide_incomplete_cost_data: Option<bool> = None;
let mut offset: Option<i64> = None;
let mut timezone: Option<String> = None;
let mut type_: Option<crate::datadogV1::model::WidgetCalendarAlignedSpanType> =
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() {
"hide_incomplete_cost_data" => {
if v.is_null() {
continue;
}
hide_incomplete_cost_data =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"offset" => {
offset = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"timezone" => {
if v.is_null() {
continue;
}
timezone = 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::WidgetCalendarAlignedSpanType::UnparsedObject(_type_) => {
_unparsed = true;
},
_ => {}
}
}
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
}
}
}
}
let offset = offset.ok_or_else(|| M::Error::missing_field("offset"))?;
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;

let content = WidgetCalendarAlignedSpan {
hide_incomplete_cost_data,
offset,
timezone,
type_,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(WidgetCalendarAlignedSpanVisitor)
}
}
57 changes: 57 additions & 0 deletions src/datadogV1/model/model_widget_calendar_aligned_span_type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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 WidgetCalendarAlignedSpanType {
DAILY,
WEEKLY,
MONTHLY,
YEARLY,
UnparsedObject(crate::datadog::UnparsedObject),
}

impl ToString for WidgetCalendarAlignedSpanType {
fn to_string(&self) -> String {
match self {
Self::DAILY => String::from("daily"),
Self::WEEKLY => String::from("weekly"),
Self::MONTHLY => String::from("monthly"),
Self::YEARLY => String::from("yearly"),
Self::UnparsedObject(v) => v.value.to_string(),
}
}
}

impl Serialize for WidgetCalendarAlignedSpanType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match self {
Self::UnparsedObject(v) => v.serialize(serializer),
_ => serializer.serialize_str(self.to_string().as_str()),
}
}
}

impl<'de> Deserialize<'de> for WidgetCalendarAlignedSpanType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s: String = String::deserialize(deserializer)?;
Ok(match s.as_str() {
"daily" => Self::DAILY,
"weekly" => Self::WEEKLY,
"monthly" => Self::MONTHLY,
"yearly" => Self::YEARLY,
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
value: serde_json::Value::String(s.into()),
}),
})
}
}
9 changes: 9 additions & 0 deletions src/datadogV1/model/model_widget_live_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ pub enum WidgetLiveSpan {
MONTH_TO_DATE,
PAST_ONE_YEAR,
ALERT,
FULL_WEEK,
FULL_MONTH,
YEAR_TO_DATE,
UnparsedObject(crate::datadog::UnparsedObject),
}

Expand All @@ -47,6 +50,9 @@ impl ToString for WidgetLiveSpan {
Self::MONTH_TO_DATE => String::from("month_to_date"),
Self::PAST_ONE_YEAR => String::from("1y"),
Self::ALERT => String::from("alert"),
Self::FULL_WEEK => String::from("full_week"),
Self::FULL_MONTH => String::from("full_month"),
Self::YEAR_TO_DATE => String::from("year_to_date"),
Self::UnparsedObject(v) => v.value.to_string(),
}
}
Expand Down Expand Up @@ -88,6 +94,9 @@ impl<'de> Deserialize<'de> for WidgetLiveSpan {
"month_to_date" => Self::MONTH_TO_DATE,
"1y" => Self::PAST_ONE_YEAR,
"alert" => Self::ALERT,
"full_week" => Self::FULL_WEEK,
"full_month" => Self::FULL_MONTH,
"year_to_date" => Self::YEAR_TO_DATE,
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
value: serde_json::Value::String(s.into()),
}),
Expand Down
9 changes: 9 additions & 0 deletions src/datadogV1/model/model_widget_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub enum WidgetTime {
WidgetLegacyLiveSpan(Box<crate::datadogV1::model::WidgetLegacyLiveSpan>),
WidgetNewLiveSpan(Box<crate::datadogV1::model::WidgetNewLiveSpan>),
WidgetNewFixedSpan(Box<crate::datadogV1::model::WidgetNewFixedSpan>),
WidgetCalendarAlignedSpan(Box<crate::datadogV1::model::WidgetCalendarAlignedSpan>),
UnparsedObject(crate::datadog::UnparsedObject),
}

Expand Down Expand Up @@ -41,6 +42,14 @@ impl<'de> Deserialize<'de> for WidgetTime {
return Ok(WidgetTime::WidgetNewFixedSpan(_v));
}
}
if let Ok(_v) = serde_json::from_value::<
Box<crate::datadogV1::model::WidgetCalendarAlignedSpan>,
>(value.clone())
{
if !_v._unparsed {
return Ok(WidgetTime::WidgetCalendarAlignedSpan(_v));
}
}

return Ok(WidgetTime::UnparsedObject(crate::datadog::UnparsedObject {
value,
Expand Down
Loading