Skip to content

Commit e7ac0fb

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit d6e52321 of spec repo
1 parent 3091346 commit e7ac0fb

15 files changed

+964
-5
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-02-14 15:03:43.490025",
8-
"spec_repo_commit": "a739b49f"
7+
"regenerated": "2025-02-17 08:34:45.011320",
8+
"spec_repo_commit": "d6e52321"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-02-14 15:03:43.505675",
13-
"spec_repo_commit": "a739b49f"
12+
"regenerated": "2025-02-17 08:34:45.029283",
13+
"spec_repo_commit": "d6e52321"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9727,6 +9727,62 @@ components:
97279727
items:
97289728
$ref: '#/components/schemas/NotifyEndType'
97299729
type: array
9730+
NumberFormatUnit:
9731+
description: Number format unit.
9732+
oneOf:
9733+
- $ref: '#/components/schemas/NumberFormatUnitCanonical'
9734+
- $ref: '#/components/schemas/NumberFormatUnitCustom'
9735+
NumberFormatUnitCanonical:
9736+
description: Canonical unit.
9737+
properties:
9738+
per_unit_name:
9739+
description: The name of the unit per item.
9740+
example: bytes
9741+
type: string
9742+
type:
9743+
$ref: '#/components/schemas/NumberFormatUnitScaleType'
9744+
unit_name:
9745+
description: The name of the unit.
9746+
example: bytes
9747+
type: string
9748+
type: object
9749+
NumberFormatUnitCustom:
9750+
description: Custom unit.
9751+
properties:
9752+
label:
9753+
description: The label for the custom unit.
9754+
maxLength: 12
9755+
minLength: 1
9756+
type: string
9757+
type:
9758+
$ref: '#/components/schemas/NumberFormatUnitCustomType'
9759+
type: object
9760+
NumberFormatUnitCustomType:
9761+
description: The type of custom unit.
9762+
enum:
9763+
- custom_unit_label
9764+
type: string
9765+
x-enum-varnames:
9766+
- CUSTOM_UNIT_LABEL
9767+
NumberFormatUnitScale:
9768+
description: The definition of `NumberFormatUnitScale` object.
9769+
nullable: true
9770+
properties:
9771+
type:
9772+
$ref: '#/components/schemas/NumberFormatUnitScaleType'
9773+
unit_name:
9774+
description: The name of the unit.
9775+
example: bytes
9776+
type: string
9777+
type: object
9778+
NumberFormatUnitScaleType:
9779+
description: The type of unit scale.
9780+
enum:
9781+
- canonical_unit
9782+
example: canonical_unit
9783+
type: string
9784+
x-enum-varnames:
9785+
- CANONICAL_UNIT
97309786
OnMissingDataOption:
97319787
description: 'Controls how groups or monitors are treated if an evaluation does
97329788
not return any data points.
@@ -23044,6 +23100,8 @@ components:
2304423100
type: string
2304523101
limit:
2304623102
$ref: '#/components/schemas/WidgetFormulaLimit'
23103+
number_format:
23104+
$ref: '#/components/schemas/WidgetNumberFormat'
2304723105
style:
2304823106
$ref: '#/components/schemas/WidgetFormulaStyle'
2304923107
required:
@@ -23463,6 +23521,14 @@ components:
2346323521
x-enum-varnames:
2346423522
- HOST
2346523523
- CONTAINER
23524+
WidgetNumberFormat:
23525+
description: Number format options for the widget.
23526+
properties:
23527+
unit:
23528+
$ref: '#/components/schemas/NumberFormatUnit'
23529+
unit_scale:
23530+
$ref: '#/components/schemas/NumberFormatUnitScale'
23531+
type: object
2346623532
WidgetOrderBy:
2346723533
description: What to order by.
2346823534
enum:

LICENSE-3rdparty.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ darling,https://github.com/TedDriggs/darling,MIT,Ted Driggs <ted.driggs@outlook.
2121
deranged,https://github.com/jhpratt/deranged,MIT OR Apache-2.0,Jacob Pratt <[email protected]>
2222
displaydoc,https://github.com/yaahc/displaydoc,MIT OR Apache-2.0,Jane Lusby <[email protected]>
2323
encoding_rs,https://github.com/hsivonen/encoding_rs,(Apache-2.0 OR MIT) AND BSD-3-Clause,Henri Sivonen <[email protected]>
24-
equivalent,https://github.com/cuviper/equivalent,Apache-2.0 OR MIT,The equivalent Authors
24+
equivalent,https://github.com/indexmap-rs/equivalent,Apache-2.0 OR MIT,The equivalent Authors
2525
errno,https://github.com/lambda-fairy/rust-errno,MIT OR Apache-2.0,Chris Wong <[email protected]>
2626
fastrand,https://github.com/smol-rs/fastrand,Apache-2.0 OR MIT,Stjepan Glavina <[email protected]>
2727
flate2,https://github.com/rust-lang/flate2-rs,MIT OR Apache-2.0,"Alex Crichton <[email protected]>, Josh Triplett <[email protected]>"
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// Create a new dashboard with timeseries widget with custom_unit
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV1::api_dashboards::DashboardsAPI;
4+
use datadog_api_client::datadogV1::model::Dashboard;
5+
use datadog_api_client::datadogV1::model::DashboardLayoutType;
6+
use datadog_api_client::datadogV1::model::DashboardReflowType;
7+
use datadog_api_client::datadogV1::model::FormulaAndFunctionMetricDataSource;
8+
use datadog_api_client::datadogV1::model::FormulaAndFunctionMetricQueryDefinition;
9+
use datadog_api_client::datadogV1::model::FormulaAndFunctionQueryDefinition;
10+
use datadog_api_client::datadogV1::model::FormulaAndFunctionResponseFormat;
11+
use datadog_api_client::datadogV1::model::NumberFormatUnit;
12+
use datadog_api_client::datadogV1::model::NumberFormatUnitCanonical;
13+
use datadog_api_client::datadogV1::model::NumberFormatUnitScale;
14+
use datadog_api_client::datadogV1::model::NumberFormatUnitScaleType;
15+
use datadog_api_client::datadogV1::model::TimeseriesWidgetDefinition;
16+
use datadog_api_client::datadogV1::model::TimeseriesWidgetDefinitionType;
17+
use datadog_api_client::datadogV1::model::TimeseriesWidgetLegendLayout;
18+
use datadog_api_client::datadogV1::model::TimeseriesWidgetRequest;
19+
use datadog_api_client::datadogV1::model::Widget;
20+
use datadog_api_client::datadogV1::model::WidgetDefinition;
21+
use datadog_api_client::datadogV1::model::WidgetDisplayType;
22+
use datadog_api_client::datadogV1::model::WidgetFormula;
23+
use datadog_api_client::datadogV1::model::WidgetLayout;
24+
use datadog_api_client::datadogV1::model::WidgetLegacyLiveSpan;
25+
use datadog_api_client::datadogV1::model::WidgetNumberFormat;
26+
use datadog_api_client::datadogV1::model::WidgetTextAlign;
27+
use datadog_api_client::datadogV1::model::WidgetTime;
28+
29+
#[tokio::main]
30+
async fn main() {
31+
let body =
32+
Dashboard::new(
33+
DashboardLayoutType::ORDERED,
34+
"Example-Dashboard".to_string(),
35+
vec![
36+
Widget::new(
37+
WidgetDefinition::TimeseriesWidgetDefinition(
38+
Box::new(
39+
TimeseriesWidgetDefinition::new(
40+
vec![
41+
TimeseriesWidgetRequest::new()
42+
.display_type(WidgetDisplayType::LINE)
43+
.formulas(
44+
vec![
45+
WidgetFormula::new(
46+
"query1".to_string(),
47+
).number_format(
48+
WidgetNumberFormat::new()
49+
.unit(
50+
NumberFormatUnit::NumberFormatUnitCanonical(
51+
Box::new(
52+
NumberFormatUnitCanonical::new()
53+
.type_(
54+
NumberFormatUnitScaleType::CANONICAL_UNIT,
55+
)
56+
.unit_name("fraction".to_string()),
57+
),
58+
),
59+
)
60+
.unit_scale(
61+
Some(
62+
NumberFormatUnitScale::new()
63+
.type_(NumberFormatUnitScaleType::CANONICAL_UNIT)
64+
.unit_name("apdex".to_string()),
65+
),
66+
),
67+
)
68+
],
69+
)
70+
.queries(
71+
vec![
72+
FormulaAndFunctionQueryDefinition
73+
::FormulaAndFunctionMetricQueryDefinition(
74+
Box::new(
75+
FormulaAndFunctionMetricQueryDefinition::new(
76+
FormulaAndFunctionMetricDataSource::METRICS,
77+
"query1".to_string(),
78+
"avg:system.cpu.user{*}".to_string(),
79+
),
80+
),
81+
)
82+
],
83+
)
84+
.response_format(FormulaAndFunctionResponseFormat::TIMESERIES)
85+
],
86+
TimeseriesWidgetDefinitionType::TIMESERIES,
87+
)
88+
.legend_layout(TimeseriesWidgetLegendLayout::AUTO)
89+
.show_legend(true)
90+
.time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
91+
.title("".to_string())
92+
.title_align(WidgetTextAlign::LEFT)
93+
.title_size("16".to_string()),
94+
),
95+
),
96+
).layout(WidgetLayout::new(5, 12, 0, 0))
97+
],
98+
)
99+
.description(Some("".to_string()))
100+
.notify_list(Some(vec![]))
101+
.reflow_type(DashboardReflowType::FIXED)
102+
.template_variables(Some(vec![]));
103+
let configuration = datadog::Configuration::new();
104+
let api = DashboardsAPI::with_config(configuration);
105+
let resp = api.create_dashboard(body).await;
106+
if let Ok(value) = resp {
107+
println!("{:#?}", value);
108+
} else {
109+
println!("{:#?}", resp.unwrap_err());
110+
}
111+
}

src/datadogV1/model/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ pub mod model_widget_formula_limit;
162162
pub use self::model_widget_formula_limit::WidgetFormulaLimit;
163163
pub mod model_query_sort_order;
164164
pub use self::model_query_sort_order::QuerySortOrder;
165+
pub mod model_widget_number_format;
166+
pub use self::model_widget_number_format::WidgetNumberFormat;
167+
pub mod model_number_format_unit_canonical;
168+
pub use self::model_number_format_unit_canonical::NumberFormatUnitCanonical;
169+
pub mod model_number_format_unit_scale_type;
170+
pub use self::model_number_format_unit_scale_type::NumberFormatUnitScaleType;
171+
pub mod model_number_format_unit_custom;
172+
pub use self::model_number_format_unit_custom::NumberFormatUnitCustom;
173+
pub mod model_number_format_unit_custom_type;
174+
pub use self::model_number_format_unit_custom_type::NumberFormatUnitCustomType;
175+
pub mod model_number_format_unit;
176+
pub use self::model_number_format_unit::NumberFormatUnit;
177+
pub mod model_number_format_unit_scale;
178+
pub use self::model_number_format_unit_scale::NumberFormatUnitScale;
165179
pub mod model_widget_formula_style;
166180
pub use self::model_widget_formula_style::WidgetFormulaStyle;
167181
pub mod model_widget_order_by;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
/// Number format unit.
7+
#[non_exhaustive]
8+
#[derive(Clone, Debug, PartialEq, Serialize)]
9+
#[serde(untagged)]
10+
pub enum NumberFormatUnit {
11+
NumberFormatUnitCanonical(Box<crate::datadogV1::model::NumberFormatUnitCanonical>),
12+
NumberFormatUnitCustom(Box<crate::datadogV1::model::NumberFormatUnitCustom>),
13+
UnparsedObject(crate::datadog::UnparsedObject),
14+
}
15+
16+
impl<'de> Deserialize<'de> for NumberFormatUnit {
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::<
23+
Box<crate::datadogV1::model::NumberFormatUnitCanonical>,
24+
>(value.clone())
25+
{
26+
if !_v._unparsed {
27+
return Ok(NumberFormatUnit::NumberFormatUnitCanonical(_v));
28+
}
29+
}
30+
if let Ok(_v) = serde_json::from_value::<Box<crate::datadogV1::model::NumberFormatUnitCustom>>(
31+
value.clone(),
32+
) {
33+
if !_v._unparsed {
34+
return Ok(NumberFormatUnit::NumberFormatUnitCustom(_v));
35+
}
36+
}
37+
38+
return Ok(NumberFormatUnit::UnparsedObject(
39+
crate::datadog::UnparsedObject { value },
40+
));
41+
}
42+
}

0 commit comments

Comments
 (0)