Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark unit as nullable #65

Merged
Merged
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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-03-29 13:20:47.377297",
"spec_repo_commit": "3e55ad68"
"regenerated": "2024-04-01 14:26:16.959295",
"spec_repo_commit": "286f4535"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-03-29 13:20:47.394748",
"spec_repo_commit": "3e55ad68"
"regenerated": "2024-04-01 14:26:16.982026",
"spec_repo_commit": "286f4535"
}
}
}
1 change: 1 addition & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21742,6 +21742,7 @@ components:
If the second element is not present, the API returns null.'
items:
$ref: '#/components/schemas/Unit'
nullable: true
type: array
type: object
TimeseriesResponseSeriesList:
Expand Down
2 changes: 1 addition & 1 deletion examples/v2_metrics_query_timeseries_data_301142940.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn main() {
vec![TimeseriesQuery::MetricsTimeseriesQuery(Box::new(
MetricsTimeseriesQuery::new(
MetricsDataSource::METRICS,
"avg:system.cpu.user{*}".to_string(),
"avg:datadog.estimated_usage.metrics.custom{*}".to_string(),
)
.name("a".to_string()),
))],
Expand Down
11 changes: 4 additions & 7 deletions src/datadogV2/model/model_timeseries_response_series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pub struct TimeseriesResponseSeries {
/// The first element describes the "primary unit" (for example, `bytes` in `bytes per second`).
/// The second element describes the "per unit" (for example, `second` in `bytes per second`).
/// If the second element is not present, the API returns null.
#[serde(rename = "unit")]
pub unit: Option<Vec<Option<crate::datadogV2::model::Unit>>>,
#[serde(rename = "unit", default, with = "::serde_with::rust::double_option")]
pub unit: Option<Option<Vec<Option<crate::datadogV2::model::Unit>>>>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
Expand All @@ -48,7 +48,7 @@ impl TimeseriesResponseSeries {
self
}

pub fn unit(mut self, value: Vec<Option<crate::datadogV2::model::Unit>>) -> Self {
pub fn unit(mut self, value: Option<Vec<Option<crate::datadogV2::model::Unit>>>) -> Self {
self.unit = Some(value);
self
}
Expand Down Expand Up @@ -79,7 +79,7 @@ impl<'de> Deserialize<'de> for TimeseriesResponseSeries {
{
let mut group_tags: Option<Vec<String>> = None;
let mut query_index: Option<i32> = None;
let mut unit: Option<Vec<Option<crate::datadogV2::model::Unit>>> = None;
let mut unit: Option<Option<Vec<Option<crate::datadogV2::model::Unit>>>> = None;
let mut _unparsed = false;

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
Expand All @@ -98,9 +98,6 @@ impl<'de> Deserialize<'de> for TimeseriesResponseSeries {
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"unit" => {
if v.is_null() {
continue;
}
unit = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
&_ => {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-03-25T19:28:01.413Z
2024-04-01T14:20:01.994Z

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions tests/scenarios/features/v2/metrics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,10 @@ Feature: Metrics
Given a valid "appKeyAuth" key in the system
And operation "QueryTimeseriesData" enabled
And new "QueryTimeseriesData" request
And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "interval": 5000, "queries": [{"data_source": "metrics", "query": "avg:system.cpu.user{*}", "name": "a"}], "to": {{ timestamp('now') }}000}, "type": "timeseries_request"}}
And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "interval": 5000, "queries": [{"data_source": "metrics", "query": "avg:datadog.estimated_usage.metrics.custom{*}", "name": "a"}], "to": {{ timestamp('now') }}000}, "type": "timeseries_request"}}
When the request is sent
Then the response status is 200 OK
And the response "data.type" is equal to "timeseries_response"
And the response "data.attributes.series[0].unit[0].name" is equal to "percent"

@generated @skip @team:DataDog/metrics-experience
Scenario: Update a tag configuration returns "Bad Request" response
Expand Down
Loading