diff --git a/.generator/src/generator/templates/model_simple.j2 b/.generator/src/generator/templates/model_simple.j2 index 2f7e83e11..c48f877a6 100644 --- a/.generator/src/generator/templates/model_simple.j2 +++ b/.generator/src/generator/templates/model_simple.j2 @@ -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 %} diff --git a/src/datadogV1/model/model_dashboard.rs b/src/datadogV1/model/model_dashboard.rs index 32b466b56..12e3eb491 100644 --- a/src/datadogV1/model/model_dashboard.rs +++ b/src/datadogV1/model/model_dashboard.rs @@ -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, diff --git a/src/datadogV1/model/model_dashboard_template_variable.rs b/src/datadogV1/model/model_dashboard_template_variable.rs index b4fa73a4b..159e5a99e 100644 --- a/src/datadogV1/model/model_dashboard_template_variable.rs +++ b/src/datadogV1/model/model_dashboard_template_variable.rs @@ -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, diff --git a/src/datadogV1/model/model_dashboard_template_variable_preset_value.rs b/src/datadogV1/model/model_dashboard_template_variable_preset_value.rs index 6966b1ce1..020f759ac 100644 --- a/src/datadogV1/model/model_dashboard_template_variable_preset_value.rs +++ b/src/datadogV1/model/model_dashboard_template_variable_preset_value.rs @@ -108,6 +108,7 @@ impl<'de> Deserialize<'de> for DashboardTemplateVariablePresetValue { } } + #[allow(deprecated)] let content = DashboardTemplateVariablePresetValue { name, value, diff --git a/src/datadogV1/model/model_distribution_widget_definition.rs b/src/datadogV1/model/model_distribution_widget_definition.rs index 763e1cb3e..76e1ff8e8 100644 --- a/src/datadogV1/model/model_distribution_widget_definition.rs +++ b/src/datadogV1/model/model_distribution_widget_definition.rs @@ -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, diff --git a/src/datadogV1/model/model_log_stream_widget_definition.rs b/src/datadogV1/model/model_log_stream_widget_definition.rs index 655cb5326..2945a6c38 100644 --- a/src/datadogV1/model/model_log_stream_widget_definition.rs +++ b/src/datadogV1/model/model_log_stream_widget_definition.rs @@ -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, diff --git a/src/datadogV1/model/model_monitor_options.rs b/src/datadogV1/model/model_monitor_options.rs index 4ccc4e671..ca6a809b0 100644 --- a/src/datadogV1/model/model_monitor_options.rs +++ b/src/datadogV1/model/model_monitor_options.rs @@ -706,6 +706,7 @@ impl<'de> Deserialize<'de> for MonitorOptions { } } + #[allow(deprecated)] let content = MonitorOptions { aggregation, device_ids, diff --git a/src/datadogV1/model/model_monitor_summary_widget_definition.rs b/src/datadogV1/model/model_monitor_summary_widget_definition.rs index 0e09cf674..7221c1ffc 100644 --- a/src/datadogV1/model/model_monitor_summary_widget_definition.rs +++ b/src/datadogV1/model/model_monitor_summary_widget_definition.rs @@ -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, diff --git a/src/datadogV1/model/model_organization.rs b/src/datadogV1/model/model_organization.rs index 9b80fd099..c82c03079 100644 --- a/src/datadogV1/model/model_organization.rs +++ b/src/datadogV1/model/model_organization.rs @@ -200,6 +200,7 @@ impl<'de> Deserialize<'de> for Organization { } } + #[allow(deprecated)] let content = Organization { billing, created, diff --git a/src/datadogV1/model/model_organization_create_body.rs b/src/datadogV1/model/model_organization_create_body.rs index ecc510aec..f4ecea488 100644 --- a/src/datadogV1/model/model_organization_create_body.rs +++ b/src/datadogV1/model/model_organization_create_body.rs @@ -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, diff --git a/src/datadogV1/model/model_slo_history_monitor.rs b/src/datadogV1/model/model_slo_history_monitor.rs index 51b6be77e..ff59620af 100644 --- a/src/datadogV1/model/model_slo_history_monitor.rs +++ b/src/datadogV1/model/model_slo_history_monitor.rs @@ -278,6 +278,7 @@ impl<'de> Deserialize<'de> for SLOHistoryMonitor { } } + #[allow(deprecated)] let content = SLOHistoryMonitor { error_budget_remaining, errors, diff --git a/src/datadogV1/model/model_slo_history_sli_data.rs b/src/datadogV1/model/model_slo_history_sli_data.rs index cebf63560..df2d2d9bf 100644 --- a/src/datadogV1/model/model_slo_history_sli_data.rs +++ b/src/datadogV1/model/model_slo_history_sli_data.rs @@ -274,6 +274,7 @@ impl<'de> Deserialize<'de> for SLOHistorySLIData { } } + #[allow(deprecated)] let content = SLOHistorySLIData { error_budget_remaining, errors, diff --git a/src/datadogV1/model/model_tree_map_widget_definition.rs b/src/datadogV1/model/model_tree_map_widget_definition.rs index 31d569982..4ee548830 100644 --- a/src/datadogV1/model/model_tree_map_widget_definition.rs +++ b/src/datadogV1/model/model_tree_map_widget_definition.rs @@ -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, diff --git a/src/datadogV1/model/model_usage_summary_date.rs b/src/datadogV1/model/model_usage_summary_date.rs index 08482b05f..a9c044705 100644 --- a/src/datadogV1/model/model_usage_summary_date.rs +++ b/src/datadogV1/model/model_usage_summary_date.rs @@ -1891,6 +1891,7 @@ impl<'de> Deserialize<'de> for UsageSummaryDate { } } + #[allow(deprecated)] let content = UsageSummaryDate { agent_host_top99p, apm_azure_app_service_host_top99p, diff --git a/src/datadogV1/model/model_usage_summary_date_org.rs b/src/datadogV1/model/model_usage_summary_date_org.rs index 66adefb0e..26f4abca3 100644 --- a/src/datadogV1/model/model_usage_summary_date_org.rs +++ b/src/datadogV1/model/model_usage_summary_date_org.rs @@ -1961,6 +1961,7 @@ impl<'de> Deserialize<'de> for UsageSummaryDateOrg { } } + #[allow(deprecated)] let content = UsageSummaryDateOrg { agent_host_top99p, apm_azure_app_service_host_top99p, diff --git a/src/datadogV1/model/model_usage_summary_response.rs b/src/datadogV1/model/model_usage_summary_response.rs index bc9679271..5b795a50b 100644 --- a/src/datadogV1/model/model_usage_summary_response.rs +++ b/src/datadogV1/model/model_usage_summary_response.rs @@ -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, diff --git a/src/datadogV2/model/model_aws_cur_config_attributes.rs b/src/datadogV2/model/model_aws_cur_config_attributes.rs index c72a11f96..6e5660db7 100644 --- a/src/datadogV2/model/model_aws_cur_config_attributes.rs +++ b/src/datadogV2/model/model_aws_cur_config_attributes.rs @@ -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, diff --git a/src/datadogV2/model/model_azure_uc_config.rs b/src/datadogV2/model/model_azure_uc_config.rs index 4b58e5069..03c2e8050 100644 --- a/src/datadogV2/model/model_azure_uc_config.rs +++ b/src/datadogV2/model/model_azure_uc_config.rs @@ -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, diff --git a/src/datadogV2/model/model_rule_attributes.rs b/src/datadogV2/model/model_rule_attributes.rs index c3d9528ca..fb92e25d1 100644 --- a/src/datadogV2/model/model_rule_attributes.rs +++ b/src/datadogV2/model/model_rule_attributes.rs @@ -213,6 +213,7 @@ impl<'de> Deserialize<'de> for RuleAttributes { } } + #[allow(deprecated)] let content = RuleAttributes { category, created_at, diff --git a/src/datadogV2/model/model_security_monitoring_standard_rule_query.rs b/src/datadogV2/model/model_security_monitoring_standard_rule_query.rs index 4f567c9bf..b12d032d0 100644 --- a/src/datadogV2/model/model_security_monitoring_standard_rule_query.rs +++ b/src/datadogV2/model/model_security_monitoring_standard_rule_query.rs @@ -211,6 +211,7 @@ impl<'de> Deserialize<'de> for SecurityMonitoringStandardRuleQuery { } } + #[allow(deprecated)] let content = SecurityMonitoringStandardRuleQuery { aggregation, distinct_fields, diff --git a/tests/scenarios/fixtures.rs b/tests/scenarios/fixtures.rs index 17abd7322..877a9e94c 100644 --- a/tests/scenarios/fixtures.rs +++ b/tests/scenarios/fixtures.rs @@ -665,10 +665,10 @@ fn relative_time_helper(v: &String, ts: i64) -> DateTime { ) .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()