Skip to content

Commit

Permalink
Remove deprecated warnings (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
skarimo authored Mar 14, 2024
1 parent 70e3a28 commit 76fbd1d
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .generator/src/generator/templates/model_simple.j2
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,22 @@ impl<'de> Deserialize<'de> for {{ name }} {
}
}

{%- set ns = namespace(hasDeprecated=false) %}
{%- for attr, schema in model.get("properties", {}).items() %}
{%- set required = attr in model.required %}
{%- set propertyName = attr|variable_name %}
{%- set nullable = schema.get("nullable", false)%}
{%- if schema.deprecated %}
{%- set ns.hasDeprecated = true %}
{%- endif %}
{%- if required %}
let {{ propertyName }} = {{ propertyName }}.ok_or_else(|| M::Error::missing_field("{{ propertyName }}"))?;
{%- endif %}
{%- endfor %}

{% if ns.hasDeprecated %}
#[allow(deprecated)]
{% endif%}
let content = {{ name }} {
{%- for attr, schema in model.get("properties", {}).items() %}
{%- set propertyName = attr|variable_name %}
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ impl<'de> Deserialize<'de> for Dashboard {
let title = title.ok_or_else(|| M::Error::missing_field("title"))?;
let widgets = widgets.ok_or_else(|| M::Error::missing_field("widgets"))?;

#[allow(deprecated)]
let content = Dashboard {
author_handle,
author_name,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_dashboard_template_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ impl<'de> Deserialize<'de> for DashboardTemplateVariable {
}
let name = name.ok_or_else(|| M::Error::missing_field("name"))?;

#[allow(deprecated)]
let content = DashboardTemplateVariable {
available_values,
default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl<'de> Deserialize<'de> for DashboardTemplateVariablePresetValue {
}
}

#[allow(deprecated)]
let content = DashboardTemplateVariablePresetValue {
name,
value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ impl<'de> Deserialize<'de> for DistributionWidgetDefinition {
let requests = requests.ok_or_else(|| M::Error::missing_field("requests"))?;
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;

#[allow(deprecated)]
let content = DistributionWidgetDefinition {
custom_links,
legend_size,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_log_stream_widget_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ impl<'de> Deserialize<'de> for LogStreamWidgetDefinition {
}
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;

#[allow(deprecated)]
let content = LogStreamWidgetDefinition {
columns,
indexes,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_monitor_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ impl<'de> Deserialize<'de> for MonitorOptions {
}
}

#[allow(deprecated)]
let content = MonitorOptions {
aggregation,
device_ids,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ impl<'de> Deserialize<'de> for MonitorSummaryWidgetDefinition {
let query = query.ok_or_else(|| M::Error::missing_field("query"))?;
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;

#[allow(deprecated)]
let content = MonitorSummaryWidgetDefinition {
color_preference,
count,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_organization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ impl<'de> Deserialize<'de> for Organization {
}
}

#[allow(deprecated)]
let content = Organization {
billing,
created,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_organization_create_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ impl<'de> Deserialize<'de> for OrganizationCreateBody {
}
let name = name.ok_or_else(|| M::Error::missing_field("name"))?;

#[allow(deprecated)]
let content = OrganizationCreateBody {
billing,
name,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_slo_history_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ impl<'de> Deserialize<'de> for SLOHistoryMonitor {
}
}

#[allow(deprecated)]
let content = SLOHistoryMonitor {
error_budget_remaining,
errors,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_slo_history_sli_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ impl<'de> Deserialize<'de> for SLOHistorySLIData {
}
}

#[allow(deprecated)]
let content = SLOHistorySLIData {
error_budget_remaining,
errors,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_tree_map_widget_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ impl<'de> Deserialize<'de> for TreeMapWidgetDefinition {
let requests = requests.ok_or_else(|| M::Error::missing_field("requests"))?;
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;

#[allow(deprecated)]
let content = TreeMapWidgetDefinition {
color_by,
custom_links,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_usage_summary_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,7 @@ impl<'de> Deserialize<'de> for UsageSummaryDate {
}
}

#[allow(deprecated)]
let content = UsageSummaryDate {
agent_host_top99p,
apm_azure_app_service_host_top99p,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_usage_summary_date_org.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,7 @@ impl<'de> Deserialize<'de> for UsageSummaryDateOrg {
}
}

#[allow(deprecated)]
let content = UsageSummaryDateOrg {
agent_host_top99p,
apm_azure_app_service_host_top99p,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV1/model/model_usage_summary_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,7 @@ impl<'de> Deserialize<'de> for UsageSummaryResponse {
}
}

#[allow(deprecated)]
let content = UsageSummaryResponse {
agent_host_top99p_sum,
apm_azure_app_service_host_top99p_sum,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV2/model/model_aws_cur_config_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ impl<'de> Deserialize<'de> for AwsCURConfigAttributes {
report_prefix.ok_or_else(|| M::Error::missing_field("report_prefix"))?;
let status = status.ok_or_else(|| M::Error::missing_field("status"))?;

#[allow(deprecated)]
let content = AwsCURConfigAttributes {
account_id,
bucket_name,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV2/model/model_azure_uc_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ impl<'de> Deserialize<'de> for AzureUCConfig {
let storage_container = storage_container
.ok_or_else(|| M::Error::missing_field("storage_container"))?;

#[allow(deprecated)]
let content = AzureUCConfig {
account_id,
client_id,
Expand Down
1 change: 1 addition & 0 deletions src/datadogV2/model/model_rule_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ impl<'de> Deserialize<'de> for RuleAttributes {
}
}

#[allow(deprecated)]
let content = RuleAttributes {
category,
created_at,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ impl<'de> Deserialize<'de> for SecurityMonitoringStandardRuleQuery {
}
}

#[allow(deprecated)]
let content = SecurityMonitoringStandardRuleQuery {
aggregation,
distinct_fields,
Expand Down
8 changes: 4 additions & 4 deletions tests/scenarios/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,10 @@ fn relative_time_helper(v: &String, ts: i64) -> DateTime<chrono::Utc> {
)
.unwrap();
match caps.get(3).unwrap().as_str() {
"s" => time.add(Duration::seconds(diff)),
"m" => time.add(Duration::minutes(diff)),
"h" => time.add(Duration::hours(diff)),
"d" => time.add(Duration::days(diff)),
"s" => time.add(Duration::try_seconds(diff).unwrap()),
"m" => time.add(Duration::try_minutes(diff).unwrap()),
"h" => time.add(Duration::try_hours(diff).unwrap()),
"d" => time.add(Duration::try_days(diff).unwrap()),
"M" => {
if diff > 0 {
time.checked_add_months(Months::new(diff as u32)).unwrap()
Expand Down

0 comments on commit 76fbd1d

Please sign in to comment.