From 131c604190e01a364f7acb4bd2efd204f20947f0 Mon Sep 17 00:00:00 2001 From: Laura Trotta <153528055+l-trotta@users.noreply.github.com> Date: Fri, 31 May 2024 16:39:36 +0200 Subject: [PATCH] FIxes from spec 2597 (#825) --- .../_types/aggregations/Aggregate.java | 26 +++++++++--------- .../aggregations/AggregateBuilders.java | 12 ++++----- .../_types/aggregations/BoxPlotAggregate.java | 2 +- .../_types/aggregations/TermsBucketBase.java | 27 ++++++++++--------- .../MultiTermVectorsOperation.java | 17 +++++++----- .../elasticsearch/doc-files/api-spec.html | 4 +-- .../nodes/info/NodeInfoScript.java | 19 ++++++++----- .../nodes/info/NodeInfoSettings.java | 19 ++++++++----- .../nodes/info/NodeInfoSettingsNetwork.java | 19 ++++++++----- 9 files changed, 83 insertions(+), 62 deletions(-) diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/Aggregate.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/Aggregate.java index f2bf9ae81..c4a9b340c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/Aggregate.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/Aggregate.java @@ -82,7 +82,7 @@ public enum Kind implements JsonEnum { Avg("avg"), - BoxPlot("box_plot"), + Boxplot("boxplot"), BucketMetricValue("bucket_metric_value"), @@ -328,20 +328,20 @@ public AvgAggregate avg() { } /** - * Is this variant instance of kind {@code box_plot}? + * Is this variant instance of kind {@code boxplot}? */ - public boolean isBoxPlot() { - return _kind == Kind.BoxPlot; + public boolean isBoxplot() { + return _kind == Kind.Boxplot; } /** - * Get the {@code box_plot} variant value. + * Get the {@code boxplot} variant value. * * @throws IllegalStateException - * if the current variant is not of the {@code box_plot} kind. + * if the current variant is not of the {@code boxplot} kind. */ - public BoxPlotAggregate boxPlot() { - return TaggedUnionUtils.get(this, Kind.BoxPlot); + public BoxPlotAggregate boxplot() { + return TaggedUnionUtils.get(this, Kind.Boxplot); } /** @@ -1540,15 +1540,15 @@ public ObjectBuilder avg(Function boxPlot(BoxPlotAggregate v) { - this._kind = Kind.BoxPlot; + public ObjectBuilder boxplot(BoxPlotAggregate v) { + this._kind = Kind.Boxplot; this._value = v; return this; } - public ObjectBuilder boxPlot( + public ObjectBuilder boxplot( Function> fn) { - return this.boxPlot(fn.apply(new BoxPlotAggregate.Builder()).build()); + return this.boxplot(fn.apply(new BoxPlotAggregate.Builder()).build()); } public ObjectBuilder bucketMetricValue(BucketMetricValueAggregate v) { @@ -2285,7 +2285,7 @@ public Aggregate build() { deserializers.put("adjacency_matrix", AdjacencyMatrixAggregate._DESERIALIZER); deserializers.put("auto_date_histogram", AutoDateHistogramAggregate._DESERIALIZER); deserializers.put("avg", AvgAggregate._DESERIALIZER); - deserializers.put("box_plot", BoxPlotAggregate._DESERIALIZER); + deserializers.put("boxplot", BoxPlotAggregate._DESERIALIZER); deserializers.put("bucket_metric_value", BucketMetricValueAggregate._DESERIALIZER); deserializers.put("cardinality", CardinalityAggregate._DESERIALIZER); deserializers.put("children", ChildrenAggregate._DESERIALIZER); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/AggregateBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/AggregateBuilders.java index a0aa76d87..ea8787496 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/AggregateBuilders.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/AggregateBuilders.java @@ -100,20 +100,20 @@ public static Aggregate avg(Function> fn) { + public static Aggregate boxplot(Function> fn) { Aggregate.Builder builder = new Aggregate.Builder(); - builder.boxPlot(fn.apply(new BoxPlotAggregate.Builder()).build()); + builder.boxplot(fn.apply(new BoxPlotAggregate.Builder()).build()); return builder.build(); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/BoxPlotAggregate.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/BoxPlotAggregate.java index d4959d043..4c43febcf 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/BoxPlotAggregate.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/BoxPlotAggregate.java @@ -124,7 +124,7 @@ public static BoxPlotAggregate of(Function builder) { super(builder); - this.docCountError = builder.docCountError; + this.docCountErrorUpperBound = builder.docCountErrorUpperBound; } /** - * API name: {@code doc_count_error} + * API name: {@code doc_count_error_upper_bound} */ @Nullable - public final Long docCountError() { - return this.docCountError; + public final Long docCountErrorUpperBound() { + return this.docCountErrorUpperBound; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { super.serializeInternal(generator, mapper); - if (this.docCountError != null) { - generator.writeKey("doc_count_error"); - generator.write(this.docCountError); + if (this.docCountErrorUpperBound != null) { + generator.writeKey("doc_count_error_upper_bound"); + generator.write(this.docCountErrorUpperBound); } @@ -91,13 +91,13 @@ public abstract static class AbstractBuilder { @Nullable - private Long docCountError; + private Long docCountErrorUpperBound; /** - * API name: {@code doc_count_error} + * API name: {@code doc_count_error_upper_bound} */ - public final BuilderT docCountError(@Nullable Long value) { - this.docCountError = value; + public final BuilderT docCountErrorUpperBound(@Nullable Long value) { + this.docCountErrorUpperBound = value; return self(); } @@ -107,7 +107,8 @@ public final BuilderT docCountError(@Nullable Long value) { protected static > void setupTermsBucketBaseDeserializer( ObjectDeserializer op) { MultiBucketBase.setupMultiBucketBaseDeserializer(op); - op.add(AbstractBuilder::docCountError, JsonpDeserializer.longDeserializer(), "doc_count_error"); + op.add(AbstractBuilder::docCountErrorUpperBound, JsonpDeserializer.longDeserializer(), + "doc_count_error_upper_bound"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mtermvectors/MultiTermVectorsOperation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mtermvectors/MultiTermVectorsOperation.java index 74467a91a..39dcdfa25 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mtermvectors/MultiTermVectorsOperation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/mtermvectors/MultiTermVectorsOperation.java @@ -66,6 +66,7 @@ */ @JsonpDeserializable public class MultiTermVectorsOperation implements JsonpSerializable { + @Nullable private final String id; @Nullable @@ -107,7 +108,7 @@ public class MultiTermVectorsOperation implements JsonpSerializable { private MultiTermVectorsOperation(Builder builder) { - this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); + this.id = builder.id; this.index = builder.index; this.doc = builder.doc; this.fields = ApiTypeHelper.unmodifiable(builder.fields); @@ -128,10 +129,11 @@ public static MultiTermVectorsOperation of(Function * API name: {@code _id} */ + @Nullable public final String id() { return this.id; } @@ -271,9 +273,11 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("_id"); - generator.write(this.id); + if (this.id != null) { + generator.writeKey("_id"); + generator.write(this.id); + } if (this.index != null) { generator.writeKey("_index"); generator.write(this.index); @@ -355,6 +359,7 @@ public String toString() { public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable private String id; @Nullable @@ -394,11 +399,11 @@ public static class Builder extends WithJsonObjectBuilderBase private VersionType versionType; /** - * Required - The ID of the document. + * The ID of the document. *

* API name: {@code _id} */ - public final Builder id(String value) { + public final Builder id(@Nullable String value) { this.id = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html index 2340fb0c3..b786afb83 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html @@ -2720,10 +2720,10 @@ if (hash.length > 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/2438c4b3e5ecd91091d9a9a75eace1c380d8e479/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/2a4afb9372742518b1a19ba0ca0829b50ec10926/specification/" + (paths[hash] || ""); - Please see the Elasticsearch API specification. + Please see the Elasticsearch API specification. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoScript.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoScript.java index f34b5f2da..25e65781c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoScript.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoScript.java @@ -61,6 +61,7 @@ public class NodeInfoScript implements JsonpSerializable { private final String allowedTypes; + @Nullable private final String disableMaxCompilationsRate; // --------------------------------------------------------------------------------------------- @@ -68,8 +69,7 @@ public class NodeInfoScript implements JsonpSerializable { private NodeInfoScript(Builder builder) { this.allowedTypes = ApiTypeHelper.requireNonNull(builder.allowedTypes, this, "allowedTypes"); - this.disableMaxCompilationsRate = ApiTypeHelper.requireNonNull(builder.disableMaxCompilationsRate, this, - "disableMaxCompilationsRate"); + this.disableMaxCompilationsRate = builder.disableMaxCompilationsRate; } @@ -85,8 +85,9 @@ public final String allowedTypes() { } /** - * Required - API name: {@code disable_max_compilations_rate} + * API name: {@code disable_max_compilations_rate} */ + @Nullable public final String disableMaxCompilationsRate() { return this.disableMaxCompilationsRate; } @@ -105,8 +106,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("allowed_types"); generator.write(this.allowedTypes); - generator.writeKey("disable_max_compilations_rate"); - generator.write(this.disableMaxCompilationsRate); + if (this.disableMaxCompilationsRate != null) { + generator.writeKey("disable_max_compilations_rate"); + generator.write(this.disableMaxCompilationsRate); + + } } @@ -124,6 +128,7 @@ public String toString() { public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { private String allowedTypes; + @Nullable private String disableMaxCompilationsRate; /** @@ -135,9 +140,9 @@ public final Builder allowedTypes(String value) { } /** - * Required - API name: {@code disable_max_compilations_rate} + * API name: {@code disable_max_compilations_rate} */ - public final Builder disableMaxCompilationsRate(String value) { + public final Builder disableMaxCompilationsRate(@Nullable String value) { this.disableMaxCompilationsRate = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoSettings.java index f2caa5182..769a757e1 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoSettings.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoSettings.java @@ -74,6 +74,7 @@ public class NodeInfoSettings implements JsonpSerializable { @Nullable private final NodeInfoAction action; + @Nullable private final NodeInfoClient client; private final NodeInfoSettingsHttp http; @@ -108,7 +109,7 @@ private NodeInfoSettings(Builder builder) { this.repositories = builder.repositories; this.discovery = builder.discovery; this.action = builder.action; - this.client = ApiTypeHelper.requireNonNull(builder.client, this, "client"); + this.client = builder.client; this.http = ApiTypeHelper.requireNonNull(builder.http, this, "http"); this.bootstrap = builder.bootstrap; this.transport = ApiTypeHelper.requireNonNull(builder.transport, this, "transport"); @@ -171,8 +172,9 @@ public final NodeInfoAction action() { } /** - * Required - API name: {@code client} + * API name: {@code client} */ + @Nullable public final NodeInfoClient client() { return this.client; } @@ -276,9 +278,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.action.serialize(generator, mapper); } - generator.writeKey("client"); - this.client.serialize(generator, mapper); + if (this.client != null) { + generator.writeKey("client"); + this.client.serialize(generator, mapper); + } generator.writeKey("http"); this.http.serialize(generator, mapper); @@ -346,6 +350,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private NodeInfoAction action; + @Nullable private NodeInfoClient client; private NodeInfoSettingsHttp http; @@ -463,15 +468,15 @@ public final Builder action(Function> fn) { return this.client(fn.apply(new NodeInfoClient.Builder()).build()); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoSettingsNetwork.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoSettingsNetwork.java index a57a5bc80..961b646d0 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoSettingsNetwork.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/nodes/info/NodeInfoSettingsNetwork.java @@ -26,7 +26,6 @@ import co.elastic.clients.json.JsonpUtils; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; @@ -60,13 +59,14 @@ */ @JsonpDeserializable public class NodeInfoSettingsNetwork implements JsonpSerializable { + @Nullable private final String host; // --------------------------------------------------------------------------------------------- private NodeInfoSettingsNetwork(Builder builder) { - this.host = ApiTypeHelper.requireNonNull(builder.host, this, "host"); + this.host = builder.host; } @@ -75,8 +75,9 @@ public static NodeInfoSettingsNetwork of(Function implements ObjectBuilder { + @Nullable private String host; /** - * Required - API name: {@code host} + * API name: {@code host} */ - public final Builder host(String value) { + public final Builder host(@Nullable String value) { this.host = value; return this; }