diff --git a/.apigentools-info b/.apigentools-info index 62c8caddfc6..86f828fc1fb 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-09-30 13:56:52.513837", - "spec_repo_commit": "eb66b1cf" + "regenerated": "2024-09-30 14:37:39.238144", + "spec_repo_commit": "60bc9127" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-09-30 13:56:52.527994", - "spec_repo_commit": "eb66b1cf" + "regenerated": "2024-09-30 14:37:39.252667", + "spec_repo_commit": "60bc9127" } } } \ No newline at end of file diff --git a/.generator/src/generator/templates/model_oneof.j2 b/.generator/src/generator/templates/model_oneof.j2 index 7bed006cdd2..8d923c8f3e1 100644 --- a/.generator/src/generator/templates/model_oneof.j2 +++ b/.generator/src/generator/templates/model_oneof.j2 @@ -63,7 +63,7 @@ func (obj *{{ name }}) UnmarshalJSON(data []byte) error { if err == nil { if obj.{{ attributeName }} != nil {% if oneOf.get("type", "object") == "object" %}&& obj.{{ attributeName }}.UnparsedObject == nil {% endif %}{ json{{ attributeName }}, _ := datadog.Marshal(obj.{{ attributeName }}) - if string(json{{ attributeName }}) == "{}" { // empty struct + if string(json{{ attributeName }}) == "{}"{% if not oneOf|is_primitive and not oneOf.required %} && string(data) != "{}" {% endif %} { // empty struct obj.{{ attributeName }} = nil } else { match++ diff --git a/api/datadogV1/model_distribution_point_item.go b/api/datadogV1/model_distribution_point_item.go index dee25d7f9f5..4a7654c9470 100644 --- a/api/datadogV1/model_distribution_point_item.go +++ b/api/datadogV1/model_distribution_point_item.go @@ -53,7 +53,7 @@ func (obj *DistributionPointItem) UnmarshalJSON(data []byte) error { if err == nil { if obj.DistributionPointData != nil { jsonDistributionPointData, _ := datadog.Marshal(obj.DistributionPointData) - if string(jsonDistributionPointData) == "{}" { // empty struct + if string(jsonDistributionPointData) == "{}" && string(data) != "{}" { // empty struct obj.DistributionPointData = nil } else { match++ diff --git a/api/datadogV1/model_shared_dashboard_invites_data.go b/api/datadogV1/model_shared_dashboard_invites_data.go index caebaafa2c6..13ab72e929d 100644 --- a/api/datadogV1/model_shared_dashboard_invites_data.go +++ b/api/datadogV1/model_shared_dashboard_invites_data.go @@ -53,7 +53,7 @@ func (obj *SharedDashboardInvitesData) UnmarshalJSON(data []byte) error { if err == nil { if obj.SharedDashboardInvitesDataList != nil { jsonSharedDashboardInvitesDataList, _ := datadog.Marshal(obj.SharedDashboardInvitesDataList) - if string(jsonSharedDashboardInvitesDataList) == "{}" { // empty struct + if string(jsonSharedDashboardInvitesDataList) == "{}" && string(data) != "{}" { // empty struct obj.SharedDashboardInvitesDataList = nil } else { match++ diff --git a/api/datadogV1/model_widget_time.go b/api/datadogV1/model_widget_time.go index e4e443178fc..c29b77e3193 100644 --- a/api/datadogV1/model_widget_time.go +++ b/api/datadogV1/model_widget_time.go @@ -42,7 +42,7 @@ func (obj *WidgetTime) UnmarshalJSON(data []byte) error { if err == nil { if obj.WidgetLegacyLiveSpan != nil && obj.WidgetLegacyLiveSpan.UnparsedObject == nil { jsonWidgetLegacyLiveSpan, _ := datadog.Marshal(obj.WidgetLegacyLiveSpan) - if string(jsonWidgetLegacyLiveSpan) == "{}" { // empty struct + if string(jsonWidgetLegacyLiveSpan) == "{}" && string(data) != "{}" { // empty struct obj.WidgetLegacyLiveSpan = nil } else { match++ diff --git a/api/datadogV2/model_api_key_response_included_item.go b/api/datadogV2/model_api_key_response_included_item.go index 43b1165ddee..923fd76da4e 100644 --- a/api/datadogV2/model_api_key_response_included_item.go +++ b/api/datadogV2/model_api_key_response_included_item.go @@ -36,7 +36,7 @@ func (obj *APIKeyResponseIncludedItem) UnmarshalJSON(data []byte) error { if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ diff --git a/api/datadogV2/model_application_key_response_included_item.go b/api/datadogV2/model_application_key_response_included_item.go index 8dfd601eeca..8ea9fa0bf89 100644 --- a/api/datadogV2/model_application_key_response_included_item.go +++ b/api/datadogV2/model_application_key_response_included_item.go @@ -42,7 +42,7 @@ func (obj *ApplicationKeyResponseIncludedItem) UnmarshalJSON(data []byte) error if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ diff --git a/api/datadogV2/model_auth_n_mapping_included.go b/api/datadogV2/model_auth_n_mapping_included.go index 7b43d49de85..05bd7a76875 100644 --- a/api/datadogV2/model_auth_n_mapping_included.go +++ b/api/datadogV2/model_auth_n_mapping_included.go @@ -76,7 +76,7 @@ func (obj *AuthNMappingIncluded) UnmarshalJSON(data []byte) error { if err == nil { if obj.AuthNMappingTeam != nil && obj.AuthNMappingTeam.UnparsedObject == nil { jsonAuthNMappingTeam, _ := datadog.Marshal(obj.AuthNMappingTeam) - if string(jsonAuthNMappingTeam) == "{}" { // empty struct + if string(jsonAuthNMappingTeam) == "{}" && string(data) != "{}" { // empty struct obj.AuthNMappingTeam = nil } else { match++ diff --git a/api/datadogV2/model_ci_app_aggregate_bucket_value.go b/api/datadogV2/model_ci_app_aggregate_bucket_value.go index 918ba4dd3d7..9d564c64009 100644 --- a/api/datadogV2/model_ci_app_aggregate_bucket_value.go +++ b/api/datadogV2/model_ci_app_aggregate_bucket_value.go @@ -76,7 +76,7 @@ func (obj *CIAppAggregateBucketValue) UnmarshalJSON(data []byte) error { if err == nil { if obj.CIAppAggregateBucketValueTimeseries != nil { jsonCIAppAggregateBucketValueTimeseries, _ := datadog.Marshal(obj.CIAppAggregateBucketValueTimeseries) - if string(jsonCIAppAggregateBucketValueTimeseries) == "{}" { // empty struct + if string(jsonCIAppAggregateBucketValueTimeseries) == "{}" && string(data) != "{}" { // empty struct obj.CIAppAggregateBucketValueTimeseries = nil } else { match++ diff --git a/api/datadogV2/model_container_image_item.go b/api/datadogV2/model_container_image_item.go index b05971f55ab..fc802c8edf3 100644 --- a/api/datadogV2/model_container_image_item.go +++ b/api/datadogV2/model_container_image_item.go @@ -36,7 +36,7 @@ func (obj *ContainerImageItem) UnmarshalJSON(data []byte) error { if err == nil { if obj.ContainerImage != nil && obj.ContainerImage.UnparsedObject == nil { jsonContainerImage, _ := datadog.Marshal(obj.ContainerImage) - if string(jsonContainerImage) == "{}" { // empty struct + if string(jsonContainerImage) == "{}" && string(data) != "{}" { // empty struct obj.ContainerImage = nil } else { match++ @@ -53,7 +53,7 @@ func (obj *ContainerImageItem) UnmarshalJSON(data []byte) error { if err == nil { if obj.ContainerImageGroup != nil && obj.ContainerImageGroup.UnparsedObject == nil { jsonContainerImageGroup, _ := datadog.Marshal(obj.ContainerImageGroup) - if string(jsonContainerImageGroup) == "{}" { // empty struct + if string(jsonContainerImageGroup) == "{}" && string(data) != "{}" { // empty struct obj.ContainerImageGroup = nil } else { match++ diff --git a/api/datadogV2/model_container_item.go b/api/datadogV2/model_container_item.go index 403313cc3e1..ab5c72bafe0 100644 --- a/api/datadogV2/model_container_item.go +++ b/api/datadogV2/model_container_item.go @@ -36,7 +36,7 @@ func (obj *ContainerItem) UnmarshalJSON(data []byte) error { if err == nil { if obj.Container != nil && obj.Container.UnparsedObject == nil { jsonContainer, _ := datadog.Marshal(obj.Container) - if string(jsonContainer) == "{}" { // empty struct + if string(jsonContainer) == "{}" && string(data) != "{}" { // empty struct obj.Container = nil } else { match++ @@ -53,7 +53,7 @@ func (obj *ContainerItem) UnmarshalJSON(data []byte) error { if err == nil { if obj.ContainerGroup != nil && obj.ContainerGroup.UnparsedObject == nil { jsonContainerGroup, _ := datadog.Marshal(obj.ContainerGroup) - if string(jsonContainerGroup) == "{}" { // empty struct + if string(jsonContainerGroup) == "{}" && string(data) != "{}" { // empty struct obj.ContainerGroup = nil } else { match++ diff --git a/api/datadogV2/model_downtime_response_included_item.go b/api/datadogV2/model_downtime_response_included_item.go index 62e1f230818..c53b343293a 100644 --- a/api/datadogV2/model_downtime_response_included_item.go +++ b/api/datadogV2/model_downtime_response_included_item.go @@ -36,7 +36,7 @@ func (obj *DowntimeResponseIncludedItem) UnmarshalJSON(data []byte) error { if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ @@ -53,7 +53,7 @@ func (obj *DowntimeResponseIncludedItem) UnmarshalJSON(data []byte) error { if err == nil { if obj.DowntimeMonitorIncludedItem != nil && obj.DowntimeMonitorIncludedItem.UnparsedObject == nil { jsonDowntimeMonitorIncludedItem, _ := datadog.Marshal(obj.DowntimeMonitorIncludedItem) - if string(jsonDowntimeMonitorIncludedItem) == "{}" { // empty struct + if string(jsonDowntimeMonitorIncludedItem) == "{}" && string(data) != "{}" { // empty struct obj.DowntimeMonitorIncludedItem = nil } else { match++ diff --git a/api/datadogV2/model_downtime_schedule_create_request.go b/api/datadogV2/model_downtime_schedule_create_request.go index b4b128c0bc5..2cb9ac7d400 100644 --- a/api/datadogV2/model_downtime_schedule_create_request.go +++ b/api/datadogV2/model_downtime_schedule_create_request.go @@ -53,7 +53,7 @@ func (obj *DowntimeScheduleCreateRequest) UnmarshalJSON(data []byte) error { if err == nil { if obj.DowntimeScheduleOneTimeCreateUpdateRequest != nil && obj.DowntimeScheduleOneTimeCreateUpdateRequest.UnparsedObject == nil { jsonDowntimeScheduleOneTimeCreateUpdateRequest, _ := datadog.Marshal(obj.DowntimeScheduleOneTimeCreateUpdateRequest) - if string(jsonDowntimeScheduleOneTimeCreateUpdateRequest) == "{}" { // empty struct + if string(jsonDowntimeScheduleOneTimeCreateUpdateRequest) == "{}" && string(data) != "{}" { // empty struct obj.DowntimeScheduleOneTimeCreateUpdateRequest = nil } else { match++ diff --git a/api/datadogV2/model_downtime_schedule_update_request.go b/api/datadogV2/model_downtime_schedule_update_request.go index e0dca76f538..647bf51fda7 100644 --- a/api/datadogV2/model_downtime_schedule_update_request.go +++ b/api/datadogV2/model_downtime_schedule_update_request.go @@ -36,7 +36,7 @@ func (obj *DowntimeScheduleUpdateRequest) UnmarshalJSON(data []byte) error { if err == nil { if obj.DowntimeScheduleRecurrencesUpdateRequest != nil && obj.DowntimeScheduleRecurrencesUpdateRequest.UnparsedObject == nil { jsonDowntimeScheduleRecurrencesUpdateRequest, _ := datadog.Marshal(obj.DowntimeScheduleRecurrencesUpdateRequest) - if string(jsonDowntimeScheduleRecurrencesUpdateRequest) == "{}" { // empty struct + if string(jsonDowntimeScheduleRecurrencesUpdateRequest) == "{}" && string(data) != "{}" { // empty struct obj.DowntimeScheduleRecurrencesUpdateRequest = nil } else { match++ @@ -53,7 +53,7 @@ func (obj *DowntimeScheduleUpdateRequest) UnmarshalJSON(data []byte) error { if err == nil { if obj.DowntimeScheduleOneTimeCreateUpdateRequest != nil && obj.DowntimeScheduleOneTimeCreateUpdateRequest.UnparsedObject == nil { jsonDowntimeScheduleOneTimeCreateUpdateRequest, _ := datadog.Marshal(obj.DowntimeScheduleOneTimeCreateUpdateRequest) - if string(jsonDowntimeScheduleOneTimeCreateUpdateRequest) == "{}" { // empty struct + if string(jsonDowntimeScheduleOneTimeCreateUpdateRequest) == "{}" && string(data) != "{}" { // empty struct obj.DowntimeScheduleOneTimeCreateUpdateRequest = nil } else { match++ diff --git a/api/datadogV2/model_incident_attachments_response_included_item.go b/api/datadogV2/model_incident_attachments_response_included_item.go index 0f4e057ac3c..d8d6d5247b4 100644 --- a/api/datadogV2/model_incident_attachments_response_included_item.go +++ b/api/datadogV2/model_incident_attachments_response_included_item.go @@ -30,7 +30,7 @@ func (obj *IncidentAttachmentsResponseIncludedItem) UnmarshalJSON(data []byte) e if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ diff --git a/api/datadogV2/model_incident_field_attributes.go b/api/datadogV2/model_incident_field_attributes.go index 73c77583907..cbac5d53489 100644 --- a/api/datadogV2/model_incident_field_attributes.go +++ b/api/datadogV2/model_incident_field_attributes.go @@ -36,7 +36,7 @@ func (obj *IncidentFieldAttributes) UnmarshalJSON(data []byte) error { if err == nil { if obj.IncidentFieldAttributesSingleValue != nil && obj.IncidentFieldAttributesSingleValue.UnparsedObject == nil { jsonIncidentFieldAttributesSingleValue, _ := datadog.Marshal(obj.IncidentFieldAttributesSingleValue) - if string(jsonIncidentFieldAttributesSingleValue) == "{}" { // empty struct + if string(jsonIncidentFieldAttributesSingleValue) == "{}" && string(data) != "{}" { // empty struct obj.IncidentFieldAttributesSingleValue = nil } else { match++ @@ -53,7 +53,7 @@ func (obj *IncidentFieldAttributes) UnmarshalJSON(data []byte) error { if err == nil { if obj.IncidentFieldAttributesMultipleValue != nil && obj.IncidentFieldAttributesMultipleValue.UnparsedObject == nil { jsonIncidentFieldAttributesMultipleValue, _ := datadog.Marshal(obj.IncidentFieldAttributesMultipleValue) - if string(jsonIncidentFieldAttributesMultipleValue) == "{}" { // empty struct + if string(jsonIncidentFieldAttributesMultipleValue) == "{}" && string(data) != "{}" { // empty struct obj.IncidentFieldAttributesMultipleValue = nil } else { match++ diff --git a/api/datadogV2/model_incident_integration_metadata_response_included_item.go b/api/datadogV2/model_incident_integration_metadata_response_included_item.go index 88bd107b905..d61741040e1 100644 --- a/api/datadogV2/model_incident_integration_metadata_response_included_item.go +++ b/api/datadogV2/model_incident_integration_metadata_response_included_item.go @@ -30,7 +30,7 @@ func (obj *IncidentIntegrationMetadataResponseIncludedItem) UnmarshalJSON(data [ if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ diff --git a/api/datadogV2/model_incident_response_included_item.go b/api/datadogV2/model_incident_response_included_item.go index 0e0adce19ad..c7d00d179de 100644 --- a/api/datadogV2/model_incident_response_included_item.go +++ b/api/datadogV2/model_incident_response_included_item.go @@ -36,7 +36,7 @@ func (obj *IncidentResponseIncludedItem) UnmarshalJSON(data []byte) error { if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ diff --git a/api/datadogV2/model_incident_service_included_items.go b/api/datadogV2/model_incident_service_included_items.go index 7876c280a67..7812992ea50 100644 --- a/api/datadogV2/model_incident_service_included_items.go +++ b/api/datadogV2/model_incident_service_included_items.go @@ -30,7 +30,7 @@ func (obj *IncidentServiceIncludedItems) UnmarshalJSON(data []byte) error { if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ diff --git a/api/datadogV2/model_incident_team_included_items.go b/api/datadogV2/model_incident_team_included_items.go index d466427ee51..03640d03550 100644 --- a/api/datadogV2/model_incident_team_included_items.go +++ b/api/datadogV2/model_incident_team_included_items.go @@ -30,7 +30,7 @@ func (obj *IncidentTeamIncludedItems) UnmarshalJSON(data []byte) error { if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ diff --git a/api/datadogV2/model_incident_todo_response_included_item.go b/api/datadogV2/model_incident_todo_response_included_item.go index b045eeb2101..b896548a039 100644 --- a/api/datadogV2/model_incident_todo_response_included_item.go +++ b/api/datadogV2/model_incident_todo_response_included_item.go @@ -30,7 +30,7 @@ func (obj *IncidentTodoResponseIncludedItem) UnmarshalJSON(data []byte) error { if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ diff --git a/api/datadogV2/model_list_entity_catalog_response_included_item.go b/api/datadogV2/model_list_entity_catalog_response_included_item.go index 1e2537c7ee1..6bbd8b6b3c9 100644 --- a/api/datadogV2/model_list_entity_catalog_response_included_item.go +++ b/api/datadogV2/model_list_entity_catalog_response_included_item.go @@ -54,7 +54,7 @@ func (obj *ListEntityCatalogResponseIncludedItem) UnmarshalJSON(data []byte) err if err == nil { if obj.EntityResponseIncludedSchema != nil && obj.EntityResponseIncludedSchema.UnparsedObject == nil { jsonEntityResponseIncludedSchema, _ := datadog.Marshal(obj.EntityResponseIncludedSchema) - if string(jsonEntityResponseIncludedSchema) == "{}" { // empty struct + if string(jsonEntityResponseIncludedSchema) == "{}" && string(data) != "{}" { // empty struct obj.EntityResponseIncludedSchema = nil } else { match++ @@ -71,7 +71,7 @@ func (obj *ListEntityCatalogResponseIncludedItem) UnmarshalJSON(data []byte) err if err == nil { if obj.EntityResponseIncludedRawSchema != nil && obj.EntityResponseIncludedRawSchema.UnparsedObject == nil { jsonEntityResponseIncludedRawSchema, _ := datadog.Marshal(obj.EntityResponseIncludedRawSchema) - if string(jsonEntityResponseIncludedRawSchema) == "{}" { // empty struct + if string(jsonEntityResponseIncludedRawSchema) == "{}" && string(data) != "{}" { // empty struct obj.EntityResponseIncludedRawSchema = nil } else { match++ @@ -88,7 +88,7 @@ func (obj *ListEntityCatalogResponseIncludedItem) UnmarshalJSON(data []byte) err if err == nil { if obj.EntityResponseIncludedRelatedEntity != nil && obj.EntityResponseIncludedRelatedEntity.UnparsedObject == nil { jsonEntityResponseIncludedRelatedEntity, _ := datadog.Marshal(obj.EntityResponseIncludedRelatedEntity) - if string(jsonEntityResponseIncludedRelatedEntity) == "{}" { // empty struct + if string(jsonEntityResponseIncludedRelatedEntity) == "{}" && string(data) != "{}" { // empty struct obj.EntityResponseIncludedRelatedEntity = nil } else { match++ @@ -105,7 +105,7 @@ func (obj *ListEntityCatalogResponseIncludedItem) UnmarshalJSON(data []byte) err if err == nil { if obj.EntityResponseIncludedOncall != nil && obj.EntityResponseIncludedOncall.UnparsedObject == nil { jsonEntityResponseIncludedOncall, _ := datadog.Marshal(obj.EntityResponseIncludedOncall) - if string(jsonEntityResponseIncludedOncall) == "{}" { // empty struct + if string(jsonEntityResponseIncludedOncall) == "{}" && string(data) != "{}" { // empty struct obj.EntityResponseIncludedOncall = nil } else { match++ @@ -122,7 +122,7 @@ func (obj *ListEntityCatalogResponseIncludedItem) UnmarshalJSON(data []byte) err if err == nil { if obj.EntityResponseIncludedIncident != nil && obj.EntityResponseIncludedIncident.UnparsedObject == nil { jsonEntityResponseIncludedIncident, _ := datadog.Marshal(obj.EntityResponseIncludedIncident) - if string(jsonEntityResponseIncludedIncident) == "{}" { // empty struct + if string(jsonEntityResponseIncludedIncident) == "{}" && string(data) != "{}" { // empty struct obj.EntityResponseIncludedIncident = nil } else { match++ diff --git a/api/datadogV2/model_logs_aggregate_bucket_value.go b/api/datadogV2/model_logs_aggregate_bucket_value.go index a444ddf0f89..f259599c122 100644 --- a/api/datadogV2/model_logs_aggregate_bucket_value.go +++ b/api/datadogV2/model_logs_aggregate_bucket_value.go @@ -76,7 +76,7 @@ func (obj *LogsAggregateBucketValue) UnmarshalJSON(data []byte) error { if err == nil { if obj.LogsAggregateBucketValueTimeseries != nil { jsonLogsAggregateBucketValueTimeseries, _ := datadog.Marshal(obj.LogsAggregateBucketValueTimeseries) - if string(jsonLogsAggregateBucketValueTimeseries) == "{}" { // empty struct + if string(jsonLogsAggregateBucketValueTimeseries) == "{}" && string(data) != "{}" { // empty struct obj.LogsAggregateBucketValueTimeseries = nil } else { match++ diff --git a/api/datadogV2/model_metric_volumes.go b/api/datadogV2/model_metric_volumes.go index 6ae23da3873..5ffeedca6b0 100644 --- a/api/datadogV2/model_metric_volumes.go +++ b/api/datadogV2/model_metric_volumes.go @@ -36,7 +36,7 @@ func (obj *MetricVolumes) UnmarshalJSON(data []byte) error { if err == nil { if obj.MetricDistinctVolume != nil && obj.MetricDistinctVolume.UnparsedObject == nil { jsonMetricDistinctVolume, _ := datadog.Marshal(obj.MetricDistinctVolume) - if string(jsonMetricDistinctVolume) == "{}" { // empty struct + if string(jsonMetricDistinctVolume) == "{}" && string(data) != "{}" { // empty struct obj.MetricDistinctVolume = nil } else { match++ @@ -53,7 +53,7 @@ func (obj *MetricVolumes) UnmarshalJSON(data []byte) error { if err == nil { if obj.MetricIngestedIndexedVolume != nil && obj.MetricIngestedIndexedVolume.UnparsedObject == nil { jsonMetricIngestedIndexedVolume, _ := datadog.Marshal(obj.MetricIngestedIndexedVolume) - if string(jsonMetricIngestedIndexedVolume) == "{}" { // empty struct + if string(jsonMetricIngestedIndexedVolume) == "{}" && string(data) != "{}" { // empty struct obj.MetricIngestedIndexedVolume = nil } else { match++ diff --git a/api/datadogV2/model_metrics_and_metric_tag_configurations.go b/api/datadogV2/model_metrics_and_metric_tag_configurations.go index 1d580b584ae..263a598ac32 100644 --- a/api/datadogV2/model_metrics_and_metric_tag_configurations.go +++ b/api/datadogV2/model_metrics_and_metric_tag_configurations.go @@ -36,7 +36,7 @@ func (obj *MetricsAndMetricTagConfigurations) UnmarshalJSON(data []byte) error { if err == nil { if obj.Metric != nil && obj.Metric.UnparsedObject == nil { jsonMetric, _ := datadog.Marshal(obj.Metric) - if string(jsonMetric) == "{}" { // empty struct + if string(jsonMetric) == "{}" && string(data) != "{}" { // empty struct obj.Metric = nil } else { match++ @@ -53,7 +53,7 @@ func (obj *MetricsAndMetricTagConfigurations) UnmarshalJSON(data []byte) error { if err == nil { if obj.MetricTagConfiguration != nil && obj.MetricTagConfiguration.UnparsedObject == nil { jsonMetricTagConfiguration, _ := datadog.Marshal(obj.MetricTagConfiguration) - if string(jsonMetricTagConfiguration) == "{}" { // empty struct + if string(jsonMetricTagConfiguration) == "{}" && string(data) != "{}" { // empty struct obj.MetricTagConfiguration = nil } else { match++ diff --git a/api/datadogV2/model_monitor_config_policy_policy.go b/api/datadogV2/model_monitor_config_policy_policy.go index 781318d9795..9a0b74e7175 100644 --- a/api/datadogV2/model_monitor_config_policy_policy.go +++ b/api/datadogV2/model_monitor_config_policy_policy.go @@ -30,7 +30,7 @@ func (obj *MonitorConfigPolicyPolicy) UnmarshalJSON(data []byte) error { if err == nil { if obj.MonitorConfigPolicyTagPolicy != nil && obj.MonitorConfigPolicyTagPolicy.UnparsedObject == nil { jsonMonitorConfigPolicyTagPolicy, _ := datadog.Marshal(obj.MonitorConfigPolicyTagPolicy) - if string(jsonMonitorConfigPolicyTagPolicy) == "{}" { // empty struct + if string(jsonMonitorConfigPolicyTagPolicy) == "{}" && string(data) != "{}" { // empty struct obj.MonitorConfigPolicyTagPolicy = nil } else { match++ diff --git a/api/datadogV2/model_rum_aggregate_bucket_value.go b/api/datadogV2/model_rum_aggregate_bucket_value.go index 484cfc520c2..0cfea0fd43b 100644 --- a/api/datadogV2/model_rum_aggregate_bucket_value.go +++ b/api/datadogV2/model_rum_aggregate_bucket_value.go @@ -76,7 +76,7 @@ func (obj *RUMAggregateBucketValue) UnmarshalJSON(data []byte) error { if err == nil { if obj.RUMAggregateBucketValueTimeseries != nil { jsonRUMAggregateBucketValueTimeseries, _ := datadog.Marshal(obj.RUMAggregateBucketValueTimeseries) - if string(jsonRUMAggregateBucketValueTimeseries) == "{}" { // empty struct + if string(jsonRUMAggregateBucketValueTimeseries) == "{}" && string(data) != "{}" { // empty struct obj.RUMAggregateBucketValueTimeseries = nil } else { match++ diff --git a/api/datadogV2/model_scalar_column.go b/api/datadogV2/model_scalar_column.go index cfa8d6adbe7..6ae169a7e6b 100644 --- a/api/datadogV2/model_scalar_column.go +++ b/api/datadogV2/model_scalar_column.go @@ -36,7 +36,7 @@ func (obj *ScalarColumn) UnmarshalJSON(data []byte) error { if err == nil { if obj.GroupScalarColumn != nil && obj.GroupScalarColumn.UnparsedObject == nil { jsonGroupScalarColumn, _ := datadog.Marshal(obj.GroupScalarColumn) - if string(jsonGroupScalarColumn) == "{}" { // empty struct + if string(jsonGroupScalarColumn) == "{}" && string(data) != "{}" { // empty struct obj.GroupScalarColumn = nil } else { match++ @@ -53,7 +53,7 @@ func (obj *ScalarColumn) UnmarshalJSON(data []byte) error { if err == nil { if obj.DataScalarColumn != nil && obj.DataScalarColumn.UnparsedObject == nil { jsonDataScalarColumn, _ := datadog.Marshal(obj.DataScalarColumn) - if string(jsonDataScalarColumn) == "{}" { // empty struct + if string(jsonDataScalarColumn) == "{}" && string(data) != "{}" { // empty struct obj.DataScalarColumn = nil } else { match++ diff --git a/api/datadogV2/model_security_monitoring_rule_query.go b/api/datadogV2/model_security_monitoring_rule_query.go index 73cddf6d6e8..e95571f0f74 100644 --- a/api/datadogV2/model_security_monitoring_rule_query.go +++ b/api/datadogV2/model_security_monitoring_rule_query.go @@ -36,7 +36,7 @@ func (obj *SecurityMonitoringRuleQuery) UnmarshalJSON(data []byte) error { if err == nil { if obj.SecurityMonitoringStandardRuleQuery != nil && obj.SecurityMonitoringStandardRuleQuery.UnparsedObject == nil { jsonSecurityMonitoringStandardRuleQuery, _ := datadog.Marshal(obj.SecurityMonitoringStandardRuleQuery) - if string(jsonSecurityMonitoringStandardRuleQuery) == "{}" { // empty struct + if string(jsonSecurityMonitoringStandardRuleQuery) == "{}" && string(data) != "{}" { // empty struct obj.SecurityMonitoringStandardRuleQuery = nil } else { match++ diff --git a/api/datadogV2/model_security_monitoring_rule_response.go b/api/datadogV2/model_security_monitoring_rule_response.go index 27a9fdffcb3..bc364e67bf5 100644 --- a/api/datadogV2/model_security_monitoring_rule_response.go +++ b/api/datadogV2/model_security_monitoring_rule_response.go @@ -36,7 +36,7 @@ func (obj *SecurityMonitoringRuleResponse) UnmarshalJSON(data []byte) error { if err == nil { if obj.SecurityMonitoringStandardRuleResponse != nil && obj.SecurityMonitoringStandardRuleResponse.UnparsedObject == nil { jsonSecurityMonitoringStandardRuleResponse, _ := datadog.Marshal(obj.SecurityMonitoringStandardRuleResponse) - if string(jsonSecurityMonitoringStandardRuleResponse) == "{}" { // empty struct + if string(jsonSecurityMonitoringStandardRuleResponse) == "{}" && string(data) != "{}" { // empty struct obj.SecurityMonitoringStandardRuleResponse = nil } else { match++ @@ -53,7 +53,7 @@ func (obj *SecurityMonitoringRuleResponse) UnmarshalJSON(data []byte) error { if err == nil { if obj.SecurityMonitoringSignalRuleResponse != nil && obj.SecurityMonitoringSignalRuleResponse.UnparsedObject == nil { jsonSecurityMonitoringSignalRuleResponse, _ := datadog.Marshal(obj.SecurityMonitoringSignalRuleResponse) - if string(jsonSecurityMonitoringSignalRuleResponse) == "{}" { // empty struct + if string(jsonSecurityMonitoringSignalRuleResponse) == "{}" && string(data) != "{}" { // empty struct obj.SecurityMonitoringSignalRuleResponse = nil } else { match++ diff --git a/api/datadogV2/model_sensitive_data_scanner_get_config_included_item.go b/api/datadogV2/model_sensitive_data_scanner_get_config_included_item.go index 9a5d3400d29..9a2be2812d9 100644 --- a/api/datadogV2/model_sensitive_data_scanner_get_config_included_item.go +++ b/api/datadogV2/model_sensitive_data_scanner_get_config_included_item.go @@ -36,7 +36,7 @@ func (obj *SensitiveDataScannerGetConfigIncludedItem) UnmarshalJSON(data []byte) if err == nil { if obj.SensitiveDataScannerRuleIncludedItem != nil && obj.SensitiveDataScannerRuleIncludedItem.UnparsedObject == nil { jsonSensitiveDataScannerRuleIncludedItem, _ := datadog.Marshal(obj.SensitiveDataScannerRuleIncludedItem) - if string(jsonSensitiveDataScannerRuleIncludedItem) == "{}" { // empty struct + if string(jsonSensitiveDataScannerRuleIncludedItem) == "{}" && string(data) != "{}" { // empty struct obj.SensitiveDataScannerRuleIncludedItem = nil } else { match++ @@ -53,7 +53,7 @@ func (obj *SensitiveDataScannerGetConfigIncludedItem) UnmarshalJSON(data []byte) if err == nil { if obj.SensitiveDataScannerGroupIncludedItem != nil && obj.SensitiveDataScannerGroupIncludedItem.UnparsedObject == nil { jsonSensitiveDataScannerGroupIncludedItem, _ := datadog.Marshal(obj.SensitiveDataScannerGroupIncludedItem) - if string(jsonSensitiveDataScannerGroupIncludedItem) == "{}" { // empty struct + if string(jsonSensitiveDataScannerGroupIncludedItem) == "{}" && string(data) != "{}" { // empty struct obj.SensitiveDataScannerGroupIncludedItem = nil } else { match++ diff --git a/api/datadogV2/model_spans_aggregate_bucket_value.go b/api/datadogV2/model_spans_aggregate_bucket_value.go index a5376432ab1..e9d83d3afbd 100644 --- a/api/datadogV2/model_spans_aggregate_bucket_value.go +++ b/api/datadogV2/model_spans_aggregate_bucket_value.go @@ -76,7 +76,7 @@ func (obj *SpansAggregateBucketValue) UnmarshalJSON(data []byte) error { if err == nil { if obj.SpansAggregateBucketValueTimeseries != nil { jsonSpansAggregateBucketValueTimeseries, _ := datadog.Marshal(obj.SpansAggregateBucketValueTimeseries) - if string(jsonSpansAggregateBucketValueTimeseries) == "{}" { // empty struct + if string(jsonSpansAggregateBucketValueTimeseries) == "{}" && string(data) != "{}" { // empty struct obj.SpansAggregateBucketValueTimeseries = nil } else { match++ diff --git a/api/datadogV2/model_team_included.go b/api/datadogV2/model_team_included.go index 70890f80d90..edc07e260f1 100644 --- a/api/datadogV2/model_team_included.go +++ b/api/datadogV2/model_team_included.go @@ -42,7 +42,7 @@ func (obj *TeamIncluded) UnmarshalJSON(data []byte) error { if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ diff --git a/api/datadogV2/model_upsert_catalog_entity_request.go b/api/datadogV2/model_upsert_catalog_entity_request.go index 23928a45b9e..222394bfa72 100644 --- a/api/datadogV2/model_upsert_catalog_entity_request.go +++ b/api/datadogV2/model_upsert_catalog_entity_request.go @@ -36,7 +36,7 @@ func (obj *UpsertCatalogEntityRequest) UnmarshalJSON(data []byte) error { if err == nil { if obj.EntityV3 != nil && obj.EntityV3.UnparsedObject == nil { jsonEntityV3, _ := datadog.Marshal(obj.EntityV3) - if string(jsonEntityV3) == "{}" { // empty struct + if string(jsonEntityV3) == "{}" && string(data) != "{}" { // empty struct obj.EntityV3 = nil } else { match++ diff --git a/api/datadogV2/model_upsert_catalog_entity_response_included_item.go b/api/datadogV2/model_upsert_catalog_entity_response_included_item.go index a4760f84d32..9dd3dc10494 100644 --- a/api/datadogV2/model_upsert_catalog_entity_response_included_item.go +++ b/api/datadogV2/model_upsert_catalog_entity_response_included_item.go @@ -30,7 +30,7 @@ func (obj *UpsertCatalogEntityResponseIncludedItem) UnmarshalJSON(data []byte) e if err == nil { if obj.EntityResponseIncludedSchema != nil && obj.EntityResponseIncludedSchema.UnparsedObject == nil { jsonEntityResponseIncludedSchema, _ := datadog.Marshal(obj.EntityResponseIncludedSchema) - if string(jsonEntityResponseIncludedSchema) == "{}" { // empty struct + if string(jsonEntityResponseIncludedSchema) == "{}" && string(data) != "{}" { // empty struct obj.EntityResponseIncludedSchema = nil } else { match++ diff --git a/api/datadogV2/model_user_team_included.go b/api/datadogV2/model_user_team_included.go index f66c29ae3c1..393a20c398c 100644 --- a/api/datadogV2/model_user_team_included.go +++ b/api/datadogV2/model_user_team_included.go @@ -36,7 +36,7 @@ func (obj *UserTeamIncluded) UnmarshalJSON(data []byte) error { if err == nil { if obj.User != nil && obj.User.UnparsedObject == nil { jsonUser, _ := datadog.Marshal(obj.User) - if string(jsonUser) == "{}" { // empty struct + if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct obj.User = nil } else { match++ diff --git a/examples/v1/dashboards/CreateDashboard_1433408735.go b/examples/v1/dashboards/CreateDashboard_1433408735.go new file mode 100644 index 00000000000..c98d24912a2 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_1433408735.go @@ -0,0 +1,70 @@ +// Clients deserialize a dashboard with a empty time object + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" +) + +func main() { + body := datadogV1.Dashboard{ + Title: "Example-Dashboard", + Widgets: []datadogV1.Widget{ + { + Definition: datadogV1.WidgetDefinition{ + TimeseriesWidgetDefinition: &datadogV1.TimeseriesWidgetDefinition{ + Title: datadog.PtrString("Example Cloud Cost Query"), + TitleSize: datadog.PtrString("16"), + TitleAlign: datadogV1.WIDGETTEXTALIGN_LEFT.Ptr(), + Type: datadogV1.TIMESERIESWIDGETDEFINITIONTYPE_TIMESERIES, + Requests: []datadogV1.TimeseriesWidgetRequest{ + { + Formulas: []datadogV1.WidgetFormula{ + { + Formula: "query1", + }, + }, + Queries: []datadogV1.FormulaAndFunctionQueryDefinition{ + datadogV1.FormulaAndFunctionQueryDefinition{ + FormulaAndFunctionCloudCostQueryDefinition: &datadogV1.FormulaAndFunctionCloudCostQueryDefinition{ + DataSource: datadogV1.FORMULAANDFUNCTIONCLOUDCOSTDATASOURCE_CLOUD_COST, + Name: "query1", + Query: "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)", + }}, + }, + ResponseFormat: datadogV1.FORMULAANDFUNCTIONRESPONSEFORMAT_TIMESERIES.Ptr(), + Style: &datadogV1.WidgetRequestStyle{ + Palette: datadog.PtrString("dog_classic"), + LineType: datadogV1.WIDGETLINETYPE_SOLID.Ptr(), + LineWidth: datadogV1.WIDGETLINEWIDTH_NORMAL.Ptr(), + }, + DisplayType: datadogV1.WIDGETDISPLAYTYPE_BARS.Ptr(), + }, + }, + Time: &datadogV1.WidgetTime{ + WidgetLegacyLiveSpan: &datadogV1.WidgetLegacyLiveSpan{}}, + }}, + }, + }, + LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV1.NewDashboardsApi(apiClient) + resp, r, err := api.CreateDashboard(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Clients_deserialize_a_dashboard_with_a_empty_time_object.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Clients_deserialize_a_dashboard_with_a_empty_time_object.freeze new file mode 100644 index 00000000000..85e15158c6a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Clients_deserialize_a_dashboard_with_a_empty_time_object.freeze @@ -0,0 +1 @@ +2024-09-24T19:19:31.807Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Clients_deserialize_a_dashboard_with_a_empty_time_object.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Clients_deserialize_a_dashboard_with_a_empty_time_object.yaml new file mode 100644 index 00000000000..1875547055a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Clients_deserialize_a_dashboard_with_a_empty_time_object.yaml @@ -0,0 +1,45 @@ +interactions: +- request: + body: | + {"layout_type":"ordered","title":"Test-Clients_deserialize_a_dashboard_with_a_empty_time_object-1727205571","widgets":[{"definition":{"requests":[{"display_type":"bars","formulas":[{"formula":"query1"}],"queries":[{"data_source":"cloud_cost","name":"query1","query":"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)"}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"time":{},"title":"Example Cloud Cost Query","title_align":"left","title_size":"16","type":"timeseries"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"id":"han-5zg-c32","title":"Test-Clients_deserialize_a_dashboard_with_a_empty_time_object-1727205571","description":null,"author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/han-5zg-c32/test-clientsdeserializeadashboardwithaemptytimeobject-1727205571","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"display_type":"bars","formulas":[{"formula":"query1"}],"queries":[{"data_source":"cloud_cost","name":"query1","query":"sum:aws.cost.amortized{*} + by {aws_product}.rollup(sum, monthly)"}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"time":{},"title":"Example + Cloud Cost Query","title_align":"left","title_size":"16","type":"timeseries"},"id":4274057372149908}],"notify_list":null,"created_at":"2024-09-24T19:19:32.071328+00:00","modified_at":"2024-09-24T19:19:32.071328+00:00","experience_type":"default","restricted_roles":[]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v1/dashboard/han-5zg-c32 + response: + body: '{"deleted_dashboard_id":"han-5zg-c32"} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v1/dashboards.feature b/tests/scenarios/features/v1/dashboards.feature index 33eaed7f4cc..de855fec2dd 100644 --- a/tests/scenarios/features/v1/dashboards.feature +++ b/tests/scenarios/features/v1/dashboards.feature @@ -9,6 +9,14 @@ Feature: Dashboards And a valid "appKeyAuth" key in the system And an instance of "Dashboards" API + @replay-only @team:DataDog/dashboards-backend + Scenario: Clients deserialize a dashboard with a empty time object + Given new "CreateDashboard" request + And body with value { "title": "{{ unique }}", "widgets": [ { "definition": { "title": "Example Cloud Cost Query", "title_size": "16", "title_align": "left", "type": "timeseries", "requests": [ { "formulas": [ { "formula": "query1" } ], "queries": [ { "data_source": "cloud_cost", "name": "query1", "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)" } ], "response_format": "timeseries", "style": { "palette": "dog_classic", "line_type": "solid", "line_width": "normal" }, "display_type": "bars" } ], "time": {} } } ], "layout_type": "ordered" } + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.time" is equal to {} + @team:DataDog/dashboards-backend Scenario: Create a distribution widget using a histogram request containing a formulas and functions APM Stats query Given new "CreateDashboard" request