From 5aef053f76a0e0e2869438f99b4369545fc7d824 Mon Sep 17 00:00:00 2001 From: Fabien Crespel Date: Sat, 21 Dec 2024 20:38:16 +0100 Subject: [PATCH] Fix serialization of time_zone field in CompositeDateHistogramAggregationSource (#1362) * Fix serialization of time_zone field in CompositeDateHistogramAggregationSource Signed-off-by: Fabien Crespel * Add test for CompositeDateHistogramAggregationSource Signed-off-by: Fabien Crespel --------- Signed-off-by: Fabien Crespel --- CHANGELOG.md | 1 + ...mpositeDateHistogramAggregationSource.java | 42 ++++++++++++++----- ...iteDateHistogramAggregationSourceTest.java | 23 ++++++++++ 3 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 java-client/src/test/java/org/opensearch/client/opensearch/_types/aggregations/CompositeDateHistogramAggregationSourceTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 5db3469860..6fe8fc723c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Removed ### Fixed +- Fixed serialization of `time_zone` field in `CompositeDateHistogramAggregationSource` ([#1362](https://github.com/opensearch-project/opensearch-java/pull/1362)) ### Security diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/aggregations/CompositeDateHistogramAggregationSource.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/aggregations/CompositeDateHistogramAggregationSource.java index 34fe20c093..9e67d4f493 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/aggregations/CompositeDateHistogramAggregationSource.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/aggregations/CompositeDateHistogramAggregationSource.java @@ -29,14 +29,15 @@ public class CompositeDateHistogramAggregationSource extends CompositeValuesSour @Nullable private final Long offset; - private final String zoneId; + @Nullable + private final String timeZone; private CompositeDateHistogramAggregationSource(Builder builder) { super(builder); this.calendarInterval = builder.calendarInterval; this.fixedInterval = builder.fixedInterval; this.offset = builder.offset; - this.zoneId = builder.zoneId; + this.timeZone = builder.timeZone; } public static CompositeDateHistogramAggregationSource of(Function> fn) { @@ -65,14 +66,22 @@ public final Time fixedInterval() { @Nullable public final Long offset() { return this.offset; + } + /** + * API name: {@code time_zone} + */ + public final String timeZone() { + return this.timeZone; } /** - * Required - API name: {@code zone_id} + * API name: {@code time_zone} + * @deprecated Use {@link #timeZone()} instead. */ + @Deprecated public final String zoneId() { - return this.zoneId; + return timeZone(); } /** @@ -103,8 +112,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } - generator.writeKey("zone_id"); - generator.write(this.zoneId); + if (this.timeZone != null) { + generator.writeKey("time_zone"); + generator.write(this.timeZone); + } } /** @@ -124,7 +135,8 @@ public static class Builder extends CompositeValuesSource.AbstractBuilder