diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ece8b4d62..6e646073ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Removed ### Fixed +- Remove required check on ShardStats.shards ([#XXX](https://github.com/opensearch-project/opensearch-java/pull/XXX)) ### Security diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java index 9cc34fa4d5..84506caa74 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java @@ -33,34 +33,15 @@ package org.opensearch.client.opensearch.indices.stats; import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.opensearch._types.BulkStats; -import org.opensearch.client.opensearch._types.CompletionStats; -import org.opensearch.client.opensearch._types.DocStats; -import org.opensearch.client.opensearch._types.FielddataStats; -import org.opensearch.client.opensearch._types.FlushStats; -import org.opensearch.client.opensearch._types.GetStats; -import org.opensearch.client.opensearch._types.IndexingStats; -import org.opensearch.client.opensearch._types.MergesStats; -import org.opensearch.client.opensearch._types.RecoveryStats; -import org.opensearch.client.opensearch._types.RefreshStats; -import org.opensearch.client.opensearch._types.RequestCacheStats; -import org.opensearch.client.opensearch._types.SearchStats; -import org.opensearch.client.opensearch._types.SegmentsStats; -import org.opensearch.client.opensearch._types.StoreStats; -import org.opensearch.client.opensearch._types.TranslogStats; -import org.opensearch.client.opensearch._types.WarmerStats; +import org.opensearch.client.json.*; +import org.opensearch.client.opensearch._types.*; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import javax.annotation.Nullable; +import java.util.function.Function; + // typedef: indices.stats.ShardStats @JsonpDeserializable @@ -110,6 +91,7 @@ public class ShardStats implements PlainJsonSerializable { @Nullable private final BulkStats bulk; + @Nullable private final ShardsTotalStats shards; // --------------------------------------------------------------------------------------------- @@ -302,8 +284,9 @@ public final BulkStats bulk() { } /** - * Required - API name: {@code shards} + * API name: {@code shards} */ + @Nullable public final ShardsTotalStats shards() { return this.shards; } @@ -387,9 +370,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.bulk.serialize(generator, mapper); } - generator.writeKey("shards"); - this.shards.serialize(generator, mapper); - + if (this.shards != null) { + generator.writeKey("shards"); + this.shards.serialize(generator, mapper); + } } // --------------------------------------------------------------------------------------------- @@ -444,6 +428,7 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder> } /** - * Required - API name: {@code shards} + * API name: {@code shards} */ public final Builder shards(ShardsTotalStats value) { this.shards = value; @@ -785,7 +770,7 @@ public final Builder shards(ShardsTotalStats value) { } /** - * Required - API name: {@code shards} + * API name: {@code shards} */ public final Builder shards(Function> fn) { return this.shards(fn.apply(new ShardsTotalStats.Builder()).build());