From b962e89d5a13572a994e56f9d5290566e0785ba2 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 1 Nov 2024 04:07:02 +1300 Subject: [PATCH] Begin generating index CRUD operations (#1220) * Generate indices.get Signed-off-by: Thomas Farr * Generate indices.exists Signed-off-by: Thomas Farr * Generate indices.create Signed-off-by: Thomas Farr * Generate indices.delete Signed-off-by: Thomas Farr * Cleanup SourceFieldMode Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr --- UPGRADING.md | 8 +- .../opensearch/OpenSearchAsyncClientBase.java | 5 + .../opensearch/OpenSearchClientBase.java | 5 + .../opensearch/_types/ExpandWildcard.java | 26 +- .../_types/IndicesResponseBase.java | 34 +- .../_types/WaitForActiveShardOptions.java | 10 +- .../_types/WaitForActiveShards.java | 106 +-- .../opensearch/_types/mapping/AllField.java | 66 +- .../_types/mapping/DataStreamTimestamp.java | 148 +++++ .../_types/mapping/DynamicMapping.java | 18 +- .../_types/mapping/DynamicTemplate.java | 65 +- .../_types/mapping/FieldNamesField.java | 32 +- .../opensearch/_types/mapping/IndexField.java | 32 +- .../opensearch/_types/mapping/MatchType.java | 12 +- .../_types/mapping/RoutingField.java | 32 +- .../opensearch/_types/mapping/SizeField.java | 32 +- .../_types/mapping/SourceField.java | 79 ++- .../_types/mapping/TypeMapping.java | 299 +++++---- .../client/opensearch/indices/Alias.java | 75 ++- .../indices/CreateIndexRequest.java | 273 ++++---- .../indices/CreateIndexResponse.java | 90 +-- .../indices/DeleteIndexRequest.java | 250 ++++--- .../indices/DeleteIndexResponse.java | 31 +- .../opensearch/indices/ExistsRequest.java | 213 ++++-- .../opensearch/indices/GetIndexRequest.java | 268 ++++---- .../opensearch/indices/GetIndexResponse.java | 17 +- .../client/opensearch/indices/IndexState.java | 187 +++--- .../OpenSearchIndicesAsyncClientBase.java | 137 ++++ .../indices/OpenSearchIndicesClientBase.java | 136 ++++ .../opensearch/OpenSearchAsyncClient.java | 5 - .../client/opensearch/OpenSearchClient.java | 5 - .../_types/WaitForActiveShardsBuilders.java | 46 -- .../opensearch/indices/ExistsResponse.java | 49 -- .../indices/OpenSearchIndicesAsyncClient.java | 131 +--- .../indices/OpenSearchIndicesClient.java | 131 +--- .../transport/endpoints/BooleanEndpoint.java | 9 + .../client/opensearch/model/EnumTest.java | 4 +- java-codegen/opensearch-openapi.yaml | 609 ++++++++++++++++-- .../client/codegen/CodeGenerator.java | 1 + .../client/codegen/model/EnumShape.java | 21 +- .../client/codegen/model/ObjectShape.java | 13 + .../client/codegen/model/RequestShape.java | 17 +- .../client/codegen/model/SpecTransformer.java | 161 +++-- .../codegen/model/TaggedUnionShape.java | 29 +- .../client/codegen/model/Types.java | 133 ++-- .../codegen/model/overrides/Overrides.java | 26 +- .../model/overrides/SchemaOverride.java | 37 +- .../model/overrides/ShouldGenerate.java | 15 + .../client/codegen/openapi/OpenApiSchema.java | 20 +- .../client/codegen/utils/Markdown.java | 4 +- .../codegen/templates/EnumShape.mustache | 5 + .../templates/ObjectShape/Builder.mustache | 12 +- .../ObjectShape/Builder/SelfImpl.mustache | 2 +- .../ObjectShape/Deserialize.mustache | 4 + .../codegen/templates/RequestShape.mustache | 7 +- .../templates/TaggedUnionShape.mustache | 2 +- .../templates/Type/directSerializer.mustache | 11 +- 57 files changed, 2749 insertions(+), 1446 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java (76%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/WaitForActiveShardOptions.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/WaitForActiveShards.java (76%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/AllField.java (83%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DataStreamTimestamp.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/FieldNamesField.java (81%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java (79%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/Alias.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/CreateIndexRequest.java (70%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/CreateIndexResponse.java (75%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/DeleteIndexRequest.java (59%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/DeleteIndexResponse.java (77%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/ExistsRequest.java (57%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java (70%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java (84%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/IndexState.java (81%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClientBase.java delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/_types/WaitForActiveShardsBuilders.java delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsResponse.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java diff --git a/UPGRADING.md b/UPGRADING.md index 4556772bea..c14f4e0821 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -51,4 +51,10 @@ After: - The `name` field, getter and builder method have been renamed to `repository`. ### CloneSnapshotRequest timeout removal -- The `timeout` field, getter and builder method have been removed from `CloneSnapshotRequest` as it is not supported by OpenSearch. \ No newline at end of file +- The `timeout` field, getter and builder method have been removed from `CloneSnapshotRequest` as it is not supported by OpenSearch. + +### DynamicMapping +- Removed the `Runtime` variant from the `DynamicMapping` enum as it is not supported by OpenSearch. + +### TypeMapping +- Removed the `runtime` field, getter and builder methods from `TypeMapping` as it is not supported by OpenSearch. \ No newline at end of file diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java index cbe9d63a80..2ddfefc198 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java @@ -45,6 +45,7 @@ import org.opensearch.client.opensearch.core.InfoRequest; import org.opensearch.client.opensearch.core.InfoResponse; import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesAsyncClient; +import org.opensearch.client.opensearch.indices.OpenSearchIndicesAsyncClient; import org.opensearch.client.opensearch.ml.OpenSearchMlAsyncClient; import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotAsyncClient; import org.opensearch.client.opensearch.tasks.OpenSearchTasksAsyncClient; @@ -66,6 +67,10 @@ public OpenSearchDanglingIndicesAsyncClient danglingIndices() { return new OpenSearchDanglingIndicesAsyncClient(this.transport, this.transportOptions); } + public OpenSearchIndicesAsyncClient indices() { + return new OpenSearchIndicesAsyncClient(this.transport, this.transportOptions); + } + public OpenSearchMlAsyncClient ml() { return new OpenSearchMlAsyncClient(this.transport, this.transportOptions); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java index 36f4a912b6..eeedcc19fd 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java @@ -44,6 +44,7 @@ import org.opensearch.client.opensearch.core.InfoRequest; import org.opensearch.client.opensearch.core.InfoResponse; import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesClient; +import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient; import org.opensearch.client.opensearch.ml.OpenSearchMlClient; import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotClient; import org.opensearch.client.opensearch.tasks.OpenSearchTasksClient; @@ -65,6 +66,10 @@ public OpenSearchDanglingIndicesClient danglingIndices() { return new OpenSearchDanglingIndicesClient(this.transport, this.transportOptions); } + public OpenSearchIndicesClient indices() { + return new OpenSearchIndicesClient(this.transport, this.transportOptions); + } + public OpenSearchMlClient ml() { return new OpenSearchMlClient(this.transport, this.transportOptions); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java similarity index 78% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java index 5b66a33bd2..cf64f63793 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java @@ -30,32 +30,33 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.ExpandWildcard + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum ExpandWildcard implements JsonEnum { /** - * Match any data stream or index, including hidden ones. + * Match any index, including hidden ones. */ All("all"), /** - * Match open, non-hidden indices. Also matches any non-hidden data stream. - */ - Open("open"), - - /** - * Match closed, non-hidden indices. Also matches any non-hidden data stream. - * Data streams cannot be closed. + * Match closed, non-hidden indices. */ Closed("closed"), /** - * Match hidden data streams and hidden indices. Must be combined with open, - * closed, or both. + * Match hidden indices. Must be combined with open, closed, or both. */ Hidden("hidden"), @@ -64,7 +65,10 @@ public enum ExpandWildcard implements JsonEnum { */ None("none"), - ; + /** + * Match open, non-hidden indices. + */ + Open("open"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java similarity index 76% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java index ba251d885a..3308f0c8b5 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java @@ -30,10 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.ObjectDeserializer; @@ -41,7 +47,9 @@ // typedef: _types.IndicesResponseBase +@Generated("org.opensearch.client.codegen.CodeGenerator") public abstract class IndicesResponseBase extends AcknowledgedResponseBase { + @Nullable private final ShardStatistics shards; @@ -49,9 +57,7 @@ public abstract class IndicesResponseBase extends AcknowledgedResponseBase { protected IndicesResponseBase(AbstractBuilder builder) { super(builder); - this.shards = builder.shards; - } /** @@ -63,16 +69,15 @@ public final ShardStatistics shards() { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - super.serializeInternal(generator, mapper); if (this.shards != null) { generator.writeKey("_shards"); this.shards.serialize(generator, mapper); - } - } + // --------------------------------------------------------------------------------------------- + protected abstract static class AbstractBuilder> extends AcknowledgedResponseBase.AbstractBuilder { @Nullable @@ -90,18 +95,35 @@ public final BuilderT shards(@Nullable ShardStatistics value) { * API name: {@code _shards} */ public final BuilderT shards(Function> fn) { - return this.shards(fn.apply(new ShardStatistics.Builder()).build()); + return shards(fn.apply(new ShardStatistics.Builder()).build()); } } // --------------------------------------------------------------------------------------------- + protected static > void setupIndicesResponseBaseDeserializer( ObjectDeserializer op ) { setupAcknowledgedResponseBaseDeserializer(op); op.add(AbstractBuilder::shards, ShardStatistics._DESERIALIZER, "_shards"); + } + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Objects.hashCode(this.shards); + return result; } + @Override + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndicesResponseBase other = (IndicesResponseBase) o; + return Objects.equals(this.shards, other.shards); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/WaitForActiveShardOptions.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WaitForActiveShardOptions.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/WaitForActiveShardOptions.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/WaitForActiveShardOptions.java index fef26538b2..47b621f811 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/WaitForActiveShardOptions.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WaitForActiveShardOptions.java @@ -30,16 +30,24 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.WaitForActiveShardOptions + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum WaitForActiveShardOptions implements JsonEnum { All("all"), - ; + IndexSetting("index-setting"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/WaitForActiveShards.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WaitForActiveShards.java similarity index 76% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/WaitForActiveShards.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/WaitForActiveShards.java index 05a374ed2f..6dd8be87b8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/WaitForActiveShards.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WaitForActiveShards.java @@ -30,14 +30,21 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.json.UnionDeserializer; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; @@ -48,12 +55,14 @@ // typedef: _types.WaitForActiveShards @JsonpDeserializable -public class WaitForActiveShards implements TaggedUnion, JsonpSerializable { - +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class WaitForActiveShards implements TaggedUnion, PlainJsonSerializable { + /** + * {@link WaitForActiveShards} variant kinds. + */ public enum Kind { - Option, - Count - + Count, + Option } private final Kind _kind; @@ -74,27 +83,40 @@ private WaitForActiveShards(Kind kind, Object value) { this._value = value; } + private WaitForActiveShards(Builder builder) { + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + } + + public static WaitForActiveShards of(Function> fn) { + return fn.apply(new Builder()).build(); + } + public String _toJsonString() { switch (_kind) { - case Option: - return this.option().jsonValue(); case Count: return String.valueOf(this.count()); - + case Option: + return this.option().jsonValue(); default: throw new IllegalStateException("Unknown kind " + _kind); } } - private WaitForActiveShards(Builder builder) { - - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); - this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - + /** + * Is this variant instance of kind {@code count}? + */ + public boolean isCount() { + return _kind == Kind.Count; } - public static WaitForActiveShards of(Function> fn) { - return fn.apply(new Builder()).build(); + /** + * Get the {@code count} variant value. + * + * @throws IllegalStateException if the current variant is not the {@code count} kind. + */ + public Integer count() { + return TaggedUnionUtils.get(this, Kind.Count); } /** @@ -107,30 +129,12 @@ public boolean isOption() { /** * Get the {@code option} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code option} kind. + * @throws IllegalStateException if the current variant is not the {@code option} kind. */ public WaitForActiveShardOptions option() { return TaggedUnionUtils.get(this, Kind.Option); } - /** - * Is this variant instance of kind {@code count}? - */ - public boolean isCount() { - return _kind == Kind.Count; - } - - /** - * Get the {@code count} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code count} kind. - */ - public Integer count() { - return TaggedUnionUtils.get(this, Kind.Count); - } - @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { if (_value instanceof JsonpSerializable) { @@ -139,44 +143,58 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { switch (_kind) { case Count: generator.write(((Integer) this._value)); - break; } } - } public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Kind _kind; private Object _value; - public ObjectBuilder option(WaitForActiveShardOptions v) { - this._kind = Kind.Option; + public ObjectBuilder count(Integer v) { + this._kind = Kind.Count; this._value = v; return this; } - public ObjectBuilder count(Integer v) { - this._kind = Kind.Count; + public ObjectBuilder option(WaitForActiveShardOptions v) { + this._kind = Kind.Option; this._value = v; return this; } + @Override public WaitForActiveShards build() { _checkSingleUse(); return new WaitForActiveShards(this); } - } private static JsonpDeserializer buildWaitForActiveShardsDeserializer() { return new UnionDeserializer.Builder(WaitForActiveShards::new, false).addMember( - Kind.Option, - WaitForActiveShardOptions._DESERIALIZER - ).addMember(Kind.Count, JsonpDeserializer.integerDeserializer()).build(); + Kind.Count, + JsonpDeserializer.integerDeserializer() + ).addMember(Kind.Option, WaitForActiveShardOptions._DESERIALIZER).build(); } public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.lazy( WaitForActiveShards::buildWaitForActiveShardsDeserializer ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this._kind); + result = 31 * result + Objects.hashCode(this._value); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + WaitForActiveShards other = (WaitForActiveShards) o; + return Objects.equals(this._kind, other._kind) && Objects.equals(this._value, other._value); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/AllField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/AllField.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/AllField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/AllField.java index d9e675fdf9..223be35e58 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/AllField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/AllField.java @@ -30,10 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -47,15 +53,20 @@ // typedef: _types.mapping.AllField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class AllField implements PlainJsonSerializable { + + @Nonnull private final String analyzer; private final boolean enabled; private final boolean omitNorms; + @Nonnull private final String searchAnalyzer; + @Nonnull private final String similarity; private final boolean store; @@ -71,7 +82,6 @@ public class AllField implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private AllField(Builder builder) { - this.analyzer = ApiTypeHelper.requireNonNull(builder.analyzer, this, "analyzer"); this.enabled = ApiTypeHelper.requireNonNull(builder.enabled, this, "enabled"); this.omitNorms = ApiTypeHelper.requireNonNull(builder.omitNorms, this, "omitNorms"); @@ -82,16 +92,16 @@ private AllField(Builder builder) { this.storeTermVectorPayloads = ApiTypeHelper.requireNonNull(builder.storeTermVectorPayloads, this, "storeTermVectorPayloads"); this.storeTermVectorPositions = ApiTypeHelper.requireNonNull(builder.storeTermVectorPositions, this, "storeTermVectorPositions"); this.storeTermVectors = ApiTypeHelper.requireNonNull(builder.storeTermVectors, this, "storeTermVectors"); - } - public static AllField of(Function> fn) { + public static AllField of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code analyzer} */ + @Nonnull public final String analyzer() { return this.analyzer; } @@ -113,6 +123,7 @@ public final boolean omitNorms() { /** * Required - API name: {@code search_analyzer} */ + @Nonnull public final String searchAnalyzer() { return this.searchAnalyzer; } @@ -120,6 +131,7 @@ public final String searchAnalyzer() { /** * Required - API name: {@code similarity} */ + @Nonnull public final String similarity() { return this.similarity; } @@ -162,6 +174,7 @@ public final boolean storeTermVectors() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -169,7 +182,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("analyzer"); generator.write(this.analyzer); @@ -199,7 +211,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("store_term_vectors"); generator.write(this.storeTermVectors); - } // --------------------------------------------------------------------------------------------- @@ -207,26 +218,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link AllField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private String analyzer; - private Boolean enabled; - private Boolean omitNorms; - private String searchAnalyzer; - private String similarity; - private Boolean store; - private Boolean storeTermVectorOffsets; - private Boolean storeTermVectorPayloads; - private Boolean storeTermVectorPositions; - private Boolean storeTermVectors; /** @@ -312,8 +313,7 @@ public final Builder storeTermVectors(boolean value) { /** * Builds a {@link AllField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public AllField build() { _checkSingleUse(); @@ -333,7 +333,6 @@ public AllField build() { ); protected static void setupAllFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::analyzer, JsonpDeserializer.stringDeserializer(), "analyzer"); op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); op.add(Builder::omitNorms, JsonpDeserializer.booleanDeserializer(), "omit_norms"); @@ -344,7 +343,38 @@ protected static void setupAllFieldDeserializer(ObjectDeserializer> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code enabled} + */ + public final boolean enabled() { + return this.enabled; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey("enabled"); + generator.write(this.enabled); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DataStreamTimestamp}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Boolean enabled; + + /** + * Required - API name: {@code enabled} + */ + public final Builder enabled(boolean value) { + this.enabled = value; + return this; + } + + /** + * Builds a {@link DataStreamTimestamp}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public DataStreamTimestamp build() { + _checkSingleUse(); + + return new DataStreamTimestamp(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link DataStreamTimestamp} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + DataStreamTimestamp::setupDataStreamTimestampDeserializer + ); + + protected static void setupDataStreamTimestampDeserializer(ObjectDeserializer op) { + op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.enabled); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + DataStreamTimestamp other = (DataStreamTimestamp) o; + return this.enabled == other.enabled; + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java index 0fe589b4c6..4daab1db6f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicMapping.java @@ -30,22 +30,28 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.mapping.DynamicMapping + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum DynamicMapping implements JsonEnum { - Strict("strict"), - - Runtime("runtime"), + False("false"), - True("true"), + Strict("strict"), - False("false"), + StrictAllowTemplates("strict_allow_templates"), - ; + True("true"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java index 568ee8a3b3..1f9af30080 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DynamicTemplate.java @@ -30,10 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -47,7 +53,9 @@ // typedef: _types.mapping.DynamicTemplate @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class DynamicTemplate implements PlainJsonSerializable { + @Nullable private final Property mapping; @@ -72,7 +80,6 @@ public class DynamicTemplate implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private DynamicTemplate(Builder builder) { - this.mapping = builder.mapping; this.match = builder.match; this.matchMappingType = builder.matchMappingType; @@ -80,10 +87,9 @@ private DynamicTemplate(Builder builder) { this.pathMatch = builder.pathMatch; this.pathUnmatch = builder.pathUnmatch; this.unmatch = builder.unmatch; - } - public static DynamicTemplate of(Function> fn) { + public static DynamicTemplate of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -146,6 +152,7 @@ public final String unmatch() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -153,42 +160,40 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.mapping != null) { generator.writeKey("mapping"); this.mapping.serialize(generator, mapper); - } + if (this.match != null) { generator.writeKey("match"); generator.write(this.match); - } + if (this.matchMappingType != null) { generator.writeKey("match_mapping_type"); generator.write(this.matchMappingType); - } + if (this.matchPattern != null) { generator.writeKey("match_pattern"); this.matchPattern.serialize(generator, mapper); } + if (this.pathMatch != null) { generator.writeKey("path_match"); generator.write(this.pathMatch); - } + if (this.pathUnmatch != null) { generator.writeKey("path_unmatch"); generator.write(this.pathUnmatch); - } + if (this.unmatch != null) { generator.writeKey("unmatch"); generator.write(this.unmatch); - } - } // --------------------------------------------------------------------------------------------- @@ -196,26 +201,19 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link DynamicTemplate}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Property mapping; - @Nullable private String match; - @Nullable private String matchMappingType; - @Nullable private MatchType matchPattern; - @Nullable private String pathMatch; - @Nullable private String pathUnmatch; - @Nullable private String unmatch; @@ -231,7 +229,7 @@ public final Builder mapping(@Nullable Property value) { * API name: {@code mapping} */ public final Builder mapping(Function> fn) { - return this.mapping(fn.apply(new Property.Builder()).build()); + return mapping(fn.apply(new Property.Builder()).build()); } /** @@ -285,8 +283,7 @@ public final Builder unmatch(@Nullable String value) { /** * Builds a {@link DynamicTemplate}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public DynamicTemplate build() { _checkSingleUse(); @@ -306,7 +303,6 @@ public DynamicTemplate build() { ); protected static void setupDynamicTemplateDeserializer(ObjectDeserializer op) { - op.add(Builder::mapping, Property._DESERIALIZER, "mapping"); op.add(Builder::match, JsonpDeserializer.stringDeserializer(), "match"); op.add(Builder::matchMappingType, JsonpDeserializer.stringDeserializer(), "match_mapping_type"); @@ -314,7 +310,32 @@ protected static void setupDynamicTemplateDeserializer(ObjectDeserializer> fn) { + public static FieldNamesField of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -72,6 +77,7 @@ public final boolean enabled() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -79,10 +85,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("enabled"); generator.write(this.enabled); - } // --------------------------------------------------------------------------------------------- @@ -90,7 +94,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link FieldNamesField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean enabled; @@ -105,8 +108,7 @@ public final Builder enabled(boolean value) { /** * Builds a {@link FieldNamesField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public FieldNamesField build() { _checkSingleUse(); @@ -126,9 +128,21 @@ public FieldNamesField build() { ); protected static void setupFieldNamesFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.enabled); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + FieldNamesField other = (FieldNamesField) o; + return this.enabled == other.enabled; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java index 47900c18c0..e5552869f7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IndexField.java @@ -30,10 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -47,18 +52,18 @@ // typedef: _types.mapping.IndexField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class IndexField implements PlainJsonSerializable { + private final boolean enabled; // --------------------------------------------------------------------------------------------- private IndexField(Builder builder) { - this.enabled = ApiTypeHelper.requireNonNull(builder.enabled, this, "enabled"); - } - public static IndexField of(Function> fn) { + public static IndexField of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -72,6 +77,7 @@ public final boolean enabled() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -79,10 +85,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("enabled"); generator.write(this.enabled); - } // --------------------------------------------------------------------------------------------- @@ -90,7 +94,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link IndexField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean enabled; @@ -105,8 +108,7 @@ public final Builder enabled(boolean value) { /** * Builds a {@link IndexField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public IndexField build() { _checkSingleUse(); @@ -126,9 +128,21 @@ public IndexField build() { ); protected static void setupIndexFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.enabled); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndexField other = (IndexField) o; + return this.enabled == other.enabled; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java index b4a3f1330b..5a57d96751 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/MatchType.java @@ -30,18 +30,24 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.mapping.MatchType + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum MatchType implements JsonEnum { - Simple("simple"), - Regex("regex"), - ; + Simple("simple"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java index 3882835104..df5983d762 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/RoutingField.java @@ -30,10 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -47,18 +52,18 @@ // typedef: _types.mapping.RoutingField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class RoutingField implements PlainJsonSerializable { + private final boolean required; // --------------------------------------------------------------------------------------------- private RoutingField(Builder builder) { - this.required = ApiTypeHelper.requireNonNull(builder.required, this, "required"); - } - public static RoutingField of(Function> fn) { + public static RoutingField of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -72,6 +77,7 @@ public final boolean required() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -79,10 +85,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("required"); generator.write(this.required); - } // --------------------------------------------------------------------------------------------- @@ -90,7 +94,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link RoutingField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean required; @@ -105,8 +108,7 @@ public final Builder required(boolean value) { /** * Builds a {@link RoutingField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public RoutingField build() { _checkSingleUse(); @@ -126,9 +128,21 @@ public RoutingField build() { ); protected static void setupRoutingFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::required, JsonpDeserializer.booleanDeserializer(), "required"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.required); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + RoutingField other = (RoutingField) o; + return this.required == other.required; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java index c0f633dbb1..a0cd45d19e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SizeField.java @@ -30,10 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -47,18 +52,18 @@ // typedef: _types.mapping.SizeField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class SizeField implements PlainJsonSerializable { + private final boolean enabled; // --------------------------------------------------------------------------------------------- private SizeField(Builder builder) { - this.enabled = ApiTypeHelper.requireNonNull(builder.enabled, this, "enabled"); - } - public static SizeField of(Function> fn) { + public static SizeField of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -72,6 +77,7 @@ public final boolean enabled() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -79,10 +85,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("enabled"); generator.write(this.enabled); - } // --------------------------------------------------------------------------------------------- @@ -90,7 +94,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link SizeField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean enabled; @@ -105,8 +108,7 @@ public final Builder enabled(boolean value) { /** * Builds a {@link SizeField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public SizeField build() { _checkSingleUse(); @@ -126,9 +128,21 @@ public SizeField build() { ); protected static void setupSizeFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.enabled); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SizeField other = (SizeField) o; + return this.enabled == other.enabled; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java index 6ff76552f3..f14950a494 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/SourceField.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; import java.util.List; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -50,7 +57,9 @@ // typedef: _types.mapping.SourceField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class SourceField implements PlainJsonSerializable { + @Nullable private final Boolean compress; @@ -60,23 +69,23 @@ public class SourceField implements PlainJsonSerializable { @Nullable private final Boolean enabled; + @Nonnull private final List excludes; + @Nonnull private final List includes; // --------------------------------------------------------------------------------------------- private SourceField(Builder builder) { - this.compress = builder.compress; this.compressThreshold = builder.compressThreshold; this.enabled = builder.enabled; this.excludes = ApiTypeHelper.unmodifiable(builder.excludes); this.includes = ApiTypeHelper.unmodifiable(builder.includes); - } - public static SourceField of(Function> fn) { + public static SourceField of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -107,6 +116,7 @@ public final Boolean enabled() { /** * API name: {@code excludes} */ + @Nonnull public final List excludes() { return this.excludes; } @@ -114,6 +124,7 @@ public final List excludes() { /** * API name: {@code includes} */ + @Nonnull public final List includes() { return this.includes; } @@ -121,6 +132,7 @@ public final List includes() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -128,43 +140,38 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.compress != null) { generator.writeKey("compress"); generator.write(this.compress); - } + if (this.compressThreshold != null) { generator.writeKey("compress_threshold"); generator.write(this.compressThreshold); - } + if (this.enabled != null) { generator.writeKey("enabled"); generator.write(this.enabled); - } + if (ApiTypeHelper.isDefined(this.excludes)) { generator.writeKey("excludes"); generator.writeStartArray(); for (String item0 : this.excludes) { generator.write(item0); - } generator.writeEnd(); - } + if (ApiTypeHelper.isDefined(this.includes)) { generator.writeKey("includes"); generator.writeStartArray(); for (String item0 : this.includes) { generator.write(item0); - } generator.writeEnd(); - } - } // --------------------------------------------------------------------------------------------- @@ -172,20 +179,20 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link SourceField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder, PlainDeserializable { + @Override + public Builder self() { + return this; + } + @Nullable private Boolean compress; - @Nullable private String compressThreshold; - @Nullable private Boolean enabled; - @Nullable private List excludes; - @Nullable private List includes; @@ -215,8 +222,10 @@ public final Builder enabled(@Nullable Boolean value) { /** * API name: {@code excludes} + * *

* Adds all elements of list to excludes. + *

*/ public final Builder excludes(List list) { this.excludes = _listAddAll(this.excludes, list); @@ -225,8 +234,10 @@ public final Builder excludes(List list) { /** * API name: {@code excludes} + * *

* Adds one or more values to excludes. + *

*/ public final Builder excludes(String value, String... values) { this.excludes = _listAdd(this.excludes, value, values); @@ -235,8 +246,10 @@ public final Builder excludes(String value, String... values) { /** * API name: {@code includes} + * *

* Adds all elements of list to includes. + *

*/ public final Builder includes(List list) { this.includes = _listAddAll(this.includes, list); @@ -245,8 +258,10 @@ public final Builder includes(List list) { /** * API name: {@code includes} + * *

* Adds one or more values to includes. + *

*/ public final Builder includes(String value, String... values) { this.includes = _listAdd(this.includes, value, values); @@ -256,19 +271,13 @@ public final Builder includes(String value, String... values) { /** * Builds a {@link SourceField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public SourceField build() { _checkSingleUse(); return new SourceField(this); } - - @Override - public Builder self() { - return this; - } } // --------------------------------------------------------------------------------------------- @@ -282,13 +291,33 @@ public Builder self() { ); protected static void setupSourceFieldDeserializer(ObjectDeserializer op) { - op.add(Builder::compress, JsonpDeserializer.booleanDeserializer(), "compress"); op.add(Builder::compressThreshold, JsonpDeserializer.stringDeserializer(), "compress_threshold"); op.add(Builder::enabled, JsonpDeserializer.booleanDeserializer(), "enabled"); op.add(Builder::excludes, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "excludes"); op.add(Builder::includes, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "includes"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.compress); + result = 31 * result + Objects.hashCode(this.compressThreshold); + result = 31 * result + Objects.hashCode(this.enabled); + result = 31 * result + Objects.hashCode(this.excludes); + result = 31 * result + Objects.hashCode(this.includes); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SourceField other = (SourceField) o; + return Objects.equals(this.compress, other.compress) + && Objects.equals(this.compressThreshold, other.compressThreshold) + && Objects.equals(this.enabled, other.enabled) + && Objects.equals(this.excludes, other.excludes) + && Objects.equals(this.includes, other.includes); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java similarity index 79% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java index cbc74c0013..8df176779a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/TypeMapping.java @@ -30,12 +30,19 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -52,31 +59,43 @@ // typedef: _types.mapping.TypeMapping @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class TypeMapping implements PlainJsonSerializable { + @Nullable private final AllField allField; + @Nullable + private final DataStreamTimestamp dataStreamTimestamp; + @Nullable private final Boolean dateDetection; @Nullable private final DynamicMapping dynamic; + @Nonnull private final List dynamicDateFormats; + @Nonnull private final List> dynamicTemplates; + @Nullable + private final Boolean enabled; + @Nullable private final FieldNamesField fieldNames; @Nullable private final IndexField indexField; + @Nonnull private final Map meta; @Nullable private final Boolean numericDetection; + @Nonnull private final Map properties; @Nullable @@ -88,20 +107,16 @@ public class TypeMapping implements PlainJsonSerializable { @Nullable private final SourceField source; - private final Map runtime; - - @Nullable - private final Boolean enabled; - // --------------------------------------------------------------------------------------------- private TypeMapping(Builder builder) { - this.allField = builder.allField; + this.dataStreamTimestamp = builder.dataStreamTimestamp; this.dateDetection = builder.dateDetection; this.dynamic = builder.dynamic; this.dynamicDateFormats = ApiTypeHelper.unmodifiable(builder.dynamicDateFormats); this.dynamicTemplates = ApiTypeHelper.unmodifiable(builder.dynamicTemplates); + this.enabled = builder.enabled; this.fieldNames = builder.fieldNames; this.indexField = builder.indexField; this.meta = ApiTypeHelper.unmodifiable(builder.meta); @@ -110,12 +125,9 @@ private TypeMapping(Builder builder) { this.routing = builder.routing; this.size = builder.size; this.source = builder.source; - this.runtime = ApiTypeHelper.unmodifiable(builder.runtime); - this.enabled = builder.enabled; - } - public static TypeMapping of(Function> fn) { + public static TypeMapping of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -127,6 +139,14 @@ public final AllField allField() { return this.allField; } + /** + * API name: {@code _data_stream_timestamp} + */ + @Nullable + public final DataStreamTimestamp dataStreamTimestamp() { + return this.dataStreamTimestamp; + } + /** * API name: {@code date_detection} */ @@ -146,6 +166,7 @@ public final DynamicMapping dynamic() { /** * API name: {@code dynamic_date_formats} */ + @Nonnull public final List dynamicDateFormats() { return this.dynamicDateFormats; } @@ -153,10 +174,19 @@ public final List dynamicDateFormats() { /** * API name: {@code dynamic_templates} */ + @Nonnull public final List> dynamicTemplates() { return this.dynamicTemplates; } + /** + * API name: {@code enabled} + */ + @Nullable + public final Boolean enabled() { + return this.enabled; + } + /** * API name: {@code _field_names} */ @@ -176,6 +206,7 @@ public final IndexField indexField() { /** * API name: {@code _meta} */ + @Nonnull public final Map meta() { return this.meta; } @@ -191,6 +222,7 @@ public final Boolean numericDetection() { /** * API name: {@code properties} */ + @Nonnull public final Map properties() { return this.properties; } @@ -219,24 +251,10 @@ public final SourceField source() { return this.source; } - /** - * API name: {@code runtime} - */ - public final Map runtime() { - return this.runtime; - } - - /** - * API name: {@code enabled} - */ - @Nullable - public final Boolean enabled() { - return this.enabled; - } - /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -244,31 +262,35 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.allField != null) { generator.writeKey("all_field"); this.allField.serialize(generator, mapper); + } + if (this.dataStreamTimestamp != null) { + generator.writeKey("_data_stream_timestamp"); + this.dataStreamTimestamp.serialize(generator, mapper); } + if (this.dateDetection != null) { generator.writeKey("date_detection"); generator.write(this.dateDetection); - } + if (this.dynamic != null) { generator.writeKey("dynamic"); this.dynamic.serialize(generator, mapper); } + if (ApiTypeHelper.isDefined(this.dynamicDateFormats)) { generator.writeKey("dynamic_date_formats"); generator.writeStartArray(); for (String item0 : this.dynamicDateFormats) { generator.write(item0); - } generator.writeEnd(); - } + if (ApiTypeHelper.isDefined(this.dynamicTemplates)) { generator.writeKey("dynamic_templates"); generator.writeStartArray(); @@ -278,84 +300,67 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); item1.getValue().serialize(generator, mapper); - } } generator.writeEnd(); - } generator.writeEnd(); + } + if (this.enabled != null) { + generator.writeKey("enabled"); + generator.write(this.enabled); } + if (this.fieldNames != null) { generator.writeKey("_field_names"); this.fieldNames.serialize(generator, mapper); - } + if (this.indexField != null) { generator.writeKey("index_field"); this.indexField.serialize(generator, mapper); - } + if (ApiTypeHelper.isDefined(this.meta)) { generator.writeKey("_meta"); generator.writeStartObject(); for (Map.Entry item0 : this.meta.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.numericDetection != null) { generator.writeKey("numeric_detection"); generator.write(this.numericDetection); - } + if (ApiTypeHelper.isDefined(this.properties)) { generator.writeKey("properties"); generator.writeStartObject(); for (Map.Entry item0 : this.properties.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.routing != null) { generator.writeKey("_routing"); this.routing.serialize(generator, mapper); - } + if (this.size != null) { generator.writeKey("_size"); this.size.serialize(generator, mapper); - } + if (this.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); - } - if (ApiTypeHelper.isDefined(this.runtime)) { - generator.writeKey("runtime"); - generator.writeStartObject(); - for (Map.Entry item0 : this.runtime.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - - } - if (this.enabled != null) { - generator.writeKey("enabled"); - generator.write(this.enabled); - - } - } // --------------------------------------------------------------------------------------------- @@ -363,53 +368,43 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link TypeMapping}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder, PlainDeserializable { + @Override + public Builder self() { + return this; + } + @Nullable private AllField allField; - + @Nullable + private DataStreamTimestamp dataStreamTimestamp; @Nullable private Boolean dateDetection; - @Nullable private DynamicMapping dynamic; - @Nullable private List dynamicDateFormats; - @Nullable private List> dynamicTemplates; - + @Nullable + private Boolean enabled; @Nullable private FieldNamesField fieldNames; - @Nullable private IndexField indexField; - @Nullable private Map meta; - @Nullable private Boolean numericDetection; - @Nullable private Map properties; - @Nullable private RoutingField routing; - @Nullable private SizeField size; - @Nullable private SourceField source; - @Nullable - private Map runtime; - - @Nullable - private Boolean enabled; - /** * API name: {@code all_field} */ @@ -422,7 +417,22 @@ public final Builder allField(@Nullable AllField value) { * API name: {@code all_field} */ public final Builder allField(Function> fn) { - return this.allField(fn.apply(new AllField.Builder()).build()); + return allField(fn.apply(new AllField.Builder()).build()); + } + + /** + * API name: {@code _data_stream_timestamp} + */ + public final Builder dataStreamTimestamp(@Nullable DataStreamTimestamp value) { + this.dataStreamTimestamp = value; + return this; + } + + /** + * API name: {@code _data_stream_timestamp} + */ + public final Builder dataStreamTimestamp(Function> fn) { + return dataStreamTimestamp(fn.apply(new DataStreamTimestamp.Builder()).build()); } /** @@ -443,8 +453,10 @@ public final Builder dynamic(@Nullable DynamicMapping value) { /** * API name: {@code dynamic_date_formats} + * *

* Adds all elements of list to dynamicDateFormats. + *

*/ public final Builder dynamicDateFormats(List list) { this.dynamicDateFormats = _listAddAll(this.dynamicDateFormats, list); @@ -453,8 +465,10 @@ public final Builder dynamicDateFormats(List list) { /** * API name: {@code dynamic_date_formats} + * *

* Adds one or more values to dynamicDateFormats. + *

*/ public final Builder dynamicDateFormats(String value, String... values) { this.dynamicDateFormats = _listAdd(this.dynamicDateFormats, value, values); @@ -463,8 +477,10 @@ public final Builder dynamicDateFormats(String value, String... values) { /** * API name: {@code dynamic_templates} + * *

* Adds all elements of list to dynamicTemplates. + *

*/ public final Builder dynamicTemplates(List> list) { this.dynamicTemplates = _listAddAll(this.dynamicTemplates, list); @@ -473,14 +489,24 @@ public final Builder dynamicTemplates(List> list) { /** * API name: {@code dynamic_templates} + * *

* Adds one or more values to dynamicTemplates. + *

*/ public final Builder dynamicTemplates(Map value, Map... values) { this.dynamicTemplates = _listAdd(this.dynamicTemplates, value, values); return this; } + /** + * API name: {@code enabled} + */ + public final Builder enabled(@Nullable Boolean value) { + this.enabled = value; + return this; + } + /** * API name: {@code _field_names} */ @@ -493,7 +519,7 @@ public final Builder fieldNames(@Nullable FieldNamesField value) { * API name: {@code _field_names} */ public final Builder fieldNames(Function> fn) { - return this.fieldNames(fn.apply(new FieldNamesField.Builder()).build()); + return fieldNames(fn.apply(new FieldNamesField.Builder()).build()); } /** @@ -508,13 +534,15 @@ public final Builder indexField(@Nullable IndexField value) { * API name: {@code index_field} */ public final Builder indexField(Function> fn) { - return this.indexField(fn.apply(new IndexField.Builder()).build()); + return indexField(fn.apply(new IndexField.Builder()).build()); } /** * API name: {@code _meta} + * *

- * Adds all entries of map to meta. + * Adds all elements of map to meta. + *

*/ public final Builder meta(Map map) { this.meta = _mapPutAll(this.meta, map); @@ -523,8 +551,10 @@ public final Builder meta(Map map) { /** * API name: {@code _meta} + * *

* Adds an entry to meta. + *

*/ public final Builder meta(String key, JsonData value) { this.meta = _mapPut(this.meta, key, value); @@ -541,8 +571,10 @@ public final Builder numericDetection(@Nullable Boolean value) { /** * API name: {@code properties} + * *

- * Adds all entries of map to properties. + * Adds all elements of map to properties. + *

*/ public final Builder properties(Map map) { this.properties = _mapPutAll(this.properties, map); @@ -551,8 +583,10 @@ public final Builder properties(Map map) { /** * API name: {@code properties} + * *

* Adds an entry to properties. + *

*/ public final Builder properties(String key, Property value) { this.properties = _mapPut(this.properties, key, value); @@ -561,8 +595,10 @@ public final Builder properties(String key, Property value) { /** * API name: {@code properties} + * *

- * Adds an entry to properties using a builder lambda. + * Adds a value to properties using a builder lambda. + *

*/ public final Builder properties(String key, Function> fn) { return properties(key, fn.apply(new Property.Builder()).build()); @@ -580,7 +616,7 @@ public final Builder routing(@Nullable RoutingField value) { * API name: {@code _routing} */ public final Builder routing(Function> fn) { - return this.routing(fn.apply(new RoutingField.Builder()).build()); + return routing(fn.apply(new RoutingField.Builder()).build()); } /** @@ -595,7 +631,7 @@ public final Builder size(@Nullable SizeField value) { * API name: {@code _size} */ public final Builder size(Function> fn) { - return this.size(fn.apply(new SizeField.Builder()).build()); + return size(fn.apply(new SizeField.Builder()).build()); } /** @@ -610,62 +646,19 @@ public final Builder source(@Nullable SourceField value) { * API name: {@code _source} */ public final Builder source(Function> fn) { - return this.source(fn.apply(new SourceField.Builder()).build()); - } - - /** - * API name: {@code runtime} - *

- * Adds all entries of map to runtime. - */ - public final Builder runtime(Map map) { - this.runtime = _mapPutAll(this.runtime, map); - return this; - } - - /** - * API name: {@code runtime} - *

- * Adds an entry to runtime. - */ - public final Builder runtime(String key, RuntimeField value) { - this.runtime = _mapPut(this.runtime, key, value); - return this; - } - - /** - * API name: {@code runtime} - *

- * Adds an entry to runtime using a builder lambda. - */ - public final Builder runtime(String key, Function> fn) { - return runtime(key, fn.apply(new RuntimeField.Builder()).build()); - } - - /** - * API name: {@code enabled} - */ - public final Builder enabled(@Nullable Boolean value) { - this.enabled = value; - return this; + return source(fn.apply(new SourceField.Builder()).build()); } /** * Builds a {@link TypeMapping}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public TypeMapping build() { _checkSingleUse(); return new TypeMapping(this); } - - @Override - public Builder self() { - return this; - } } // --------------------------------------------------------------------------------------------- @@ -679,8 +672,8 @@ public Builder self() { ); protected static void setupTypeMappingDeserializer(ObjectDeserializer op) { - op.add(Builder::allField, AllField._DESERIALIZER, "all_field"); + op.add(Builder::dataStreamTimestamp, DataStreamTimestamp._DESERIALIZER, "_data_stream_timestamp"); op.add(Builder::dateDetection, JsonpDeserializer.booleanDeserializer(), "date_detection"); op.add(Builder::dynamic, DynamicMapping._DESERIALIZER, "dynamic"); op.add( @@ -693,6 +686,7 @@ protected static void setupTypeMappingDeserializer(ObjectDeserializer> fn) { + public static Alias of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -101,7 +107,10 @@ public final String indexRouting() { } /** + * If true, the alias is hidden. All indices for the alias must have the same is_hidden value. + *

* API name: {@code is_hidden} + *

*/ @Nullable public final Boolean isHidden() { @@ -109,7 +118,10 @@ public final Boolean isHidden() { } /** + * If true, the index is the write index for the alias. + *

* API name: {@code is_write_index} + *

*/ @Nullable public final Boolean isWriteIndex() { @@ -135,6 +147,7 @@ public final String searchRouting() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -142,38 +155,35 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.filter != null) { generator.writeKey("filter"); this.filter.serialize(generator, mapper); - } + if (this.indexRouting != null) { generator.writeKey("index_routing"); generator.write(this.indexRouting); - } + if (this.isHidden != null) { generator.writeKey("is_hidden"); generator.write(this.isHidden); - } + if (this.isWriteIndex != null) { generator.writeKey("is_write_index"); generator.write(this.isWriteIndex); - } + if (this.routing != null) { generator.writeKey("routing"); generator.write(this.routing); - } + if (this.searchRouting != null) { generator.writeKey("search_routing"); generator.write(this.searchRouting); - } - } // --------------------------------------------------------------------------------------------- @@ -181,23 +191,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link Alias}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Query filter; - @Nullable private String indexRouting; - @Nullable private Boolean isHidden; - @Nullable private Boolean isWriteIndex; - @Nullable private String routing; - @Nullable private String searchRouting; @@ -213,7 +217,7 @@ public final Builder filter(@Nullable Query value) { * API name: {@code filter} */ public final Builder filter(Function> fn) { - return this.filter(fn.apply(new Query.Builder()).build()); + return filter(fn.apply(new Query.Builder()).build()); } /** @@ -225,7 +229,10 @@ public final Builder indexRouting(@Nullable String value) { } /** + * If true, the alias is hidden. All indices for the alias must have the same is_hidden value. + *

* API name: {@code is_hidden} + *

*/ public final Builder isHidden(@Nullable Boolean value) { this.isHidden = value; @@ -233,7 +240,10 @@ public final Builder isHidden(@Nullable Boolean value) { } /** + * If true, the index is the write index for the alias. + *

* API name: {@code is_write_index} + *

*/ public final Builder isWriteIndex(@Nullable Boolean value) { this.isWriteIndex = value; @@ -259,8 +269,7 @@ public final Builder searchRouting(@Nullable String value) { /** * Builds a {@link Alias}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public Alias build() { _checkSingleUse(); @@ -280,14 +289,36 @@ public Alias build() { ); protected static void setupAliasDeserializer(ObjectDeserializer op) { - op.add(Builder::filter, Query._DESERIALIZER, "filter"); op.add(Builder::indexRouting, JsonpDeserializer.stringDeserializer(), "index_routing"); op.add(Builder::isHidden, JsonpDeserializer.booleanDeserializer(), "is_hidden"); op.add(Builder::isWriteIndex, JsonpDeserializer.booleanDeserializer(), "is_write_index"); op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "routing"); op.add(Builder::searchRouting, JsonpDeserializer.stringDeserializer(), "search_routing"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.filter); + result = 31 * result + Objects.hashCode(this.indexRouting); + result = 31 * result + Objects.hashCode(this.isHidden); + result = 31 * result + Objects.hashCode(this.isWriteIndex); + result = 31 * result + Objects.hashCode(this.routing); + result = 31 * result + Objects.hashCode(this.searchRouting); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + Alias other = (Alias) o; + return Objects.equals(this.filter, other.filter) + && Objects.equals(this.indexRouting, other.indexRouting) + && Objects.equals(this.isHidden, other.isHidden) + && Objects.equals(this.isWriteIndex, other.isWriteIndex) + && Objects.equals(this.routing, other.routing) + && Objects.equals(this.searchRouting, other.searchRouting); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/CreateIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/CreateIndexRequest.java similarity index 70% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/CreateIndexRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/CreateIndexRequest.java index 236d52d700..492a2f3931 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/CreateIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/CreateIndexRequest.java @@ -30,12 +30,19 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import jakarta.json.stream.JsonGenerator; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -58,12 +65,18 @@ /** * Creates an index with optional settings and mappings. - * */ @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class CreateIndexRequest extends RequestBase implements PlainJsonSerializable { + + @Nonnull private final Map aliases; + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull private final String index; @Nullable @@ -73,9 +86,6 @@ public class CreateIndexRequest extends RequestBase implements PlainJsonSerializ @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - @Nullable private final IndexSettings settings; @@ -88,46 +98,54 @@ public class CreateIndexRequest extends RequestBase implements PlainJsonSerializ // --------------------------------------------------------------------------------------------- private CreateIndexRequest(Builder builder) { - this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.mappings = builder.mappings; this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.settings = builder.settings; this.timeout = builder.timeout; this.waitForActiveShards = builder.waitForActiveShards; - } - public static CreateIndexRequest of(Function> fn) { + public static CreateIndexRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** + * Aliases for the index. + *

* API name: {@code aliases} + *

*/ + @Nonnull public final Map aliases() { return this.aliases; } /** - * Required - The name of the index + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + /** + * Required - Name of the index you wish to create. *

* API name: {@code index} + *

*/ + @Nonnull public final String index() { return this.index; } /** - * Mapping for fields in the index. If specified, this mapping can include: - *
    - *
  • Field names
  • - *
  • Field data types
  • - *
  • Mapping parameters
  • - *
- *

* API name: {@code mappings} */ @Nullable @@ -136,9 +154,11 @@ public final TypeMapping mappings() { } /** - * Specify timeout for connection to master + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated @Nullable @@ -146,16 +166,6 @@ public final Time masterTimeout() { return this.masterTimeout; } - /** - * Specify timeout for connection to cluster-manager - *

- * API name: {@code cluster_manager_timeout} - */ - @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - /** * API name: {@code settings} */ @@ -165,9 +175,10 @@ public final IndexSettings settings() { } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ @Nullable public final Time timeout() { @@ -175,9 +186,11 @@ public final Time timeout() { } /** - * Set the number of active shards to wait for before the operation returns. + * The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer + * up to the total number of shards in the index (number_of_replicas+1). *

* API name: {@code wait_for_active_shards} + *

*/ @Nullable public final WaitForActiveShards waitForActiveShards() { @@ -187,6 +200,7 @@ public final WaitForActiveShards waitForActiveShards() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -194,66 +208,57 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.aliases)) { generator.writeKey("aliases"); generator.writeStartObject(); for (Map.Entry item0 : this.aliases.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.mappings != null) { generator.writeKey("mappings"); this.mappings.serialize(generator, mapper); - } + if (this.settings != null) { generator.writeKey("settings"); this.settings.serialize(generator, mapper); - } - } - // --------------------------------------------------------------------------------------------- /** * Builder for {@link CreateIndexRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Map aliases; - + @Nullable + private Time clusterManagerTimeout; private String index; - @Nullable private TypeMapping mappings; - - @Deprecated @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - @Nullable private IndexSettings settings; - @Nullable private Time timeout; - @Nullable private WaitForActiveShards waitForActiveShards; /** + * Aliases for the index. + *

* API name: {@code aliases} + *

+ * *

- * Adds all entries of map to aliases. + * Adds all elements of map to aliases. + *

*/ public final Builder aliases(Map map) { this.aliases = _mapPutAll(this.aliases, map); @@ -261,9 +266,14 @@ public final Builder aliases(Map map) { } /** + * Aliases for the index. + *

* API name: {@code aliases} + *

+ * *

* Adds an entry to aliases. + *

*/ public final Builder aliases(String key, Alias value) { this.aliases = _mapPut(this.aliases, key, value); @@ -271,18 +281,45 @@ public final Builder aliases(String key, Alias value) { } /** + * Aliases for the index. + *

* API name: {@code aliases} + *

+ * *

- * Adds an entry to aliases using a builder lambda. + * Adds a value to aliases using a builder lambda. + *

*/ public final Builder aliases(String key, Function> fn) { return aliases(key, fn.apply(new Alias.Builder()).build()); } /** - * Required - The name of the index + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(@Nullable Time value) { + this.clusterManagerTimeout = value; + return this; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Required - Name of the index you wish to create. *

* API name: {@code index} + *

*/ public final Builder index(String value) { this.index = value; @@ -290,13 +327,6 @@ public final Builder index(String value) { } /** - * Mapping for fields in the index. If specified, this mapping can include: - *
    - *
  • Field names
  • - *
  • Field data types
  • - *
  • Mapping parameters
  • - *
- *

* API name: {@code mappings} */ public final Builder mappings(@Nullable TypeMapping value) { @@ -305,23 +335,18 @@ public final Builder mappings(@Nullable TypeMapping value) { } /** - * Mapping for fields in the index. If specified, this mapping can include: - *

    - *
  • Field names
  • - *
  • Field data types
  • - *
  • Mapping parameters
  • - *
- *

* API name: {@code mappings} */ public final Builder mappings(Function> fn) { - return this.mappings(fn.apply(new TypeMapping.Builder()).build()); + return mappings(fn.apply(new TypeMapping.Builder()).build()); } /** - * Specify timeout for connection to master + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(@Nullable Time value) { @@ -330,32 +355,15 @@ public final Builder masterTimeout(@Nullable Time value) { } /** - * Specify timeout for connection to master + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); - } - - /** - * Specify timeout for connection to cluster-manager - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(@Nullable Time value) { - this.clusterManagerTimeout = value; - return this; - } - - /** - * Specify timeout for connection to cluster-manager - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** @@ -370,13 +378,14 @@ public final Builder settings(@Nullable IndexSettings value) { * API name: {@code settings} */ public final Builder settings(Function> fn) { - return this.settings(fn.apply(new IndexSettings.Builder()).build()); + return settings(fn.apply(new IndexSettings.Builder()).build()); } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ public final Builder timeout(@Nullable Time value) { this.timeout = value; @@ -384,18 +393,21 @@ public final Builder timeout(@Nullable Time value) { } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ public final Builder timeout(Function> fn) { - return this.timeout(fn.apply(new Time.Builder()).build()); + return timeout(fn.apply(new Time.Builder()).build()); } /** - * Set the number of active shards to wait for before the operation returns. + * The number of shard copies that must be active before proceeding with the operation. Set to all or any positive + * integer up to the total number of shards in the index (number_of_replicas+1). *

* API name: {@code wait_for_active_shards} + *

*/ public final Builder waitForActiveShards(@Nullable WaitForActiveShards value) { this.waitForActiveShards = value; @@ -403,19 +415,20 @@ public final Builder waitForActiveShards(@Nullable WaitForActiveShards value) { } /** - * Set the number of active shards to wait for before the operation returns. + * The number of shard copies that must be active before proceeding with the operation. Set to all or any positive + * integer up to the total number of shards in the index (number_of_replicas+1). *

* API name: {@code wait_for_active_shards} + *

*/ public final Builder waitForActiveShards(Function> fn) { - return this.waitForActiveShards(fn.apply(new WaitForActiveShards.Builder()).build()); + return waitForActiveShards(fn.apply(new WaitForActiveShards.Builder()).build()); } /** * Builds a {@link CreateIndexRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public CreateIndexRequest build() { _checkSingleUse(); @@ -435,11 +448,9 @@ public CreateIndexRequest build() { ); protected static void setupCreateIndexRequestDeserializer(ObjectDeserializer op) { - op.add(Builder::aliases, JsonpDeserializer.stringMapDeserializer(Alias._DESERIALIZER), "aliases"); op.add(Builder::mappings, TypeMapping._DESERIALIZER, "mappings"); op.add(Builder::settings, IndexSettings._DESERIALIZER, "settings"); - } // --------------------------------------------------------------------------------------------- @@ -448,51 +459,63 @@ protected static void setupCreateIndexRequestDeserializer(ObjectDeserializer _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "PUT"; - - }, - + request -> "PUT", // Request path request -> { - final int _index = 1 << 0; - - int propsSet = 0; - - propsSet |= _index; - - if (propsSet == (_index)) { - StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index, buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(request.index, buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout._toJsonString()); - } if (request.clusterManagerTimeout != null) { params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); } - if (request.waitForActiveShards != null) { - params.put("wait_for_active_shards", request.waitForActiveShards._toJsonString()); + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } + if (request.waitForActiveShards != null) { + params.put("wait_for_active_shards", request.waitForActiveShards._toJsonString()); + } return params; - }, SimpleEndpoint.emptyMap(), true, CreateIndexResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.aliases); + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + this.index.hashCode(); + result = 31 * result + Objects.hashCode(this.mappings); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + Objects.hashCode(this.settings); + result = 31 * result + Objects.hashCode(this.timeout); + result = 31 * result + Objects.hashCode(this.waitForActiveShards); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + CreateIndexRequest other = (CreateIndexRequest) o; + return Objects.equals(this.aliases, other.aliases) + && Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && this.index.equals(other.index) + && Objects.equals(this.mappings, other.mappings) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && Objects.equals(this.settings, other.settings) + && Objects.equals(this.timeout, other.timeout) + && Objects.equals(this.waitForActiveShards, other.waitForActiveShards); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/CreateIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/CreateIndexResponse.java similarity index 75% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/CreateIndexResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/CreateIndexResponse.java index 1773f5e9e4..d0eab4c802 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/CreateIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/CreateIndexResponse.java @@ -30,11 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import jakarta.json.stream.JsonGenerator; import java.util.function.Function; -import javax.annotation.Nullable; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -48,31 +53,39 @@ // typedef: indices.create.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class CreateIndexResponse implements PlainJsonSerializable { + + private final boolean acknowledged; + + @Nonnull private final String index; private final boolean shardsAcknowledged; - @Nullable - private final Boolean acknowledged; - // --------------------------------------------------------------------------------------------- private CreateIndexResponse(Builder builder) { - + this.acknowledged = ApiTypeHelper.requireNonNull(builder.acknowledged, this, "acknowledged"); this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.shardsAcknowledged = ApiTypeHelper.requireNonNull(builder.shardsAcknowledged, this, "shardsAcknowledged"); - this.acknowledged = builder.acknowledged; - } - public static CreateIndexResponse of(Function> fn) { + public static CreateIndexResponse of(Function> fn) { return fn.apply(new Builder()).build(); } + /** + * Required - API name: {@code acknowledged} + */ + public final boolean acknowledged() { + return this.acknowledged; + } + /** * Required - API name: {@code index} */ + @Nonnull public final String index() { return this.index; } @@ -84,17 +97,10 @@ public final boolean shardsAcknowledged() { return this.shardsAcknowledged; } - /** - * API name: {@code acknowledged} - */ - @Nullable - public final Boolean acknowledged() { - return this.acknowledged; - } - /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -102,19 +108,14 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey("acknowledged"); + generator.write(this.acknowledged); generator.writeKey("index"); generator.write(this.index); generator.writeKey("shards_acknowledged"); generator.write(this.shardsAcknowledged); - - if (this.acknowledged != null) { - generator.writeKey("acknowledged"); - generator.write(this.acknowledged); - - } - } // --------------------------------------------------------------------------------------------- @@ -122,14 +123,18 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link CreateIndexResponse}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Boolean acknowledged; private String index; - private Boolean shardsAcknowledged; - @Nullable - private Boolean acknowledged; + /** + * Required - API name: {@code acknowledged} + */ + public final Builder acknowledged(boolean value) { + this.acknowledged = value; + return this; + } /** * Required - API name: {@code index} @@ -147,19 +152,10 @@ public final Builder shardsAcknowledged(boolean value) { return this; } - /** - * API name: {@code acknowledged} - */ - public final Builder acknowledged(@Nullable Boolean value) { - this.acknowledged = value; - return this; - } - /** * Builds a {@link CreateIndexResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public CreateIndexResponse build() { _checkSingleUse(); @@ -179,11 +175,27 @@ public CreateIndexResponse build() { ); protected static void setupCreateIndexResponseDeserializer(ObjectDeserializer op) { - + op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); op.add(Builder::shardsAcknowledged, JsonpDeserializer.booleanDeserializer(), "shards_acknowledged"); - op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.acknowledged); + result = 31 * result + this.index.hashCode(); + result = 31 * result + Boolean.hashCode(this.shardsAcknowledged); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + CreateIndexResponse other = (CreateIndexResponse) o; + return this.acknowledged == other.acknowledged + && this.index.equals(other.index) + && this.shardsAcknowledged == other.shardsAcknowledged; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexRequest.java similarity index 59% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexRequest.java index c3f7bf09db..016d3edc0d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexRequest.java @@ -30,13 +30,20 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.ExpandWildcard; @@ -52,53 +59,54 @@ /** * Deletes an index. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class DeleteIndexRequest extends RequestBase { + @Nullable private final Boolean allowNoIndices; + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull private final List expandWildcards; @Nullable private final Boolean ignoreUnavailable; + @Nonnull private final List index; @Deprecated @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - @Nullable private final Time timeout; // --------------------------------------------------------------------------------------------- private DeleteIndexRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.ignoreUnavailable = builder.ignoreUnavailable; this.index = ApiTypeHelper.unmodifiableRequired(builder.index, this, "index"); this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.timeout = builder.timeout; - } - public static DeleteIndexRequest of(Function> fn) { + public static DeleteIndexRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Ignore if a wildcard expression resolves to no concrete indices (default: - * false) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets only + * missing or closed indices. This behavior applies even if the request targets other open indices. *

* API name: {@code allow_no_indices} + *

*/ @Nullable public final Boolean allowNoIndices() { @@ -106,19 +114,34 @@ public final Boolean allowNoIndices() { } /** - * Whether wildcard expressions should get expanded to open, closed, or hidden - * indices + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + /** + * Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard + * expressions match hidden data streams. Supports comma-separated values, such as open,hidden. Valid values are: + * all, open, closed, hidden, none. *

* API name: {@code expand_wildcards} + *

*/ + @Nonnull public final List expandWildcards() { return this.expandWildcards; } /** - * Ignore unavailable indexes (default: false) + * If false, the request returns an error if it targets a missing or closed index. *

* API name: {@code ignore_unavailable} + *

*/ @Nullable public final Boolean ignoreUnavailable() { @@ -126,19 +149,24 @@ public final Boolean ignoreUnavailable() { } /** - * Required - A comma-separated list of indices to delete; use _all - * or * string to delete all indices + * Required - Comma-separated list of indices to delete. You cannot specify index aliases. By default, this parameter does not support + * wildcards (*) or _all. To use wildcards or _all, set the + * action.destructive_requires_name cluster setting to false. *

* API name: {@code index} + *

*/ + @Nonnull public final List index() { return this.index; } /** - * Specify timeout for connection to master + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated @Nullable @@ -147,19 +175,10 @@ public final Time masterTimeout() { } /** - * Specify timeout for connection to cluster-manager - *

- * API name: {@code cluster_manager_timeout} - */ - @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ @Nullable public final Time timeout() { @@ -171,34 +190,27 @@ public final Time timeout() { /** * Builder for {@link DeleteIndexRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Boolean allowNoIndices; - + @Nullable + private Time clusterManagerTimeout; @Nullable private List expandWildcards; - @Nullable private Boolean ignoreUnavailable; - private List index; - - @Deprecated @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - @Nullable private Time timeout; /** - * Ignore if a wildcard expression resolves to no concrete indices (default: - * false) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets + * only missing or closed indices. This behavior applies even if the request targets other open indices. *

* API name: {@code allow_no_indices} + *

*/ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; @@ -206,12 +218,37 @@ public final Builder allowNoIndices(@Nullable Boolean value) { } /** - * Whether wildcard expressions should get expanded to open, closed, or hidden - * indices + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(@Nullable Time value) { + this.clusterManagerTimeout = value; + return this; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard + * expressions match hidden data streams. Supports comma-separated values, such as open,hidden. Valid values are: + * all, open, closed, hidden, none. *

* API name: {@code expand_wildcards} + *

+ * *

* Adds all elements of list to expandWildcards. + *

*/ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); @@ -219,12 +256,16 @@ public final Builder expandWildcards(List list) { } /** - * Whether wildcard expressions should get expanded to open, closed, or hidden - * indices + * Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard + * expressions match hidden data streams. Supports comma-separated values, such as open,hidden. Valid values are: + * all, open, closed, hidden, none. *

* API name: {@code expand_wildcards} + *

+ * *

* Adds one or more values to expandWildcards. + *

*/ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); @@ -232,9 +273,10 @@ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... val } /** - * Ignore unavailable indexes (default: false) + * If false, the request returns an error if it targets a missing or closed index. *

* API name: {@code ignore_unavailable} + *

*/ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; @@ -242,12 +284,16 @@ public final Builder ignoreUnavailable(@Nullable Boolean value) { } /** - * Required - A comma-separated list of indices to delete; use _all - * or * string to delete all indices + * Required - Comma-separated list of indices to delete. You cannot specify index aliases. By default, this parameter does not + * support wildcards (*) or _all. To use wildcards or _all, set the + * action.destructive_requires_name cluster setting to false. *

* API name: {@code index} + *

+ * *

* Adds all elements of list to index. + *

*/ public final Builder index(List list) { this.index = _listAddAll(this.index, list); @@ -255,12 +301,16 @@ public final Builder index(List list) { } /** - * Required - A comma-separated list of indices to delete; use _all - * or * string to delete all indices + * Required - Comma-separated list of indices to delete. You cannot specify index aliases. By default, this parameter does not + * support wildcards (*) or _all. To use wildcards or _all, set the + * action.destructive_requires_name cluster setting to false. *

* API name: {@code index} + *

+ * *

* Adds one or more values to index. + *

*/ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); @@ -268,9 +318,11 @@ public final Builder index(String value, String... values) { } /** - * Specify timeout for connection to master + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(@Nullable Time value) { @@ -279,38 +331,22 @@ public final Builder masterTimeout(@Nullable Time value) { } /** - * Specify timeout for connection to master + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); - } - - /** - * Specify timeout for connection to cluster-manager - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(@Nullable Time value) { - this.clusterManagerTimeout = value; - return this; - } - - /** - * Specify timeout for connection to cluster-manager - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ public final Builder timeout(@Nullable Time value) { this.timeout = value; @@ -318,19 +354,19 @@ public final Builder timeout(@Nullable Time value) { } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ public final Builder timeout(Function> fn) { - return this.timeout(fn.apply(new Time.Builder()).build()); + return timeout(fn.apply(new Time.Builder()).build()); } /** * Builds a {@link DeleteIndexRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public DeleteIndexRequest build() { _checkSingleUse(); @@ -345,36 +381,20 @@ public DeleteIndexRequest build() { * Endpoint "{@code indices.delete}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "DELETE"; - - }, - + request -> "DELETE", // Request path request -> { - final int _index = 1 << 0; - - int propsSet = 0; - - propsSet |= _index; - - if (propsSet == (_index)) { - StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout._toJsonString()); + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.clusterManagerTimeout != null) { params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); @@ -385,17 +405,43 @@ public DeleteIndexRequest build() { if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } - if (request.allowNoIndices != null) { - params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } return params; - }, SimpleEndpoint.emptyMap(), false, DeleteIndexResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allowNoIndices); + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.expandWildcards); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + this.index.hashCode(); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + Objects.hashCode(this.timeout); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + DeleteIndexRequest other = (DeleteIndexRequest) o; + return Objects.equals(this.allowNoIndices, other.allowNoIndices) + && Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.expandWildcards, other.expandWildcards) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && this.index.equals(other.index) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && Objects.equals(this.timeout, other.timeout); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexResponse.java similarity index 77% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexResponse.java index 27bb751b42..1ddf2f9b6b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexResponse.java @@ -30,9 +30,14 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; @@ -43,15 +48,16 @@ // typedef: indices.delete.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class DeleteIndexResponse extends IndicesResponseBase { + // --------------------------------------------------------------------------------------------- private DeleteIndexResponse(Builder builder) { super(builder); - } - public static DeleteIndexResponse of(Function> fn) { + public static DeleteIndexResponse of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -60,8 +66,8 @@ public static DeleteIndexResponse of(Function implements ObjectBuilder { + @Override protected Builder self() { return this; @@ -70,8 +76,7 @@ protected Builder self() { /** * Builds a {@link DeleteIndexResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public DeleteIndexResponse build() { _checkSingleUse(); @@ -91,8 +96,22 @@ public DeleteIndexResponse build() { ); protected static void setupDeleteIndexResponseDeserializer(ObjectDeserializer op) { - IndicesResponseBase.setupIndicesResponseBaseDeserializer(op); + setupIndicesResponseBaseDeserializer(op); + } + @Override + public int hashCode() { + int result = super.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ExistsRequest.java similarity index 57% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/ExistsRequest.java index 5cd06ef799..0edbe4fd89 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ExistsRequest.java @@ -30,17 +30,25 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.ExpandWildcard; import org.opensearch.client.opensearch._types.RequestBase; +import org.opensearch.client.opensearch._types.Time; import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.BooleanEndpoint; import org.opensearch.client.transport.endpoints.BooleanResponse; @@ -53,13 +61,17 @@ /** * Returns information about whether a particular index exists. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class ExistsRequest extends RequestBase { + @Nullable private final Boolean allowNoIndices; + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull private final List expandWildcards; @Nullable @@ -71,6 +83,7 @@ public class ExistsRequest extends RequestBase { @Nullable private final Boolean includeDefaults; + @Nonnull private final List index; @Nullable @@ -79,26 +92,26 @@ public class ExistsRequest extends RequestBase { // --------------------------------------------------------------------------------------------- private ExistsRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.flatSettings = builder.flatSettings; this.ignoreUnavailable = builder.ignoreUnavailable; this.includeDefaults = builder.includeDefaults; this.index = ApiTypeHelper.unmodifiableRequired(builder.index, this, "index"); this.local = builder.local; - } - public static ExistsRequest of(Function> fn) { + public static ExistsRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Ignore if a wildcard expression resolves to no concrete indices (default: - * false) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets only + * missing or closed indices. This behavior applies even if the request targets other open indices. *

* API name: {@code allow_no_indices} + *

*/ @Nullable public final Boolean allowNoIndices() { @@ -106,19 +119,34 @@ public final Boolean allowNoIndices() { } /** - * Whether wildcard expressions should get expanded to open or closed indices - * (default: open) + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + /** + * Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard + * expressions match hidden data streams. Supports comma-separated values, such as open,hidden. Valid values are: + * all, open, closed, hidden, none. *

* API name: {@code expand_wildcards} + *

*/ + @Nonnull public final List expandWildcards() { return this.expandWildcards; } /** - * Return settings in flat format (default: false) + * If true, returns settings in flat format. *

* API name: {@code flat_settings} + *

*/ @Nullable public final Boolean flatSettings() { @@ -126,9 +154,10 @@ public final Boolean flatSettings() { } /** - * Ignore unavailable indexes (default: false) + * If false, the request returns an error if it targets a missing or closed index. *

* API name: {@code ignore_unavailable} + *

*/ @Nullable public final Boolean ignoreUnavailable() { @@ -136,9 +165,10 @@ public final Boolean ignoreUnavailable() { } /** - * Whether to return all default setting for each of the indices. + * If true, return all default settings in the response. *

* API name: {@code include_defaults} + *

*/ @Nullable public final Boolean includeDefaults() { @@ -146,19 +176,21 @@ public final Boolean includeDefaults() { } /** - * Required - A comma-separated list of index names + * Required - Comma-separated list of data streams, indices, and aliases. Supports wildcards (*). *

* API name: {@code index} + *

*/ + @Nonnull public final List index() { return this.index; } /** - * Return local information, do not retrieve the state from cluster-manager node - * (default: false) + * If true, the request retrieves information from the local node only. *

* API name: {@code local} + *

*/ @Nullable public final Boolean local() { @@ -170,33 +202,29 @@ public final Boolean local() { /** * Builder for {@link ExistsRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Boolean allowNoIndices; - + @Nullable + private Time clusterManagerTimeout; @Nullable private List expandWildcards; - @Nullable private Boolean flatSettings; - @Nullable private Boolean ignoreUnavailable; - @Nullable private Boolean includeDefaults; - private List index; - @Nullable private Boolean local; /** - * Ignore if a wildcard expression resolves to no concrete indices (default: - * false) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets + * only missing or closed indices. This behavior applies even if the request targets other open indices. *

* API name: {@code allow_no_indices} + *

*/ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; @@ -204,12 +232,37 @@ public final Builder allowNoIndices(@Nullable Boolean value) { } /** - * Whether wildcard expressions should get expanded to open or closed indices - * (default: open) + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(@Nullable Time value) { + this.clusterManagerTimeout = value; + return this; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard + * expressions match hidden data streams. Supports comma-separated values, such as open,hidden. Valid values are: + * all, open, closed, hidden, none. *

* API name: {@code expand_wildcards} + *

+ * *

* Adds all elements of list to expandWildcards. + *

*/ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); @@ -217,12 +270,16 @@ public final Builder expandWildcards(List list) { } /** - * Whether wildcard expressions should get expanded to open or closed indices - * (default: open) + * Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard + * expressions match hidden data streams. Supports comma-separated values, such as open,hidden. Valid values are: + * all, open, closed, hidden, none. *

* API name: {@code expand_wildcards} + *

+ * *

* Adds one or more values to expandWildcards. + *

*/ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); @@ -230,9 +287,10 @@ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... val } /** - * Return settings in flat format (default: false) + * If true, returns settings in flat format. *

* API name: {@code flat_settings} + *

*/ public final Builder flatSettings(@Nullable Boolean value) { this.flatSettings = value; @@ -240,9 +298,10 @@ public final Builder flatSettings(@Nullable Boolean value) { } /** - * Ignore unavailable indexes (default: false) + * If false, the request returns an error if it targets a missing or closed index. *

* API name: {@code ignore_unavailable} + *

*/ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; @@ -250,9 +309,10 @@ public final Builder ignoreUnavailable(@Nullable Boolean value) { } /** - * Whether to return all default setting for each of the indices. + * If true, return all default settings in the response. *

* API name: {@code include_defaults} + *

*/ public final Builder includeDefaults(@Nullable Boolean value) { this.includeDefaults = value; @@ -260,11 +320,14 @@ public final Builder includeDefaults(@Nullable Boolean value) { } /** - * Required - A comma-separated list of index names + * Required - Comma-separated list of data streams, indices, and aliases. Supports wildcards (*). *

* API name: {@code index} + *

+ * *

* Adds all elements of list to index. + *

*/ public final Builder index(List list) { this.index = _listAddAll(this.index, list); @@ -272,11 +335,14 @@ public final Builder index(List list) { } /** - * Required - A comma-separated list of index names + * Required - Comma-separated list of data streams, indices, and aliases. Supports wildcards (*). *

* API name: {@code index} + *

+ * *

* Adds one or more values to index. + *

*/ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); @@ -284,10 +350,10 @@ public final Builder index(String value, String... values) { } /** - * Return local information, do not retrieve the state from cluster-manager node - * (default: false) + * If true, the request retrieves information from the local node only. *

* API name: {@code local} + *

*/ public final Builder local(@Nullable Boolean value) { this.local = value; @@ -297,8 +363,7 @@ public final Builder local(@Nullable Boolean value) { /** * Builds a {@link ExistsRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public ExistsRequest build() { _checkSingleUse(); @@ -313,47 +378,33 @@ public ExistsRequest build() { * Endpoint "{@code indices.exists}". */ public static final Endpoint _ENDPOINT = new BooleanEndpoint<>( - "opensearch/indices.exists", - // Request method - request -> { - return "HEAD"; - - }, - + request -> "HEAD", // Request path request -> { - final int _index = 1 << 0; - - int propsSet = 0; - - propsSet |= _index; - - if (propsSet == (_index)) { - StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.flatSettings != null) { - params.put("flat_settings", String.valueOf(request.flatSettings)); + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); + } + if (request.clusterManagerTimeout != null) { + params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } + if (request.flatSettings != null) { + params.put("flat_settings", String.valueOf(request.flatSettings)); + } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } - if (request.allowNoIndices != null) { - params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); - } if (request.includeDefaults != null) { params.put("include_defaults", String.valueOf(request.includeDefaults)); } @@ -361,10 +412,36 @@ public ExistsRequest build() { params.put("local", String.valueOf(request.local)); } return params; - }, - SimpleEndpoint.emptyMap(), - false, - null + SimpleEndpoint.emptyMap() ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allowNoIndices); + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.expandWildcards); + result = 31 * result + Objects.hashCode(this.flatSettings); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + Objects.hashCode(this.includeDefaults); + result = 31 * result + this.index.hashCode(); + result = 31 * result + Objects.hashCode(this.local); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + ExistsRequest other = (ExistsRequest) o; + return Objects.equals(this.allowNoIndices, other.allowNoIndices) + && Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.expandWildcards, other.expandWildcards) + && Objects.equals(this.flatSettings, other.flatSettings) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.includeDefaults, other.includeDefaults) + && this.index.equals(other.index) + && Objects.equals(this.local, other.local); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java similarity index 70% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java index 4049613f69..a30b95e2f5 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexRequest.java @@ -30,13 +30,20 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.ExpandWildcard; @@ -52,13 +59,17 @@ /** * Returns information about one or more indices. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetIndexRequest extends RequestBase { + @Nullable private final Boolean allowNoIndices; + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull private final List expandWildcards; @Nullable @@ -70,6 +81,7 @@ public class GetIndexRequest extends RequestBase { @Nullable private final Boolean includeDefaults; + @Nonnull private final List index; @Nullable @@ -79,14 +91,11 @@ public class GetIndexRequest extends RequestBase { @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - // --------------------------------------------------------------------------------------------- private GetIndexRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.flatSettings = builder.flatSettings; this.ignoreUnavailable = builder.ignoreUnavailable; @@ -94,19 +103,19 @@ private GetIndexRequest(Builder builder) { this.index = ApiTypeHelper.unmodifiableRequired(builder.index, this, "index"); this.local = builder.local; this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - } - public static GetIndexRequest of(Function> fn) { + public static GetIndexRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Ignore if a wildcard expression resolves to no concrete indices (default: - * false) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. + * This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if + * an index starts with foo but no index starts with bar. *

* API name: {@code allow_no_indices} + *

*/ @Nullable public final Boolean allowNoIndices() { @@ -114,12 +123,24 @@ public final Boolean allowNoIndices() { } /** - * Type of index that wildcard expressions can match. If the request can target - * data streams, this argument determines whether wildcard expressions match - * hidden data streams. Supports comma-separated values, such as open,hidden. + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + /** + * Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether wildcard + * expressions match hidden data streams. Supports comma-separated values, such as open,hidden. *

* API name: {@code expand_wildcards} + *

*/ + @Nonnull public final List expandWildcards() { return this.expandWildcards; } @@ -128,6 +149,7 @@ public final List expandWildcards() { * If true, returns settings in flat format. *

* API name: {@code flat_settings} + *

*/ @Nullable public final Boolean flatSettings() { @@ -138,6 +160,7 @@ public final Boolean flatSettings() { * If false, requests that target a missing index return an error. *

* API name: {@code ignore_unavailable} + *

*/ @Nullable public final Boolean ignoreUnavailable() { @@ -148,6 +171,7 @@ public final Boolean ignoreUnavailable() { * If true, return all default settings in the response. *

* API name: {@code include_defaults} + *

*/ @Nullable public final Boolean includeDefaults() { @@ -155,20 +179,23 @@ public final Boolean includeDefaults() { } /** - * Required - Comma-separated list of data streams, indices, and index aliases - * used to limit the request. Wildcard expressions (*) are supported. + * Required - Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) are + * supported. *

* API name: {@code index} + *

*/ + @Nonnull public final List index() { return this.index; } /** - * If true, the request retrieves information from the local node only. Defaults - * to false, which means information is retrieved from the cluster-manager node. + * If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the + * master node. *

* API name: {@code local} + *

*/ @Nullable public final Boolean local() { @@ -176,10 +203,11 @@ public final Boolean local() { } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated @Nullable @@ -187,56 +215,37 @@ public final Time masterTimeout() { return this.masterTimeout; } - /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. - *

- * API name: {@code cluster_manager_timeout} - */ - @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - // --------------------------------------------------------------------------------------------- /** * Builder for {@link GetIndexRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Boolean allowNoIndices; - + @Nullable + private Time clusterManagerTimeout; @Nullable private List expandWildcards; - @Nullable private Boolean flatSettings; - @Nullable private Boolean ignoreUnavailable; - @Nullable private Boolean includeDefaults; - private List index; - @Nullable private Boolean local; - - @Deprecated @Nullable private Time masterTimeout; - @Nullable - private Time clusterManagerTimeout; - /** - * Ignore if a wildcard expression resolves to no concrete indices (default: - * false) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed + * indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns + * an error if an index starts with foo but no index starts with bar. *

* API name: {@code allow_no_indices} + *

*/ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; @@ -244,13 +253,36 @@ public final Builder allowNoIndices(@Nullable Boolean value) { } /** - * Type of index that wildcard expressions can match. If the request can target - * data streams, this argument determines whether wildcard expressions match - * hidden data streams. Supports comma-separated values, such as open,hidden. + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(@Nullable Time value) { + this.clusterManagerTimeout = value; + return this; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether + * wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden. *

* API name: {@code expand_wildcards} + *

+ * *

* Adds all elements of list to expandWildcards. + *

*/ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); @@ -258,13 +290,15 @@ public final Builder expandWildcards(List list) { } /** - * Type of index that wildcard expressions can match. If the request can target - * data streams, this argument determines whether wildcard expressions match - * hidden data streams. Supports comma-separated values, such as open,hidden. + * Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether + * wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden. *

* API name: {@code expand_wildcards} + *

+ * *

* Adds one or more values to expandWildcards. + *

*/ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); @@ -275,6 +309,7 @@ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... val * If true, returns settings in flat format. *

* API name: {@code flat_settings} + *

*/ public final Builder flatSettings(@Nullable Boolean value) { this.flatSettings = value; @@ -285,6 +320,7 @@ public final Builder flatSettings(@Nullable Boolean value) { * If false, requests that target a missing index return an error. *

* API name: {@code ignore_unavailable} + *

*/ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; @@ -295,6 +331,7 @@ public final Builder ignoreUnavailable(@Nullable Boolean value) { * If true, return all default settings in the response. *

* API name: {@code include_defaults} + *

*/ public final Builder includeDefaults(@Nullable Boolean value) { this.includeDefaults = value; @@ -302,12 +339,15 @@ public final Builder includeDefaults(@Nullable Boolean value) { } /** - * Required - Comma-separated list of data streams, indices, and index aliases - * used to limit the request. Wildcard expressions (*) are supported. + * Required - Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) + * are supported. *

* API name: {@code index} + *

+ * *

* Adds all elements of list to index. + *

*/ public final Builder index(List list) { this.index = _listAddAll(this.index, list); @@ -315,12 +355,15 @@ public final Builder index(List list) { } /** - * Required - Comma-separated list of data streams, indices, and index aliases - * used to limit the request. Wildcard expressions (*) are supported. + * Required - Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) + * are supported. *

* API name: {@code index} + *

+ * *

* Adds one or more values to index. + *

*/ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); @@ -328,10 +371,11 @@ public final Builder index(String value, String... values) { } /** - * If true, the request retrieves information from the local node only. Defaults - * to false, which means information is retrieved from the cluster-manager node. + * If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from + * the master node. *

* API name: {@code local} + *

*/ public final Builder local(@Nullable Boolean value) { this.local = value; @@ -339,10 +383,11 @@ public final Builder local(@Nullable Boolean value) { } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(@Nullable Time value) { @@ -351,42 +396,21 @@ public final Builder masterTimeout(@Nullable Time value) { } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); - } - - /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(@Nullable Time value) { - this.clusterManagerTimeout = value; - return this; - } - - /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** * Builds a {@link GetIndexRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public GetIndexRequest build() { _checkSingleUse(); @@ -401,63 +425,77 @@ public GetIndexRequest build() { * Endpoint "{@code indices.get}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "GET"; - - }, - + request -> "GET", // Request path request -> { - final int _index = 1 << 0; - - int propsSet = 0; - - propsSet |= _index; - - if (propsSet == (_index)) { - StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout._toJsonString()); + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.clusterManagerTimeout != null) { params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); } - if (request.flatSettings != null) { - params.put("flat_settings", String.valueOf(request.flatSettings)); - } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } + if (request.flatSettings != null) { + params.put("flat_settings", String.valueOf(request.flatSettings)); + } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } - if (request.allowNoIndices != null) { - params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); - } if (request.includeDefaults != null) { params.put("include_defaults", String.valueOf(request.includeDefaults)); } if (request.local != null) { params.put("local", String.valueOf(request.local)); } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } return params; - }, SimpleEndpoint.emptyMap(), false, GetIndexResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allowNoIndices); + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.expandWildcards); + result = 31 * result + Objects.hashCode(this.flatSettings); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + Objects.hashCode(this.includeDefaults); + result = 31 * result + this.index.hashCode(); + result = 31 * result + Objects.hashCode(this.local); + result = 31 * result + Objects.hashCode(this.masterTimeout); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + GetIndexRequest other = (GetIndexRequest) o; + return Objects.equals(this.allowNoIndices, other.allowNoIndices) + && Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.expandWildcards, other.expandWildcards) + && Objects.equals(this.flatSettings, other.flatSettings) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.includeDefaults, other.includeDefaults) + && this.index.equals(other.index) + && Objects.equals(this.local, other.local) + && Objects.equals(this.masterTimeout, other.masterTimeout); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java similarity index 84% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java index 5cd71afc55..cc79d9cbda 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexResponse.java @@ -30,9 +30,14 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; @@ -43,15 +48,15 @@ // typedef: indices.get.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetIndexResponse extends DictionaryResponse { // --------------------------------------------------------------------------------------------- private GetIndexResponse(Builder builder) { super(builder); - } - public static GetIndexResponse of(Function> fn) { + public static GetIndexResponse of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -60,7 +65,6 @@ public static GetIndexResponse of(Function implements ObjectBuilder { @@ -72,8 +76,7 @@ protected Builder self() { /** * Builds a {@link GetIndexResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public GetIndexResponse build() { _checkSingleUse(); @@ -95,8 +98,6 @@ public GetIndexResponse build() { ); protected static void setupGetIndexResponseDeserializer(ObjectDeserializer op) { - DictionaryResponse.setupDictionaryResponseDeserializer(op, JsonpDeserializer.stringDeserializer(), IndexState._DESERIALIZER); - + setupDictionaryResponseDeserializer(op, JsonpDeserializer.stringDeserializer(), IndexState._DESERIALIZER); } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexState.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexState.java similarity index 81% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexState.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexState.java index d24e42858c..da4c86fbf1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexState.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexState.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import jakarta.json.stream.JsonGenerator; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -47,85 +54,85 @@ import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: indices._types.IndexState +// typedef: indices.IndexState @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class IndexState implements PlainJsonSerializable { + + @Nonnull private final Map aliases; @Nullable - private final TypeMapping mappings; + private final String dataStream; @Nullable - private final IndexSettings settings; + private final IndexSettings defaults; @Nullable - private final IndexSettings defaults; + private final TypeMapping mappings; @Nullable - private final String dataStream; + private final IndexSettings settings; // --------------------------------------------------------------------------------------------- private IndexState(Builder builder) { - this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); + this.dataStream = builder.dataStream; + this.defaults = builder.defaults; this.mappings = builder.mappings; this.settings = builder.settings; - this.defaults = builder.defaults; - this.dataStream = builder.dataStream; - } - public static IndexState of(Function> fn) { + public static IndexState of(Function> fn) { return fn.apply(new Builder()).build(); } /** * API name: {@code aliases} */ + @Nonnull public final Map aliases() { return this.aliases; } /** - * API name: {@code mappings} + * API name: {@code data_stream} */ @Nullable - public final TypeMapping mappings() { - return this.mappings; + public final String dataStream() { + return this.dataStream; } /** - * API name: {@code settings} + * API name: {@code defaults} */ @Nullable - public final IndexSettings settings() { - return this.settings; + public final IndexSettings defaults() { + return this.defaults; } /** - * Default settings, included when the request's include_default is - * true. - *

- * API name: {@code defaults} + * API name: {@code mappings} */ @Nullable - public final IndexSettings defaults() { - return this.defaults; + public final TypeMapping mappings() { + return this.mappings; } /** - * API name: {@code data_stream} + * API name: {@code settings} */ @Nullable - public final String dataStream() { - return this.dataStream; + public final IndexSettings settings() { + return this.settings; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -133,39 +140,35 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.aliases)) { generator.writeKey("aliases"); generator.writeStartObject(); for (Map.Entry item0 : this.aliases.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); - } generator.writeEnd(); - } - if (this.mappings != null) { - generator.writeKey("mappings"); - this.mappings.serialize(generator, mapper); + if (this.dataStream != null) { + generator.writeKey("data_stream"); + generator.write(this.dataStream); } - if (this.settings != null) { - generator.writeKey("settings"); - this.settings.serialize(generator, mapper); - } if (this.defaults != null) { generator.writeKey("defaults"); this.defaults.serialize(generator, mapper); - } - if (this.dataStream != null) { - generator.writeKey("data_stream"); - generator.write(this.dataStream); + if (this.mappings != null) { + generator.writeKey("mappings"); + this.mappings.serialize(generator, mapper); } + if (this.settings != null) { + generator.writeKey("settings"); + this.settings.serialize(generator, mapper); + } } // --------------------------------------------------------------------------------------------- @@ -173,27 +176,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link IndexState}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Map aliases; - @Nullable - private TypeMapping mappings; - - @Nullable - private IndexSettings settings; - + private String dataStream; @Nullable private IndexSettings defaults; - @Nullable - private String dataStream; + private TypeMapping mappings; + @Nullable + private IndexSettings settings; /** * API name: {@code aliases} + * *

- * Adds all entries of map to aliases. + * Adds all elements of map to aliases. + *

*/ public final Builder aliases(Map map) { this.aliases = _mapPutAll(this.aliases, map); @@ -202,8 +202,10 @@ public final Builder aliases(Map map) { /** * API name: {@code aliases} + * *

* Adds an entry to aliases. + *

*/ public final Builder aliases(String key, Alias value) { this.aliases = _mapPut(this.aliases, key, value); @@ -212,77 +214,72 @@ public final Builder aliases(String key, Alias value) { /** * API name: {@code aliases} + * *

- * Adds an entry to aliases using a builder lambda. + * Adds a value to aliases using a builder lambda. + *

*/ public final Builder aliases(String key, Function> fn) { return aliases(key, fn.apply(new Alias.Builder()).build()); } /** - * API name: {@code mappings} + * API name: {@code data_stream} */ - public final Builder mappings(@Nullable TypeMapping value) { - this.mappings = value; + public final Builder dataStream(@Nullable String value) { + this.dataStream = value; return this; } /** - * API name: {@code mappings} + * API name: {@code defaults} */ - public final Builder mappings(Function> fn) { - return this.mappings(fn.apply(new TypeMapping.Builder()).build()); + public final Builder defaults(@Nullable IndexSettings value) { + this.defaults = value; + return this; } /** - * API name: {@code settings} + * API name: {@code defaults} */ - public final Builder settings(@Nullable IndexSettings value) { - this.settings = value; - return this; + public final Builder defaults(Function> fn) { + return defaults(fn.apply(new IndexSettings.Builder()).build()); } /** - * API name: {@code settings} + * API name: {@code mappings} */ - public final Builder settings(Function> fn) { - return this.settings(fn.apply(new IndexSettings.Builder()).build()); + public final Builder mappings(@Nullable TypeMapping value) { + this.mappings = value; + return this; } /** - * Default settings, included when the request's include_default is - * true. - *

- * API name: {@code defaults} + * API name: {@code mappings} */ - public final Builder defaults(@Nullable IndexSettings value) { - this.defaults = value; - return this; + public final Builder mappings(Function> fn) { + return mappings(fn.apply(new TypeMapping.Builder()).build()); } /** - * Default settings, included when the request's include_default is - * true. - *

- * API name: {@code defaults} + * API name: {@code settings} */ - public final Builder defaults(Function> fn) { - return this.defaults(fn.apply(new IndexSettings.Builder()).build()); + public final Builder settings(@Nullable IndexSettings value) { + this.settings = value; + return this; } /** - * API name: {@code data_stream} + * API name: {@code settings} */ - public final Builder dataStream(@Nullable String value) { - this.dataStream = value; - return this; + public final Builder settings(Function> fn) { + return settings(fn.apply(new IndexSettings.Builder()).build()); } /** * Builds a {@link IndexState}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public IndexState build() { _checkSingleUse(); @@ -302,13 +299,33 @@ public IndexState build() { ); protected static void setupIndexStateDeserializer(ObjectDeserializer op) { - op.add(Builder::aliases, JsonpDeserializer.stringMapDeserializer(Alias._DESERIALIZER), "aliases"); + op.add(Builder::dataStream, JsonpDeserializer.stringDeserializer(), "data_stream"); + op.add(Builder::defaults, IndexSettings._DESERIALIZER, "defaults"); op.add(Builder::mappings, TypeMapping._DESERIALIZER, "mappings"); op.add(Builder::settings, IndexSettings._DESERIALIZER, "settings"); - op.add(Builder::defaults, IndexSettings._DESERIALIZER, "defaults"); - op.add(Builder::dataStream, JsonpDeserializer.stringDeserializer(), "data_stream"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.aliases); + result = 31 * result + Objects.hashCode(this.dataStream); + result = 31 * result + Objects.hashCode(this.defaults); + result = 31 * result + Objects.hashCode(this.mappings); + result = 31 * result + Objects.hashCode(this.settings); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndexState other = (IndexState) o; + return Objects.equals(this.aliases, other.aliases) + && Objects.equals(this.dataStream, other.dataStream) + && Objects.equals(this.defaults, other.defaults) + && Objects.equals(this.mappings, other.mappings) + && Objects.equals(this.settings, other.settings); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java new file mode 100644 index 0000000000..7aef6e75e3 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java @@ -0,0 +1,137 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.indices; + +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.transport.endpoints.BooleanResponse; +import org.opensearch.client.util.ObjectBuilder; + +/** + * Client for the indices namespace. + */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public abstract class OpenSearchIndicesAsyncClientBase> extends ApiClient< + OpenSearchTransport, + Self> { + public OpenSearchIndicesAsyncClientBase(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + // ----- Endpoint: indices.create + + /** + * Creates an index with optional settings and mappings. + */ + public CompletableFuture create(CreateIndexRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, CreateIndexRequest._ENDPOINT, this.transportOptions); + } + + /** + * Creates an index with optional settings and mappings. + * + * @param fn a function that initializes a builder to create the {@link CreateIndexRequest} + */ + public final CompletableFuture create(Function> fn) + throws IOException, OpenSearchException { + return create(fn.apply(new CreateIndexRequest.Builder()).build()); + } + + // ----- Endpoint: indices.delete + + /** + * Deletes an index. + */ + public CompletableFuture delete(DeleteIndexRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, DeleteIndexRequest._ENDPOINT, this.transportOptions); + } + + /** + * Deletes an index. + * + * @param fn a function that initializes a builder to create the {@link DeleteIndexRequest} + */ + public final CompletableFuture delete(Function> fn) + throws IOException, OpenSearchException { + return delete(fn.apply(new DeleteIndexRequest.Builder()).build()); + } + + // ----- Endpoint: indices.exists + + /** + * Returns information about whether a particular index exists. + */ + public CompletableFuture exists(ExistsRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, ExistsRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about whether a particular index exists. + * + * @param fn a function that initializes a builder to create the {@link ExistsRequest} + */ + public final CompletableFuture exists(Function> fn) + throws IOException, OpenSearchException { + return exists(fn.apply(new ExistsRequest.Builder()).build()); + } + + // ----- Endpoint: indices.get + + /** + * Returns information about one or more indices. + */ + public CompletableFuture get(GetIndexRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, GetIndexRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about one or more indices. + * + * @param fn a function that initializes a builder to create the {@link GetIndexRequest} + */ + public final CompletableFuture get(Function> fn) + throws IOException, OpenSearchException { + return get(fn.apply(new GetIndexRequest.Builder()).build()); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClientBase.java new file mode 100644 index 0000000000..ffd788a06f --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClientBase.java @@ -0,0 +1,136 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.indices; + +import java.io.IOException; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.transport.endpoints.BooleanResponse; +import org.opensearch.client.util.ObjectBuilder; + +/** + * Client for the indices namespace. + */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public abstract class OpenSearchIndicesClientBase> extends ApiClient< + OpenSearchTransport, + Self> { + public OpenSearchIndicesClientBase(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + // ----- Endpoint: indices.create + + /** + * Creates an index with optional settings and mappings. + */ + public CreateIndexResponse create(CreateIndexRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, CreateIndexRequest._ENDPOINT, this.transportOptions); + } + + /** + * Creates an index with optional settings and mappings. + * + * @param fn a function that initializes a builder to create the {@link CreateIndexRequest} + */ + public final CreateIndexResponse create(Function> fn) throws IOException, + OpenSearchException { + return create(fn.apply(new CreateIndexRequest.Builder()).build()); + } + + // ----- Endpoint: indices.delete + + /** + * Deletes an index. + */ + public DeleteIndexResponse delete(DeleteIndexRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, DeleteIndexRequest._ENDPOINT, this.transportOptions); + } + + /** + * Deletes an index. + * + * @param fn a function that initializes a builder to create the {@link DeleteIndexRequest} + */ + public final DeleteIndexResponse delete(Function> fn) throws IOException, + OpenSearchException { + return delete(fn.apply(new DeleteIndexRequest.Builder()).build()); + } + + // ----- Endpoint: indices.exists + + /** + * Returns information about whether a particular index exists. + */ + public BooleanResponse exists(ExistsRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, ExistsRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about whether a particular index exists. + * + * @param fn a function that initializes a builder to create the {@link ExistsRequest} + */ + public final BooleanResponse exists(Function> fn) throws IOException, + OpenSearchException { + return exists(fn.apply(new ExistsRequest.Builder()).build()); + } + + // ----- Endpoint: indices.get + + /** + * Returns information about one or more indices. + */ + public GetIndexResponse get(GetIndexRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, GetIndexRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about one or more indices. + * + * @param fn a function that initializes a builder to create the {@link GetIndexRequest} + */ + public final GetIndexResponse get(Function> fn) throws IOException, + OpenSearchException { + return get(fn.apply(new GetIndexRequest.Builder()).build()); + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java index a0aca846f8..78ffa50708 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java @@ -120,7 +120,6 @@ import org.opensearch.client.opensearch.core.pit.ListAllPitRequest; import org.opensearch.client.opensearch.core.pit.ListAllPitResponse; import org.opensearch.client.opensearch.features.OpenSearchFeaturesAsyncClient; -import org.opensearch.client.opensearch.indices.OpenSearchIndicesAsyncClient; import org.opensearch.client.opensearch.ingest.OpenSearchIngestAsyncClient; import org.opensearch.client.opensearch.nodes.OpenSearchNodesAsyncClient; import org.opensearch.client.opensearch.shutdown.OpenSearchShutdownAsyncClient; @@ -163,10 +162,6 @@ public OpenSearchFeaturesAsyncClient features() { return new OpenSearchFeaturesAsyncClient(this.transport, this.transportOptions); } - public OpenSearchIndicesAsyncClient indices() { - return new OpenSearchIndicesAsyncClient(this.transport, this.transportOptions); - } - public OpenSearchIngestAsyncClient ingest() { return new OpenSearchIngestAsyncClient(this.transport, this.transportOptions); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java index 4327951b80..b783518ab7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java @@ -120,7 +120,6 @@ import org.opensearch.client.opensearch.core.pit.ListAllPitResponse; import org.opensearch.client.opensearch.features.OpenSearchFeaturesClient; import org.opensearch.client.opensearch.generic.OpenSearchGenericClient; -import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient; import org.opensearch.client.opensearch.ingest.OpenSearchIngestClient; import org.opensearch.client.opensearch.nodes.OpenSearchNodesClient; import org.opensearch.client.opensearch.shutdown.OpenSearchShutdownClient; @@ -166,10 +165,6 @@ public OpenSearchFeaturesClient features() { return new OpenSearchFeaturesClient(this.transport, this.transportOptions); } - public OpenSearchIndicesClient indices() { - return new OpenSearchIndicesClient(this.transport, this.transportOptions); - } - public OpenSearchIngestClient ingest() { return new OpenSearchIngestClient(this.transport, this.transportOptions); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/WaitForActiveShardsBuilders.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/WaitForActiveShardsBuilders.java deleted file mode 100644 index ef18bbaa3e..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/WaitForActiveShardsBuilders.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch._types; - -/** - * Builders for {@link WaitForActiveShards} variants. - *

- * Variants option, count are not available here as - * they don't have a dedicated class. Use {@link WaitForActiveShards}'s builder - * for these. - * - */ -public class WaitForActiveShardsBuilders { - private WaitForActiveShardsBuilders() {} - -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsResponse.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsResponse.java deleted file mode 100644 index 1c51f63584..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.indices; - -import org.opensearch.client.json.JsonpDeserializer; - -// typedef: indices.exists.Response - -public class ExistsResponse { - public ExistsResponse() {} - - /** - * Singleton instance for {@link ExistsResponse}. - */ - public static final ExistsResponse _INSTANCE = new ExistsResponse(); - - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.fixedValue(ExistsResponse._INSTANCE); - -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClient.java index d2a4087e40..f90140a6a5 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClient.java @@ -36,7 +36,6 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Function; import javax.annotation.Nullable; -import org.opensearch.client.ApiClient; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.transport.JsonEndpoint; @@ -48,7 +47,7 @@ /** * Client for the indices namespace. */ -public class OpenSearchIndicesAsyncClient extends ApiClient { +public class OpenSearchIndicesAsyncClient extends OpenSearchIndicesAsyncClientBase { public OpenSearchIndicesAsyncClient(OpenSearchTransport transport) { super(transport, null); @@ -249,38 +248,6 @@ public final CompletableFuture close(Function create(CreateIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - CreateIndexRequest, - CreateIndexResponse, - ErrorResponse>) CreateIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Creates an index with optional settings and mappings. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreateIndexRequest} - * - */ - - public final CompletableFuture create(Function> fn) - throws IOException, OpenSearchException { - return create(fn.apply(new CreateIndexRequest.Builder()).build()); - } - // ----- Endpoint: indices.create_data_stream /** @@ -311,38 +278,6 @@ public CompletableFuture createDataStream( return createDataStream(fn.apply(new CreateDataStreamRequest.Builder()).build()); } - // ----- Endpoint: indices.delete - - /** - * Deletes an index. - * - * - */ - - public CompletableFuture delete(DeleteIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteIndexRequest, - DeleteIndexResponse, - ErrorResponse>) DeleteIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Deletes an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteIndexRequest} - * - */ - - public final CompletableFuture delete(Function> fn) - throws IOException, OpenSearchException { - return delete(fn.apply(new DeleteIndexRequest.Builder()).build()); - } - // ----- Endpoint: indices.delete_data_stream /** @@ -507,38 +442,6 @@ public final CompletableFuture diskUsage(Function exists(ExistsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ExistsRequest, - BooleanResponse, - ErrorResponse>) ExistsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a particular index exists. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsRequest} - * - */ - - public final CompletableFuture exists(Function> fn) - throws IOException, OpenSearchException { - return exists(fn.apply(new ExistsRequest.Builder()).build()); - } - // ----- Endpoint: indices.exists_alias /** @@ -726,38 +629,6 @@ public CompletableFuture forcemerge() throws IOException, Op ); } - // ----- Endpoint: indices.get - - /** - * Returns information about one or more indices. - * - * - */ - - public CompletableFuture get(GetIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetIndexRequest, - GetIndexResponse, - ErrorResponse>) GetIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about one or more indices. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetIndexRequest} - * - */ - - public final CompletableFuture get(Function> fn) - throws IOException, OpenSearchException { - return get(fn.apply(new GetIndexRequest.Builder()).build()); - } - // ----- Endpoint: indices.get_data_stream /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClient.java index a3bdd52d4e..85a108f1fb 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClient.java @@ -35,7 +35,6 @@ import java.io.IOException; import java.util.function.Function; import javax.annotation.Nullable; -import org.opensearch.client.ApiClient; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.transport.JsonEndpoint; @@ -47,7 +46,7 @@ /** * Client for the indices namespace. */ -public class OpenSearchIndicesClient extends ApiClient { +public class OpenSearchIndicesClient extends OpenSearchIndicesClientBase { public OpenSearchIndicesClient(OpenSearchTransport transport) { super(transport, null); @@ -236,38 +235,6 @@ public final CloseIndexResponse close(Function endpoint = (JsonEndpoint< - CreateIndexRequest, - CreateIndexResponse, - ErrorResponse>) CreateIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Creates an index with optional settings and mappings. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreateIndexRequest} - * - */ - - public final CreateIndexResponse create(Function> fn) throws IOException, - OpenSearchException { - return create(fn.apply(new CreateIndexRequest.Builder()).build()); - } - // ----- Endpoint: indices.create_data_stream /** @@ -297,38 +264,6 @@ public final CreateDataStreamResponse createDataStream( return createDataStream(fn.apply(new CreateDataStreamRequest.Builder()).build()); } - // ----- Endpoint: indices.delete - - /** - * Deletes an index. - * - * - */ - - public DeleteIndexResponse delete(DeleteIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteIndexRequest, - DeleteIndexResponse, - ErrorResponse>) DeleteIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Deletes an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteIndexRequest} - * - */ - - public final DeleteIndexResponse delete(Function> fn) throws IOException, - OpenSearchException { - return delete(fn.apply(new DeleteIndexRequest.Builder()).build()); - } - // ----- Endpoint: indices.delete_data_stream /** @@ -489,38 +424,6 @@ public final DiskUsageResponse diskUsage(Function endpoint = (JsonEndpoint< - ExistsRequest, - BooleanResponse, - ErrorResponse>) ExistsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a particular index exists. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsRequest} - * - */ - - public final BooleanResponse exists(Function> fn) throws IOException, - OpenSearchException { - return exists(fn.apply(new ExistsRequest.Builder()).build()); - } - // ----- Endpoint: indices.exists_alias /** @@ -702,38 +605,6 @@ public ForcemergeResponse forcemerge() throws IOException, OpenSearchException { return this.transport.performRequest(new ForcemergeRequest.Builder().build(), ForcemergeRequest._ENDPOINT, this.transportOptions); } - // ----- Endpoint: indices.get - - /** - * Returns information about one or more indices. - * - * - */ - - public GetIndexResponse get(GetIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetIndexRequest, - GetIndexResponse, - ErrorResponse>) GetIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about one or more indices. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetIndexRequest} - * - */ - - public final GetIndexResponse get(Function> fn) throws IOException, - OpenSearchException { - return get(fn.apply(new GetIndexRequest.Builder()).build()); - } - // ----- Endpoint: indices.get_data_stream /** diff --git a/java-client/src/main/java/org/opensearch/client/transport/endpoints/BooleanEndpoint.java b/java-client/src/main/java/org/opensearch/client/transport/endpoints/BooleanEndpoint.java index a6969671ac..70200eaab4 100644 --- a/java-client/src/main/java/org/opensearch/client/transport/endpoints/BooleanEndpoint.java +++ b/java-client/src/main/java/org/opensearch/client/transport/endpoints/BooleanEndpoint.java @@ -38,6 +38,15 @@ public class BooleanEndpoint extends SimpleEndpoint { + public BooleanEndpoint( + Function method, + Function requestUrl, + Function> queryParameters, + Function> headers + ) { + super(method, requestUrl, queryParameters, headers, false, null); + } + public BooleanEndpoint( String id, Function method, diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/model/EnumTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/model/EnumTest.java index adbe18465c..e62d4cdf06 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/model/EnumTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/model/EnumTest.java @@ -61,8 +61,8 @@ public void testEnumWithBooleanSupport() { DynamicMapping booleanAsString = fromJson("\"true\"", DynamicMapping.class); assertEquals(booleanAsString, DynamicMapping.True); - DynamicMapping nonBooleanEnumValue = fromJson("\"runtime\"", DynamicMapping.class); - assertEquals(nonBooleanEnumValue, DynamicMapping.Runtime); + DynamicMapping nonBooleanEnumValue = fromJson("\"strict\"", DynamicMapping.class); + assertEquals(nonBooleanEnumValue, DynamicMapping.Strict); DynamicMapping booleanPrimitive = fromJson("false", DynamicMapping.class); assertEquals(booleanPrimitive, DynamicMapping.False); diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index 3f17f3482f..63a088b941 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch API Specification - version: 0.1.0 + version: 0.1.1 x-api-version: 2.16.0 paths: /: @@ -2768,6 +2768,22 @@ paths: responses: '200': $ref: '#/components/responses/ingest.processor_grok@200' + /_insights/top_queries: + get: + operationId: insights.top_queries.0 + x-operation-group: insights.top_queries + x-version-added: '1.0' + description: Retrieves the top queries based on the given metric type (latency, CPU, or memory). + parameters: + - $ref: '#/components/parameters/insights.top_queries::query.type' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/insights.top_queries@200' /_mapping: get: operationId: indices.get_mapping.0 @@ -9171,6 +9187,85 @@ paths: responses: '200': $ref: '#/components/responses/indices.validate_query@200' + /_wlm/query_group: + get: + operationId: wlm.get_query_group.0 + x-operation-group: wlm.get_query_group + x-version-added: '2.17' + description: Gets the specified QueryGroup or get all if no name is provided. + responses: + '200': + $ref: '#/components/responses/wlm.get_query_group@200' + parameters: + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + put: + operationId: wlm.create_query_group.0 + x-operation-group: wlm.create_query_group + x-version-added: '2.17' + description: Creates the specified query group. + requestBody: + $ref: '#/components/requestBodies/wlm.create_query_group' + responses: + '200': + $ref: '#/components/responses/wlm.create_query_group@200' + parameters: + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + /_wlm/query_group/{name}: + delete: + operationId: wlm.delete_query_group.0 + x-operation-group: wlm.delete_query_group + x-version-added: '2.17' + description: Deletes the specified QueryGroup. + parameters: + - $ref: '#/components/parameters/wlm.delete_query_group::path.name' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/wlm.delete_query_group@200' + get: + operationId: wlm.get_query_group.1 + x-operation-group: wlm.get_query_group + x-version-added: '2.17' + description: Gets the specified QueryGroup or get all if no name is provided. + parameters: + - $ref: '#/components/parameters/wlm.get_query_group::path.name' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/wlm.get_query_group@200' + put: + operationId: wlm.update_query_group.0 + x-operation-group: wlm.update_query_group + x-version-added: '2.17' + description: Updates the specified query group. + parameters: + - $ref: '#/components/parameters/wlm.update_query_group::path.name' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/wlm.update_query_group' + responses: + '200': + $ref: '#/components/responses/wlm.update_query_group@200' /{alias}/_rollover: post: operationId: indices.rollover.0 @@ -21197,6 +21292,17 @@ components: type: boolean default: false style: form + insights.top_queries::query.type: + name: type + in: query + required: true + description: Get top n queries by a specific metric. + schema: + type: string + enum: + - cpu + - latency + - memory ism.add_policy::path.index: name: index in: path @@ -25230,6 +25336,27 @@ components: $ref: '#/components/schemas/_common:WaitForActiveShards' style: form x-default: '1' + wlm.delete_query_group::path.name: + name: name + in: path + description: QueryGroup name. + schema: + type: string + required: true + wlm.get_query_group::path.name: + name: name + in: path + description: QueryGroup name. + schema: + type: string + required: true + wlm.update_query_group::path.name: + name: name + in: path + description: QueryGroup name. + schema: + type: string + required: true requestBodies: asynchronous_search.search: content: @@ -26836,6 +26963,18 @@ components: conflicts: $ref: '#/components/schemas/_common:Conflicts' description: The search definition using the Query DSL + wlm.create_query_group: + content: + application/json: + schema: + $ref: '#/components/schemas/wlm._common:QueryGroupCreate' + required: true + wlm.update_query_group: + content: + application/json: + schema: + $ref: '#/components/schemas/wlm._common:QueryGroupUpdate' + required: true responses: asynchronous_search.delete@200: content: @@ -28341,6 +28480,11 @@ components: $ref: '#/components/schemas/ingest.simulate:PipelineSimulation' required: - docs + insights.top_queries@200: + content: + application/json: + schema: + $ref: '#/components/schemas/insights._common:TopQueriesResponse' ism.add_policy@200: content: application/json: @@ -28410,7 +28554,11 @@ components: schema: $ref: '#/components/schemas/ism._common:RetryIndexResponse' knn.delete_model@200: {} - knn.get_model@200: {} + knn.get_model@200: + content: + application/json: + schema: + type: object knn.search_models@200: {} knn.stats@200: {} knn.train_model@200: @@ -29921,6 +30069,38 @@ components: application/json: schema: $ref: '#/components/schemas/_core.update:UpdateWriteResponseBase' + wlm.create_query_group@200: + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/wlm._common:QueryGroupResponse' + wlm.delete_query_group@200: + description: '' + content: + application/json: + schema: + type: object + properties: + acknowledged: + type: boolean + wlm.get_query_group@200: + description: '' + content: + application/json: + schema: + type: object + properties: + query_groups: + type: array + items: + $ref: '#/components/schemas/wlm._common:QueryGroupResponse' + wlm.update_query_group@200: + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/wlm._common:QueryGroupResponse' schemas: _common:AcknowledgedResponseBase: type: object @@ -38644,14 +38824,6 @@ components: type: array items: type: string - mode: - $ref: '#/components/schemas/_common.mapping:SourceFieldMode' - _common.mapping:SourceFieldMode: - type: string - enum: - - disabled - - stored - - synthetic _common.mapping:SparseVectorProperty: allOf: - $ref: '#/components/schemas/_common.mapping:PropertyBase' @@ -38925,6 +39097,13 @@ components: - type: array items: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' + adjust_pure_negative: + description: |- + Ensures correct behavior when a query contains only must_not clauses. + By default set to true, OpenSearch adds a match-all clause to ensure results are returned from Lucene, with the must_not conditions applied as filters. + If set to false, the query may return no results, as Lucene typically requires at least one positive condition. + type: boolean + default: true _common.query_dsl:BoostingQuery: allOf: - $ref: '#/components/schemas/_common.query_dsl:QueryBase' @@ -41667,7 +41846,7 @@ components: type: object properties: k: - description: Sets the maximum number of documents retrieved per query. This value replaces the usual `size` parameter in the query. + description: Sets the maximum number of documents retrieved per query. This value replaces the `size` parameter in the query. type: number _core.rank_eval:RankEvalMetricDetail: type: object @@ -41676,17 +41855,17 @@ components: description: The `metric_score`, found in the `metric_details` section, shows the contribution of this query to the global quality metric score. type: number unrated_docs: - description: The `unrated_docs` section contains an `_index` and `_id` entry for each document that didn't have a ratings value. This can be used to ask the user to supply ratings for these documents. + description: The `unrated_docs` section contains an `_index` and `_id` entry for each document that didn't have a `ratings` value. This can be used to ask the user to supply ratings for these documents. type: array items: $ref: '#/components/schemas/_core.rank_eval:UnratedDocument' hits: - description: The `hits` section shows a grouping of the search results with their supplied ratings + description: The `hits` section provides a grouping of the search results with their supplied ratings. type: array items: $ref: '#/components/schemas/_core.rank_eval:RankEvalHitItem' metric_details: - description: The `metric_details` section gives additional information about the calculated quality metric, in other words, how many of the retrieved documents were relevant. The content varies for each metric but allows for better interpretation of the results. + description: The `metric_details` section provides additional information about the calculated quality metric indicating the number of relevant retrieved documents. The content varies for each metric but allows for better interpretation of the results. type: object additionalProperties: type: object @@ -41703,7 +41882,7 @@ components: - type: object properties: normalize: - description: When `true`, this metric calculates the Normalized DCG (https://en.wikipedia.org/wiki/Discounted_cumulative_gain#Normalized_DCG). + description: When `true`, calculates the [normalized discounted cumulative gain (nDCG)](https://en.wikipedia.org/wiki/Discounted_cumulative_gain#Normalized_DCG). type: boolean _core.rank_eval:RankEvalMetricExpectedReciprocalRank: allOf: @@ -41711,7 +41890,7 @@ components: - type: object properties: maximum_relevance: - description: The highest relevance grade used in the user-supplied relevance judgments. + description: The highest relevance grade used in user-supplied relevance judgments. type: number required: - maximum_relevance @@ -41725,7 +41904,7 @@ components: - type: object properties: ignore_unlabeled: - description: Controls how unlabeled documents in the search results are counted. When `true`, unlabeled documents are ignored and do not count as relevant or irrelevant. When `false`, unlabeled documents are treated as irrelevant. + description: Controls how unlabeled documents in the search results are counted. When `true`, unlabeled documents are ignored and are not treated as relevant or irrelevant. When `false`, unlabeled documents are treated as irrelevant. type: boolean _core.rank_eval:RankEvalMetricRatingThreshold: allOf: @@ -41795,7 +41974,7 @@ components: type: object properties: batches: - description: The number of scroll responses pulled back by the reindex. + description: The number of scroll responses shown by the reindex. type: number created: description: The number of documents that were successfully created. @@ -41804,10 +41983,10 @@ components: description: The number of documents that were successfully deleted. type: number noops: - description: The number of documents that were ignored because the script used for the reindex returned a `noop` value for `ctx.op`. + description: The number of documents that were ignored because the script used for the reindex operation returned a `noop` value for `ctx.op`. type: number requests_per_second: - description: The number of requests per second effectively executed during the reindex. + description: The number of successful requests per second during the reindex operation. type: number retries: $ref: '#/components/schemas/_common:Retries' @@ -41823,7 +42002,7 @@ components: description: The number of documents that were successfully processed. type: number updated: - description: The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex updating it. + description: The number of documents that were successfully updated. type: number version_conflicts: description: The number of version conflicts that reindex hits. @@ -41922,7 +42101,7 @@ components: size: description: |- The number of documents to index per batch. - Use when indexing from remote to ensure that the batches fit within the on-heap buffer, which defaults to a maximum size of 100 MB. + Use the `size` setting when indexing from a remote cluster. This ensures that batches fit in the on-heap buffer. The buffer defaults to a maximum size of `100MB`. type: number slice: $ref: '#/components/schemas/_common:SlicedScroll' @@ -41936,7 +42115,7 @@ components: type: object properties: document: - description: Document that's temporarily indexed in-memory and accessible from the script. + description: A document temporarily indexed in-memory and accessible from the Painless script. type: object index: $ref: '#/components/schemas/_common:IndexName' @@ -42266,14 +42445,14 @@ components: field: $ref: '#/components/schemas/_common:Field' inner_hits: - description: The number of inner hits and their sort order + description: The number of inner hits and their sort order. oneOf: - $ref: '#/components/schemas/_core.search:InnerHits' - type: array items: $ref: '#/components/schemas/_core.search:InnerHits' max_concurrent_group_searches: - description: The number of concurrent requests allowed to retrieve the inner_hits per group + description: The number of concurrent requests that are allowed to be retrieved by the `inner_hits` parameter per group. type: integer required: - field @@ -42307,7 +42486,7 @@ components: boundary_scanner_locale: description: |- Controls which locale is used to search for sentence and word boundaries. - This parameter takes a form of a language tag, for example: `"en-US"`, `"fr-FR"`, `"ja-JP"`. + This parameter takes the form of a language tag, for example, `"en-US"`, `"fr-FR"`, or `"ja-JP"`. type: string force_source: deprecated: true @@ -42328,8 +42507,8 @@ components: max_analyzed_offset: description: |- If set to a non-negative value, highlighting stops at this defined maximum limit. - The rest of the text is not processed, thus not highlighted and no error is returned - The `max_analyzed_offset` query setting does not override the `index.highlight.max_analyzed_offset` setting, which prevails when it's set to lower value than the query setting. + The rest of the text is not processed or highlighted, and no error is returned. + The `max_analyzed_offset` query setting does not override the `index.highlight.max_analyzed_offset` setting, which takes precedence when it is set to a lower value than the query setting. type: integer format: int32 no_match_size: @@ -42339,10 +42518,10 @@ components: number_of_fragments: description: |- The maximum number of fragments to return. - If the number of fragments is set to `0`, no fragments are returned. - Instead, the entire field contents are highlighted and returned. - This can be handy when you need to highlight short texts such as a title or address, but fragmentation is not required. - If `number_of_fragments` is `0`, `fragment_size` is ignored. + When the number of fragments is set to `0`, no fragments are returned. + Instead, the entirety of a field's contents are highlighted and returned. + This is useful when you need to highlight short texts, such as a title or address, in which fragmentation is not required. + If `number_of_fragments` is set to `0`, the `fragment_size` is ignored. type: integer format: int32 options: @@ -42354,21 +42533,21 @@ components: phrase_limit: description: |- Controls the number of matching phrases in a document that are considered. - Prevents the `fvh` highlighter from analyzing too many phrases and consuming too much memory. - When using `matched_fields`, `phrase_limit` phrases per matched field are considered. Raising the limit increases query time and consumes more memory. - Only supported by the `fvh` highlighter. + This prevents the `fvh` highlighter from analyzing too many phrases and consuming too much memory. + When using `matched_fields`, phrase-limited phrases per matched field are considered. Raising the limit increases the query time and consumes more memory. + This setting is only supported by the `fvh` highlighter. type: integer format: int32 post_tags: description: |- - Use in conjunction with `pre_tags` to define the HTML tags to use for the highlighted text. + When used in conjunction with `pre_tags`, defines the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in `` and `` tags. type: array items: type: string pre_tags: description: |- - Use in conjunction with `post_tags` to define the HTML tags to use for the highlighted text. + When used in conjunction with `post_tags`, defines the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in `` and `` tags. type: array items: @@ -42486,7 +42665,7 @@ components: type: object properties: total: - description: Total hit count information, present only if `track_total_hits` wasn't `false` in the search request. + description: The total number of hits, present only if `track_total_hits` is not set to `false` in the search request. oneOf: - $ref: '#/components/schemas/_core.search:TotalHits' - type: integer @@ -42512,7 +42691,7 @@ components: type: integer format: int32 from: - description: Inner hit starting document offset. + description: The inner hit that initiates document offset. type: integer format: int32 collapse: @@ -42723,11 +42902,11 @@ components: rescore_query: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' query_weight: - description: Relative importance of the original query versus the rescore query. + description: The relative importance of the original query as compared to the rescore query. type: number format: float rescore_query_weight: - description: Relative importance of the rescore query versus the original query. + description: The relative importance of the rescore query as compared to the original query. type: number format: float score_mode: @@ -42843,7 +43022,7 @@ components: _core.search:SourceConfigParam: description: |- Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered. - Used as a query parameter along with the `_source_includes` and `_source_excludes` parameters. + Use this setting with the `_source_includes` and `_source_excludes` parameters. oneOf: - type: boolean - $ref: '#/components/schemas/_common:Fields' @@ -42878,7 +43057,7 @@ components: type: object properties: text: - description: Global suggest text, to avoid repetition when the same text is used in several suggesters + description: The global suggest text, which avoids repetition when the same text is used in several suggesters. type: string _core.search:TermSuggest: allOf: @@ -42930,10 +43109,10 @@ components: - gte _core.search:TrackHits: description: |- - Number of hits matching the query to count accurately. If true, the exact - number of hits is returned at the cost of some performance. If false, the + The number of hits matching the query. When `true`, the exact + number of hits is returned at the cost of some performance. When `false`, the response does not include the total number of hits matching the query. - Defaults to 10,000 hits. + Default is `10,000` hits. oneOf: - type: boolean - type: integer @@ -42956,21 +43135,21 @@ components: properties: max_doc_freq: description: |- - Ignore words which occur in more than this many docs. - Defaults to unbounded. + Ignores words that appear in more than the specified number of documents. + Default is `unbounded`. type: number max_num_terms: - description: Maximum number of terms that must be returned per field. + description: The maximum number of terms that should be returned per field. type: number max_term_freq: description: |- Ignore words with more than this frequency in the source doc. - Defaults to unbounded. + Default is `unbounded`. type: number max_word_length: description: |- The maximum word length above which words will be ignored. - Defaults to unbounded. + Default is `unbounded`. type: number min_doc_freq: description: Ignore terms which do not occur in at least this many docs. @@ -50234,6 +50413,225 @@ components: type: string status: $ref: '#/components/schemas/_common:ActionStatusOptions' + insights._common:Measurement: + type: object + properties: + number: + type: integer + count: + type: integer + aggregationType: + type: string + insights._common:Measurements: + type: object + properties: + latency: + type: object + $ref: '#/components/schemas/insights._common:Measurement' + cpu: + type: object + $ref: '#/components/schemas/insights._common:Measurement' + memory: + type: object + $ref: '#/components/schemas/insights._common:Measurement' + insights._common:Source: + type: object + properties: + aggregations: + description: Defines the aggregations that are run as part of the search request. + type: object + collapse: + $ref: '#/components/schemas/_core.search:FieldCollapse' + explain: + description: If true, returns detailed information about score computation as part of a hit. + type: boolean + ext: + description: Configuration of search extensions defined by OpenSearch plugins. + type: object + additionalProperties: + type: object + from: + description: |- + Starting document offset. + Needs to be non-negative. + By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. + To page through more hits, use the `search_after` parameter. + type: number + highlight: + $ref: '#/components/schemas/_core.search:Highlight' + track_total_hits: + $ref: '#/components/schemas/_core.search:TrackHits' + indices_boost: + description: Boosts the _score of documents from specified indices. + type: array + items: + type: object + additionalProperties: + type: number + docvalue_fields: + description: |- + Array of wildcard (`*`) patterns. + The request returns doc values for field names matching these patterns in the `hits.fields` property of the response. + type: array + items: + $ref: '#/components/schemas/_common.query_dsl:FieldAndFormat' + min_score: + description: |- + Minimum `_score` for matching documents. + Documents with a lower `_score` are not included in the search results. + type: number + post_filter: + $ref: '#/components/schemas/_common.query_dsl:QueryContainer' + profile: + description: |- + Set to `true` to return detailed timing information about the execution of individual components in a search request. + NOTE: This is a debugging tool and adds significant overhead to search execution. + type: boolean + query: + $ref: '#/components/schemas/_common.query_dsl:QueryContainer' + script_fields: + description: Retrieve a script evaluation (based on different fields) for each hit. + type: object + additionalProperties: + $ref: '#/components/schemas/_common:ScriptField' + search_after: + $ref: '#/components/schemas/_common:SortResults' + size: + description: |- + The number of hits to return. + By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. + To page through more hits, use the `search_after` parameter. + type: number + slice: + $ref: '#/components/schemas/_common:SlicedScroll' + sort: + $ref: '#/components/schemas/_common:Sort' + _source: + $ref: '#/components/schemas/_core.search:SourceConfig' + fields: + description: |- + Array of wildcard (`*`) patterns. + The request returns values for field names matching these patterns in the `hits.fields` property of the response. + type: array + items: + $ref: '#/components/schemas/_common.query_dsl:FieldAndFormat' + suggest: + $ref: '#/components/schemas/_core.search:Suggester' + terminate_after: + description: |- + Maximum number of documents to collect for each shard. + If a query reaches this limit, OpenSearch terminates the query early. + OpenSearch collects documents before sorting. + Use with caution. + OpenSearch applies this parameter to each shard handling the request. + When possible, let OpenSearch perform early termination automatically. + Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. + If set to `0` (default), the query does not terminate early. + type: integer + format: int32 + timeout: + description: |- + Specifies the period of time to wait for a response from each shard. + If no response is received before the timeout expires, the request fails and returns an error. + Defaults to no timeout. + type: string + track_scores: + description: If true, calculate and return document scores, even if the scores are not used for sorting. + type: boolean + version: + description: If true, returns document version as part of a hit. + type: boolean + seq_no_primary_term: + description: If `true`, returns sequence number and primary term of the last modification of each hit. + type: boolean + stored_fields: + $ref: '#/components/schemas/_common:Fields' + pit: + $ref: '#/components/schemas/_core.search:PointInTimeReference' + stats: + description: |- + Stats groups to associate with the search. + Each group maintains a statistics aggregation for its associated searches. + You can retrieve these stats using the indices stats API. + type: array + items: + type: string + insights._common:TaskResourceUsage: + type: object + properties: + cpu_time_in_nanos: + type: integer + description: The CPU time used in nanoseconds. + memory_in_bytes: + type: integer + description: The memory usage in bytes. + insights._common:TaskResourceUsages: + type: object + properties: + action: + type: string + description: The action type of the task. + taskId: + type: integer + description: The task ID. + parentTaskId: + type: integer + description: The parent task ID. + nodeId: + type: string + description: The node ID where the task was executed. + taskResourceUsage: + type: object + $ref: '#/components/schemas/insights._common:TaskResourceUsage' + insights._common:TopQueriesResponse: + type: object + properties: + top_queries: + type: array + items: + type: object + $ref: '#/components/schemas/insights._common:TopQuery' + required: + - top_queries + insights._common:TopQuery: + type: object + properties: + timestamp: + type: integer + description: The timestamp of the query execution. + total_shards: + type: integer + description: The total number of shards involved in the query. + task_resource_usages: + type: array + items: + type: object + $ref: '#/components/schemas/insights._common:TaskResourceUsages' + query_hashcode: + type: string + description: The hash code of the query. + labels: + type: object + description: Additional labels for the query. + search_type: + type: string + description: The search query type (e.g., query_then_fetch). + source: + type: object + $ref: '#/components/schemas/insights._common:Source' + node_id: + type: string + description: The node ID associated with the query. + indices: + type: array + items: + type: string + description: The indices involved in the query. + phase_latency_map: + type: object + measurements: + type: object + $ref: '#/components/schemas/insights._common:Measurements' ism._common:Action: type: object description: An action to perform. @@ -51775,6 +52173,12 @@ components: $ref: '#/components/schemas/_common:Duration' cumulative_execution_time_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' + nodes._common:RemoteStoreStats: + type: object + properties: + last_successful_fetch_of_pinned_timestamps: + description: Timestamp for the last successful fetch of pinned timestamps. + $ref: '#/components/schemas/_common:StringifiedEpochTimeUnitSeconds' nodes._common:SampleType: type: string description: The type to sample. @@ -52135,6 +52539,8 @@ components: $ref: '#/components/schemas/nodes._common:ShardSearchPipelineStats' segment_replication_backpressure: $ref: '#/components/schemas/nodes._common:ShardSegmentReplicationBackpressureStats' + remote_store: + $ref: '#/components/schemas/nodes._common:RemoteStoreStats' repositories: $ref: '#/components/schemas/nodes._common:ShardRepositoriesStats' admission_control: @@ -55862,3 +56268,104 @@ components: type: array items: $ref: '#/components/schemas/transforms._common:TransformEntity' + wlm._common:QueryGroupCreate: + type: object + properties: + name: + type: string + resiliency_mode: + type: string + enum: + - enforced + - monitor + - soft + resource_limits: + anyOf: + - type: object + properties: + memory: + type: number + format: double + cpu: + type: number + format: double + required: + - memory + - type: object + properties: + memory: + type: number + format: double + cpu: + type: number + format: double + required: + - cpu + required: + - name + - resiliency_mode + - resource_limits + wlm._common:QueryGroupResponse: + type: object + properties: + _id: + type: string + name: + type: string + resiliency_mode: + type: string + enum: + - enforced + - monitor + - soft + updated_at: + type: integer + format: int64 + resource_limits: + anyOf: + - type: object + properties: + memory: + type: number + format: double + cpu: + type: number + format: double + required: + - memory + - type: object + properties: + memory: + type: number + format: double + cpu: + type: number + format: double + required: + - cpu + required: + - _id + - name + - resiliency_mode + - resource_limits + - updated_at + wlm._common:QueryGroupUpdate: + type: object + properties: + resiliency_mode: + type: string + enum: + - enforced + - monitor + - soft + resource_limits: + $ref: '#/components/schemas/wlm._common:ResourceLimitsSchema' + wlm._common:ResourceLimitsSchema: + type: object + properties: + memory: + type: number + format: double + cpu: + type: number + format: double diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java index 70d12db927..7a79aecbe6 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java @@ -43,6 +43,7 @@ public class CodeGenerator { private static final OperationGroupMatcher OPERATION_MATCHER = or( and(namespace(""), named("info")), namespace("dangling_indices"), + and(namespace("indices"), named("create", "delete", "exists", "get")), and(namespace("ml"), not(named("search_models"))), // TODO: search_models is complex and ideally should re-use the search structures and(namespace("snapshot"), named("cleanup_repository", "clone", "verify_repository")), and(namespace("tasks")) diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java index 90a2fae57c..1150a1813f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java @@ -13,7 +13,9 @@ import java.util.List; import java.util.Set; import java.util.TreeMap; +import javax.annotation.Nullable; import org.opensearch.client.codegen.utils.JavaClassKind; +import org.opensearch.client.codegen.utils.Markdown; import org.opensearch.client.codegen.utils.Strings; public class EnumShape extends Shape { @@ -38,14 +40,17 @@ public Collection getImplementsTypes() { return List.of(Types.Client.Json.JsonEnum); } - public void addVariant(String value, boolean deprecated) { + public void addVariant(String value, String description, boolean deprecated) { var variant = variants.get(value.toLowerCase()); if (variant == null) { - variant = new Variant(value, deprecated); + variant = new Variant(value, description, deprecated); variants.put(value.toLowerCase(), variant); } else { variant.addAlias(value); variant.setDeprecated(variant.isDeprecated() || deprecated); + if (description != null) { + variant.setDescription(description); + } } } @@ -61,9 +66,11 @@ public static class Variant { private final String wireName; private final Set aliases = new HashSet<>(); private boolean deprecated; + private String description; - public Variant(String wireName, boolean deprecated) { + public Variant(String wireName, String description, boolean deprecated) { this.wireName = wireName; + setDescription(description); this.deprecated = deprecated; } @@ -71,6 +78,14 @@ public String getWireName() { return wireName; } + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description != null ? Markdown.toJavaDocHtml(description) : null; + } + public Set getAliases() { return aliases; } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java index 3ecac3830d..9caa269bf5 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -21,6 +21,7 @@ public class ObjectShape extends Shape { protected final Map bodyFields = new TreeMap<>(); protected Field additionalPropertiesField; + private String shortcutProperty; public ObjectShape(Namespace parent, String className, String typedefName, String description) { super(parent, className, typedefName, description); @@ -62,6 +63,14 @@ public Field getAdditionalPropertiesField() { return additionalPropertiesField; } + public String getShortcutProperty() { + return shortcutProperty; + } + + public void setShortcutProperty(String shortcutProperty) { + this.shortcutProperty = shortcutProperty; + } + public boolean hasFieldsToSerialize() { return !bodyFields.isEmpty() || additionalPropertiesField != null; } @@ -108,6 +117,10 @@ public Collection getAnnotations() { return (hasFieldsToSerialize() || extendsOtherShape()) && !isAbstract() ? List.of(Types.Client.Json.JsonpDeserializable) : null; } + public boolean shouldImplementPlainDeserializable() { + return Set.of("SourceField", "TypeMapping").contains(getClassName()); + } + public static class ReferencingDiscriminatedUnion { private final TaggedUnionShape union; private final String discriminatorValue; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index f8d270e772..fc351a1156 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -35,6 +35,7 @@ public class RequestShape extends ObjectShape { private final Map pathParams = new TreeMap<>(); @Nonnull private final Map fields = new TreeMap<>(); + private boolean isBooleanRequest; public RequestShape(@Nonnull Namespace parent, @Nonnull OperationGroup operationGroup, @Nullable String description) { super(parent, requestClassName(operationGroup), operationGroup.asTypedefPrefix() + ".Request", description); @@ -72,8 +73,18 @@ public void addSupportedHttpMethod(String method) { httpMethods.add(method); } + public void setIsBooleanRequest() { + isBooleanRequest = true; + } + + public boolean isBooleanRequest() { + return isBooleanRequest; + } + public Type getResponseType() { - return Type.builder().withPackage(getPackageName()).withName(responseClassName(operationGroup)).build(); + return !isBooleanRequest + ? Type.builder().withPackage(getPackageName()).withName(responseClassName(operationGroup)).build() + : Types.Client.Transport.Endpoints.BooleanResponse; } public boolean canBeSingleton() { @@ -169,6 +180,10 @@ private static String responseClassName(@Nonnull OperationGroup operationGroup) private static String classBaseName(@Nonnull OperationGroup operationGroup) { Objects.requireNonNull(operationGroup, "operationGroup must not be null"); switch (operationGroup.toString()) { + case "indices.create": + return "CreateIndex"; + case "indices.delete": + return "DeleteIndex"; case "indices.get": return "GetIndex"; case "snapshot.clone": diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java index b9452504f1..a631254623 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java @@ -28,6 +28,7 @@ import org.opensearch.client.codegen.model.overrides.Overrides; import org.opensearch.client.codegen.model.overrides.PropertyOverride; import org.opensearch.client.codegen.model.overrides.SchemaOverride; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; import org.opensearch.client.codegen.openapi.HttpStatusCode; import org.opensearch.client.codegen.openapi.In; import org.opensearch.client.codegen.openapi.JsonPointer; @@ -122,10 +123,14 @@ private void visit(@Nonnull OperationGroup group, @Nonnull List c.get(MimeType.Json)) .flatMap(OpenApiMediaType::getSchema) .map(OpenApiSchema::resolve) - .orElse(OpenApiSchema.ANONYMOUS_OBJECT); - - visitInto(bodySchema, shape); + .ifPresent(s -> visitInto(s, shape)); if (shape.getExtendsType() == null) { shape.setExtendsType(Types.Client.OpenSearch._Types.RequestBase); @@ -252,33 +255,25 @@ private Shape visit(Namespace parent, String className, String typedefName, Open var description = schema.getDescription().orElse(null); - var oneOf = schema.getOneOf(); - var isTaggedUnion = oneOf.isPresent() - && (schema.getDiscriminator().isPresent() || oneOf.orElseThrow().stream().allMatch(OpenApiSchema::hasTitle)); + var isTaggedUnion = isTaggedUnion(schema); + var isShortcutPropertyObject = isShortcutPropertyObject(schema); if (schema.isArray()) { shape = new ArrayShape(parent, className, mapType(schema), typedefName, description); visitedSchemas.putIfAbsent(schema, shape); - } else if (schema.isStringEnum() || (oneOf.isPresent() && oneOf.get().stream().allMatch(OpenApiSchema::isStringEnum))) { + } else if (isEnum(schema)) { var enumShape = new EnumShape(parent, className, typedefName, description); shape = enumShape; visitedSchemas.putIfAbsent(schema, shape); - if (oneOf.isPresent()) { - oneOf.get().forEach(s -> { - var isDeprecated = s.getVersionDeprecated().isPresent(); - s.getEnums().orElseThrow().forEach(v -> enumShape.addVariant(v, isDeprecated)); - }); - } else { - schema.getEnums().orElseThrow().forEach(v -> enumShape.addVariant(v, false)); - } + visitInto(schema, enumShape); } else if (isTaggedUnion) { var discriminatingField = schema.getDiscriminator().flatMap(OpenApiDiscriminator::getPropertyName).orElse(null); var taggedUnion = new TaggedUnionShape(parent, className, typedefName, description, discriminatingField); shape = taggedUnion; visitedSchemas.putIfAbsent(schema, shape); - oneOf.get().forEach(s -> { + schema.getOneOf().or(schema::getAnyOf).orElseThrow().forEach(s -> { String name; if (discriminatingField != null) { var props = new HashMap(); @@ -301,7 +296,7 @@ private Shape visit(Namespace parent, String className, String typedefName, Open } taggedUnion.addVariant(name, mapType(s)); }); - } else if (schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object) { + } else if (isShortcutPropertyObject || schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object) { if (schema.getProperties().isEmpty() && schema.getAdditionalProperties().isPresent()) { shape = new DictionaryResponseShape( parent, @@ -317,6 +312,13 @@ private Shape visit(Namespace parent, String className, String typedefName, Open shape = objShape; visitedSchemas.putIfAbsent(schema, shape); + if (isShortcutPropertyObject) { + var oneOf = schema.getOneOf().orElseThrow(); + var shortcutProperty = oneOf.get(0).getTitle().orElseThrow(); + objShape.setShortcutProperty(shortcutProperty); + schema = oneOf.get(1); + } + visitInto(schema, objShape); } } else { @@ -369,7 +371,7 @@ private void visitInto(OpenApiSchema schema, ObjectShape shape) { } } - private Set collectObjectProperties( + private static Set collectObjectProperties( OpenApiSchema schema, Map properties, List additionalProperties @@ -428,6 +430,21 @@ private Set collectObjectProperties( return schema.getRequired().orElseGet(Collections::emptySet); } + private void visitInto(OpenApiSchema schema, EnumShape shape) { + var isDeprecated = schema.getVersionDeprecated().isPresent(); + + if (schema.hasOneOf()) { + schema.getOneOf().orElseThrow().forEach(s -> visitInto(s, shape)); + } else if (schema.hasEnums()) { + var enums = schema.getEnums().orElseThrow(); + var description = enums.size() == 1 ? schema.getDescription().orElse(null) : null; + enums.forEach(v -> shape.addVariant(v, description, isDeprecated)); + } else if (schema.hasConst()) { + var value = (String) schema.getConst().orElseThrow(); + shape.addVariant(value, schema.getDescription().orElse(null), isDeprecated); + } + } + private Type mapType(OpenApiSchema schema) { return mapType(schema, false); } @@ -452,10 +469,26 @@ private Type mapTypeInner(OpenApiSchema schema) { if (schema.has$ref()) { schema = schema.resolve(); + var schemaOverrides = overrides.getSchema(schema.getPointer()); + var overriddenMappedType = schemaOverrides.flatMap(SchemaOverride::getMappedType); + + if (overriddenMappedType.isPresent()) { + return overriddenMappedType.get(); + } + if (!shouldKeepRef(schema)) { return mapType(schema); } + var shouldGenerate = schemaOverrides.map(SchemaOverride::shouldGenerate).orElse(ShouldGenerate.IfNeeded); + + if (shouldGenerate == ShouldGenerate.Never) { + return Type.builder() + .withPackage(Types.Client.OpenSearch.PACKAGE + "." + schema.getNamespace().orElseThrow()) + .withName(schema.getName().orElseThrow()) + .build(); + } + var shape = visit(schema); return shape.getType(); @@ -582,38 +615,24 @@ private boolean shouldKeepRef(OpenApiSchema schema) { if (schema.isArray() || schema.isBoolean() || schema.isInteger() || schema.isNumber()) { return false; } + if (isEnum(schema)) { + return true; + } if (schema.isString()) { - return schema.hasEnums(); + return false; } if (schema.isObject() && schema.getProperties().map(Map::isEmpty).orElse(true) && schema.getAdditionalProperties().map(s -> s.getTitle().isEmpty()).orElse(false)) { return false; } - if (schema.getOneOf().isPresent()) { - if (schema.getDiscriminator().isPresent()) { - return true; - } - var allObject = true; - var allHaveTitle = true; - var allStringEnum = true; - for (var s : schema.getOneOf().orElseThrow()) { - if (s.determineSingleType().orElse(null) != OpenApiSchemaType.Object) { - allObject = false; - } - if (s.getTitle().isEmpty()) { - allHaveTitle = false; - } - if (!s.isStringEnum()) { - allStringEnum = false; - } - } - return allObject || allHaveTitle || allStringEnum; + if (isTaggedUnion(schema)) { + return true; } - if (schema.getAllOf().isPresent()) { - return schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object; + if (isShortcutPropertyObject(schema)) { + return true; } - return true; + return schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object; } private static boolean isOneOfSingleAndArray(List oneOf) { @@ -628,4 +647,56 @@ private static boolean isOneOfSingleAndArray(List oneOf) { var items = second.getItems().orElseThrow(); return first.getTypes().equals(items.getTypes()) && first.get$ref().equals(items.get$ref()); } + + private static boolean isEnum(OpenApiSchema schema) { + if (schema.isString()) { + return schema.hasEnums() || schema.hasConst(); + } + if (schema.getOneOf().isPresent()) { + return schema.getOneOf().get().stream().allMatch(SpecTransformer::isEnum); + } + return false; + } + + private static boolean isShortcutPropertyObject(OpenApiSchema schema) { + var oneOf = schema.getOneOf().orElse(null); + + if (oneOf == null || oneOf.size() != 2) { + return false; + } + + var first = oneOf.get(0); + var second = oneOf.get(1); + + if (!first.hasTitle() || second.hasTitle()) { + return false; + } + + var secondType = second.determineSingleType().orElse(null); + if (secondType != OpenApiSchemaType.Object) { + return false; + } + + var properties = new HashMap(); + collectObjectProperties(second, properties, new ArrayList<>()); + + return properties.containsKey(first.getTitle().orElseThrow()); + } + + private static boolean isTaggedUnion(OpenApiSchema schema) { + if (schema.hasOneOf()) { + if (schema.getDiscriminator().isPresent()) { + return true; + } + return isTaggedUnion(schema.getOneOf().orElseThrow()); + } + if (schema.hasAnyOf()) { + return isTaggedUnion(schema.getAnyOf().orElseThrow()); + } + return false; + } + + private static boolean isTaggedUnion(List oneOfAnyOf) { + return oneOfAnyOf.stream().allMatch(OpenApiSchema::hasTitle); + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java index 8e317e2ef8..79ee51340c 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java @@ -36,10 +36,6 @@ public Collection getVariants() { return variants.values(); } - public Collection getShapeVariants() { - return Lists.filter(getVariants(), v -> v.getType().isInsidePackage("org.opensearch") && !v.getType().isEnum()); - } - public Collection getNonShapeVariants() { return Lists.filter(getVariants(), v -> !v.getType().isInsidePackage("org.opensearch")); } @@ -76,14 +72,29 @@ public Type getVariantBaseType() { } public boolean canStringify() { - return !isDiscriminated() && getVariants().stream().allMatch(v -> v.getType().isString() || v.getType().isEnum()); + return !isDiscriminated() && getVariants().stream().allMatch(v -> { + var t = v.getType(); + return t.isPotentiallyBoxedPrimitive() || t.isString() || t.isEnum(); + }); + } + + public boolean hasAmbiguities() { + if (isDiscriminated()) { + return false; + } + + return getVariants().stream().filter(v -> { + var t = v.getType(); + return t.isString() || t.isEnum(); + }).count() > 1; } @Override public void render(ShapeRenderingContext ctx) throws RenderException { super.render(ctx); - if (!getShapeVariants().isEmpty()) { - new Builders(this).render(ctx); + var buildableVariants = Lists.filter(getVariants(), v -> v.getType().hasBuilder()); + if (!buildableVariants.isEmpty()) { + new Builders(this, buildableVariants).render(ctx); } if (isDiscriminated()) { new VariantInterface(this).render(ctx); @@ -130,9 +141,9 @@ private static String buildDescription(TaggedUnionShape union) { private final String unionClassName; private final Collection variants; - private Builders(TaggedUnionShape union) { + private Builders(TaggedUnionShape union, Collection variants) { super(union.getParent(), union.getClassName() + "Builders", null, buildDescription(union)); - variants = union.getShapeVariants(); + this.variants = variants; unionClassName = union.getClassName(); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java index 7545444777..aab2d65e5f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java @@ -39,12 +39,20 @@ private static Map asMap(Class clazz) { return map; } + private static Type type(String name) { + return Type.builder().withName(name).build(); + } + + private static Type type(String packageName, String name) { + return Type.builder().withPackage(packageName).withName(name).build(); + } + public static final class Primitive { - public static final Type Boolean = Type.builder().withName("boolean").build(); - public static final Type Int = Type.builder().withName("int").build(); - public static final Type Long = Type.builder().withName("long").build(); - public static final Type Float = Type.builder().withName("float").build(); - public static final Type Double = Type.builder().withName("double").build(); + public static final Type Boolean = type("boolean"); + public static final Type Int = type("int"); + public static final Type Long = type("long"); + public static final Type Float = type("float"); + public static final Type Double = type("double"); } public static final class Java { @@ -52,59 +60,65 @@ public static final class Java { public static final class Io { public static final String PACKAGE = Java.PACKAGE + ".io"; - public static final Type IOException = Type.builder().withPackage(PACKAGE).withName("IOException").build(); + public static final Type IOException = type(PACKAGE, "IOException"); } public static final class Lang { public static final String PACKAGE = Java.PACKAGE + ".lang"; - public static final Type String = Type.builder().withPackage(PACKAGE).withName("String").build(); - public static final Type Character = Type.builder().withPackage(PACKAGE).withName("Character").build(); - public static final Type Boolean = Type.builder().withPackage(PACKAGE).withName("Boolean").build(); - public static final Type Byte = Type.builder().withPackage(PACKAGE).withName("Byte").build(); - public static final Type Short = Type.builder().withPackage(PACKAGE).withName("Short").build(); - public static final Type Integer = Type.builder().withPackage(PACKAGE).withName("Integer").build(); - public static final Type Long = Type.builder().withPackage(PACKAGE).withName("Long").build(); - public static final Type Float = Type.builder().withPackage(PACKAGE).withName("Float").build(); - public static final Type Double = Type.builder().withPackage(PACKAGE).withName("Double").build(); - public static final Type Object = Type.builder().withPackage(PACKAGE).withName("Object").build(); - public static final Type Number = Type.builder().withPackage(PACKAGE).withName("Number").build(); + public static final Type String = type(PACKAGE, "String"); + public static final Type Character = type(PACKAGE, "Character"); + public static final Type Boolean = type(PACKAGE, "Boolean"); + public static final Type Byte = type(PACKAGE, "Byte"); + public static final Type Short = type(PACKAGE, "Short"); + public static final Type Integer = type(PACKAGE, "Integer"); + public static final Type Long = type(PACKAGE, "Long"); + public static final Type Float = type(PACKAGE, "Float"); + public static final Type Double = type(PACKAGE, "Double"); + public static final Type Object = type(PACKAGE, "Object"); + public static final Type Number = type(PACKAGE, "Number"); } public static final class Util { public static final String PACKAGE = Java.PACKAGE + ".util"; - public static final Type Objects = Type.builder().withPackage(PACKAGE).withName("Objects").build(); - public static final Type HashMap = Type.builder().withPackage(PACKAGE).withName("HashMap").build(); + public static final Type Objects = type(PACKAGE, "Objects"); + public static final Type HashMap = type(PACKAGE, "HashMap"); public static Type Map(Type keyType, Type valueType) { - return Map.toBuilder().withTypeParameters(keyType, valueType).build(); + return Map.withTypeParameters(keyType, valueType); } - public static final Type Map = Type.builder().withPackage(PACKAGE).withName("Map").build(); + public static final Type Map = type(PACKAGE, "Map"); public static Type MapEntry(Type keyType, Type valueType) { - return Type.builder().withPackage(PACKAGE).withName("Map.Entry").withTypeParameters(keyType, valueType).build(); + return MapEntry.withTypeParameters(keyType, valueType); } + public static final Type MapEntry = type(PACKAGE, "Map.Entry"); + public static Type List(Type valueType) { - return Type.builder().withPackage(PACKAGE).withName("List").withTypeParameters(valueType).build(); + return List.withTypeParameters(valueType); } + public static final Type List = type(PACKAGE, "List"); + public static final class Concurrent { public static final String PACKAGE = Util.PACKAGE + ".concurrent"; - public static final Type CompletableFuture = Type.builder().withPackage(PACKAGE).withName("CompletableFuture").build(); + public static final Type CompletableFuture = type(PACKAGE, "CompletableFuture"); } public static final class Function { public static final String PACKAGE = Util.PACKAGE + ".function"; public static Type Function(Type argType, Type returnType) { - return Type.builder().withPackage(PACKAGE).withName("Function").withTypeParameters(argType, returnType).build(); + return Function.withTypeParameters(argType, returnType); } + + public static final Type Function = type(PACKAGE, "Function"); } public static final class Stream { public static final String PACKAGE = Util.PACKAGE + ".stream"; - public static final Type Collectors = Type.builder().withPackage(PACKAGE).withName("Collectors").build(); + public static final Type Collectors = type(PACKAGE, "Collectors"); } } } @@ -114,9 +128,9 @@ public static final class Javax { public static final class Annotation { public static final String PACKAGE = Javax.PACKAGE + ".annotation"; - public static final Type Generated = Type.builder().withPackage(PACKAGE).withName("Generated").build(); - public static final Type Nonnull = Type.builder().withPackage(PACKAGE).withName("Nonnull").build(); - public static final Type Nullable = Type.builder().withPackage(PACKAGE).withName("Nullable").build(); + public static final Type Generated = type(PACKAGE, "Generated"); + public static final Type Nonnull = type(PACKAGE, "Nonnull"); + public static final Type Nullable = type(PACKAGE, "Nullable"); } } @@ -127,23 +141,21 @@ public static Type ApiClient(Type transport, Type client) { return ApiClient.withTypeParameters(transport, client); } - public static final Type ApiClient = Type.builder().withPackage(PACKAGE).withName("ApiClient").build(); + public static final Type ApiClient = type(PACKAGE, "ApiClient"); public static final class Json { public static final String PACKAGE = Client.PACKAGE + ".json"; - public static final Type JsonData = Type.builder().withPackage(PACKAGE).withName("JsonData").build(); - public static final Type JsonpDeserializable = Type.builder().withPackage(PACKAGE).withName("JsonpDeserializable").build(); - public static final Type JsonpDeserializer = Type.builder().withPackage(PACKAGE).withName("JsonpDeserializer").build(); - public static final Type JsonEnum = Type.builder().withPackage(PACKAGE).withName("JsonEnum").build(); - public static final Type JsonpMapper = Type.builder().withPackage(PACKAGE).withName("JsonpMapper").build(); - public static final Type JsonpSerializable = Type.builder().withPackage(PACKAGE).withName("JsonpSerializable").build(); - public static final Type ObjectBuilderDeserializer = Type.builder() - .withPackage(PACKAGE) - .withName("ObjectBuilderDeserializer") - .build(); - public static final Type ObjectDeserializer = Type.builder().withPackage(PACKAGE).withName("ObjectDeserializer").build(); - public static final Type PlainJsonSerializable = Type.builder().withPackage(PACKAGE).withName("PlainJsonSerializable").build(); - public static final Type UnionDeserializer = Type.builder().withPackage(PACKAGE).withName("UnionDeserializer").build(); + public static final Type JsonData = type(PACKAGE, "JsonData"); + public static final Type JsonpDeserializable = type(PACKAGE, "JsonpDeserializable"); + public static final Type JsonpDeserializer = type(PACKAGE, "JsonpDeserializer"); + public static final Type JsonEnum = type(PACKAGE, "JsonEnum"); + public static final Type JsonpMapper = type(PACKAGE, "JsonpMapper"); + public static final Type JsonpSerializable = type(PACKAGE, "JsonpSerializable"); + public static final Type ObjectBuilderDeserializer = type(PACKAGE, "ObjectBuilderDeserializer"); + public static final Type ObjectDeserializer = type(PACKAGE, "ObjectDeserializer"); + public static final Type PlainDeserializable = type(PACKAGE, "PlainDeserializable"); + public static final Type PlainJsonSerializable = type(PACKAGE, "PlainJsonSerializable"); + public static final Type UnionDeserializer = type(PACKAGE, "UnionDeserializer"); } public static final class OpenSearch { @@ -151,54 +163,57 @@ public static final class OpenSearch { public static final class _Types { public static final String PACKAGE = OpenSearch.PACKAGE + "._types"; - public static final Type ErrorResponse = Type.builder().withPackage(PACKAGE).withName("ErrorResponse").build(); - public static final Type OpenSearchException = Type.builder().withPackage(PACKAGE).withName("OpenSearchException").build(); - public static final Type RequestBase = Type.builder().withPackage(PACKAGE).withName("RequestBase").build(); - public static final Type Time = Type.builder().withPackage(PACKAGE).withName("Time").build(); + public static final Type ErrorResponse = type(PACKAGE, "ErrorResponse"); + public static final Type OpenSearchException = type(PACKAGE, "OpenSearchException"); + public static final Type RequestBase = type(PACKAGE, "RequestBase"); + public static final Type Time = type(PACKAGE, "Time"); } } public static final class Transport { public static final String PACKAGE = Client.PACKAGE + ".transport"; - public static final Type Endpoint = Type.builder().withPackage(PACKAGE).withName("Endpoint").build(); + public static final Type Endpoint = type(PACKAGE, "Endpoint"); public static Type JsonEndpoint(Type requestType, Type responseType, Type errorType) { return JsonEndpoint.withTypeParameters(requestType, responseType, errorType); } - public static final Type JsonEndpoint = Type.builder().withPackage(PACKAGE).withName("JsonEndpoint").build(); - public static final Type OpenSearchTransport = Type.builder().withPackage(PACKAGE).withName("OpenSearchTransport").build(); - public static final Type TransportOptions = Type.builder().withPackage(PACKAGE).withName("TransportOptions").build(); + public static final Type JsonEndpoint = type(PACKAGE, "JsonEndpoint"); + public static final Type OpenSearchTransport = type(PACKAGE, "OpenSearchTransport"); + public static final Type TransportOptions = type(PACKAGE, "TransportOptions"); public static final class Endpoints { public static final String PACKAGE = Transport.PACKAGE + ".endpoints"; + public static final Type BooleanEndpoint = type(PACKAGE, "BooleanEndpoint"); + public static final Type BooleanResponse = type(PACKAGE, "BooleanResponse"); + public static Type DictionaryResponse(Type keyType, Type valueType) { return DictionaryResponse.withTypeParameters(keyType, valueType); } - public static final Type DictionaryResponse = Type.builder().withPackage(PACKAGE).withName("DictionaryResponse").build(); - public static final Type SimpleEndpoint = Type.builder().withPackage(PACKAGE).withName("SimpleEndpoint").build(); + public static final Type DictionaryResponse = type(PACKAGE, "DictionaryResponse"); + public static final Type SimpleEndpoint = type(PACKAGE, "SimpleEndpoint"); } } public static final class Util { public static final String PACKAGE = Client.PACKAGE + ".util"; - public static final Type ApiTypeHelper = Type.builder().withPackage(PACKAGE).withName("ApiTypeHelper").build(); + public static final Type ApiTypeHelper = type(PACKAGE, "ApiTypeHelper"); public static Type ObjectBuilder(Type type) { return ObjectBuilder.withTypeParameters(type); } - public static final Type ObjectBuilder = Type.builder().withPackage(PACKAGE).withName("ObjectBuilder").build(); - public static final Type ObjectBuilderBase = Type.builder().withPackage(PACKAGE).withName("ObjectBuilderBase").build(); + public static final Type ObjectBuilder = type(PACKAGE, "ObjectBuilder"); + public static final Type ObjectBuilderBase = type(PACKAGE, "ObjectBuilderBase"); public static Type TaggedUnion(Type tagType, Type baseType) { return TaggedUnion.withTypeParameters(tagType, baseType); } - public static final Type TaggedUnion = Type.builder().withPackage(PACKAGE).withName("TaggedUnion").build(); - public static final Type TaggedUnionUtils = Type.builder().withPackage(PACKAGE).withName("TaggedUnionUtils").build(); + public static final Type TaggedUnion = type(PACKAGE, "TaggedUnion"); + public static final Type TaggedUnionUtils = type(PACKAGE, "TaggedUnionUtils"); } } @@ -210,7 +225,7 @@ public static final class Json { public static final class Stream { public static final String PACKAGE = Json.PACKAGE + ".stream"; - public static final Type JsonGenerator = Type.builder().withPackage(PACKAGE).withName("JsonGenerator").build(); + public static final Type JsonGenerator = type(PACKAGE, "JsonGenerator"); } } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java index 7a8ef32339..750a4e8e88 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java @@ -12,10 +12,10 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.function.Function; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.opensearch.client.codegen.model.Types; import org.opensearch.client.codegen.openapi.JsonPointer; import org.opensearch.client.codegen.utils.builder.ObjectBuilder; import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; @@ -24,20 +24,16 @@ public class Overrides { private static final JsonPointer SCHEMAS = JsonPointer.of("components", "schemas"); public static final Overrides OVERRIDES = builder().withSchemas( - s -> s.with(SCHEMAS.append("_common.query_dsl:QueryContainer"), so -> so.withClassName("Query")) - .with(SCHEMAS.append("indices._common:IndexSettings"), so -> so.withAliasProvider((k) -> { - switch (k) { - case "index": - case "indexing": - case "mapping": - case "search": - case "settings": - case "top_metrics_max_size": - return null; - default: - return Set.of("index." + k); - } - })) + s -> s + // TODO: Remove this to generate property mapping types + .with(SCHEMAS.append("_common.mapping:Property"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + // TODO: Remove this to generate query types + .with( + SCHEMAS.append("_common.query_dsl:QueryContainer"), + so -> so.withMappedType(t -> t.withPackage(Types.Client.OpenSearch._Types.PACKAGE + ".query_dsl").withName("Query")) + ) + // TODO: Remove this to generate index settings types + .with(SCHEMAS.append("indices._common:IndexSettings"), so -> so.withShouldGenerate(ShouldGenerate.Never)) ).build(); @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java index a72db9173e..a1ee81b882 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java @@ -24,19 +24,22 @@ import org.opensearch.client.codegen.utils.builder.ObjectMapBuilderBase; public final class SchemaOverride { - private final boolean skipGeneration; + private final ShouldGenerate shouldGenerate; @Nonnull private final Map properties; @Nullable private final Function> aliasProvider; @Nullable private final String className; + @Nullable + private final Type mappedType; private SchemaOverride(Builder builder) { - this.skipGeneration = builder.skipGeneration; + this.shouldGenerate = builder.shouldGenerate; this.properties = builder.properties != null ? Collections.unmodifiableMap(builder.properties) : Collections.emptyMap(); this.aliasProvider = builder.aliasProvider; this.className = builder.className; + this.mappedType = builder.mappedType; } @Nonnull @@ -63,8 +66,8 @@ public PropertyOverride getProperty(@Nonnull String key) { return PropertyOverride.builder().withMappedType(mappedType).withAliases(aliases).build(); } - public boolean shouldSkipGeneration() { - return skipGeneration; + public ShouldGenerate shouldGenerate() { + return shouldGenerate; } @Nonnull @@ -72,6 +75,11 @@ public Optional getClassName() { return Optional.ofNullable(className); } + @Nonnull + public Optional getMappedType() { + return Optional.ofNullable(mappedType); + } + @Nonnull public static Builder builder() { return new Builder(); @@ -83,13 +91,16 @@ public static MapBuilder mapBuilder() { } public static final class Builder extends ObjectBuilderBase { - private boolean skipGeneration; + @Nonnull + private ShouldGenerate shouldGenerate = ShouldGenerate.IfNeeded; @Nullable private Map properties; @Nullable private Function> aliasProvider; @Nullable private String className; + @Nullable + private Type mappedType; private Builder() {} @@ -100,8 +111,8 @@ protected SchemaOverride construct() { } @Nonnull - public Builder withSkipGeneration(boolean skipGeneration) { - this.skipGeneration = skipGeneration; + public Builder withShouldGenerate(ShouldGenerate shouldGenerate) { + this.shouldGenerate = Objects.requireNonNull(shouldGenerate, "shouldGenerate must not be null"); return this; } @@ -122,6 +133,18 @@ public Builder withClassName(@Nullable String className) { this.className = className; return this; } + + @Nonnull + public Builder withMappedType(@Nullable Type mappedType) { + this.mappedType = mappedType; + return this; + } + + @Nonnull + public Builder withMappedType(@Nonnull Function> fn) { + this.mappedType = Objects.requireNonNull(fn, "fn must not be null").apply(Type.builder()).build(); + return this; + } } public static final class MapBuilder extends ObjectMapBuilderBase { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java new file mode 100644 index 0000000000..068511302c --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java @@ -0,0 +1,15 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.model.overrides; + +public enum ShouldGenerate { + Always, + IfNeeded, + Never +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java index 304b3e4055..79ca01555f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java @@ -68,6 +68,8 @@ public class OpenApiSchema extends OpenApiRefElement { @Nullable private final OpenApiDiscriminator discriminator; @Nullable + private final Object constValue; + @Nullable private final Semver versionRemoved; @Nullable private final Semver versionDeprecated; @@ -90,6 +92,7 @@ private OpenApiSchema(@Nonnull Builder builder) { title = builder.title; pattern = builder.pattern; discriminator = builder.discriminator; + constValue = builder.constValue; versionRemoved = builder.versionRemoved; versionDeprecated = builder.versionDeprecated; } @@ -144,6 +147,8 @@ protected OpenApiSchema(@Nullable OpenApiElement parent, @Nonnull JsonPointer discriminator = child("discriminator", schema.getDiscriminator(), OpenApiDiscriminator::new); + constValue = schema.getConst(); + var extensions = schema.getExtensions(); versionRemoved = Maps.tryGet(extensions, "x-version-removed").map(v -> Versions.coerce((String) v)).orElse(null); @@ -204,10 +209,6 @@ public boolean isString() { return is(OpenApiSchemaType.String); } - public boolean isStringEnum() { - return isString() && hasEnums(); - } - public boolean hasAllOf() { return allOf != null && !allOf.isEmpty(); } @@ -283,6 +284,15 @@ public Optional getDiscriminator() { return Optional.ofNullable(discriminator); } + public boolean hasConst() { + return constValue != null; + } + + @Nonnull + public Optional getConst() { + return Optional.ofNullable(constValue); + } + @Nonnull public Optional getVersionRemoved() { return Optional.ofNullable(versionRemoved); @@ -374,6 +384,8 @@ public static class Builder extends ObjectBuilderBase { @Nullable private OpenApiDiscriminator discriminator; @Nullable + private Object constValue; + @Nullable private Semver versionRemoved; @Nullable private Semver versionDeprecated; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java index 4f005f2a87..c8476f465b 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java @@ -8,6 +8,7 @@ package org.opensearch.client.codegen.utils; +import javax.annotation.Nonnull; import org.commonmark.parser.Parser; import org.commonmark.renderer.html.HtmlRenderer; @@ -17,7 +18,8 @@ private Markdown() {} private static final Parser PARSER = Parser.builder().build(); private static final HtmlRenderer RENDERER = HtmlRenderer.builder().omitSingleParagraphP(true).build(); - public static String toJavaDocHtml(String markdown) { + @Nonnull + public static String toJavaDocHtml(@Nonnull String markdown) { return RENDERER.render(PARSER.parse(markdown)).strip(); } } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache index 719c40ba20..543bfdb110 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache @@ -3,6 +3,11 @@ {{^-first}} {{/-first}} +{{#description}} + /** + * {{.}} + */ +{{/description}} {{#deprecated}} @Deprecated {{/deprecated}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache index f9a8abeeaa..f715bd75d5 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache @@ -4,7 +4,7 @@ */ {{#extendsOtherShape}} public static class Builder extends {{extendsType}}.AbstractBuilder - implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{#shouldImplementPlainDeserializable}}, {{TYPES.Client.Json.PlainDeserializable}}{{/shouldImplementPlainDeserializable}} { {{>ObjectShape/Builder/Fields}} {{>ObjectShape/Builder/SelfImpl}} @@ -15,7 +15,8 @@ {{^extendsOtherShape}} {{#extendedByOtherShape}} public static class Builder extends {{type}}.AbstractBuilder - implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}>{{#shouldImplementPlainDeserializable}}, {{TYPES.Client.Json.PlainDeserializable}}{{/shouldImplementPlainDeserializable}} + { {{>ObjectShape/Builder/SelfImpl}} {{>ObjectShape/Builder/BuildImpl}} @@ -23,7 +24,12 @@ {{/extendedByOtherShape}} {{^extendedByOtherShape}} public static class Builder extends {{TYPES.Client.Util.ObjectBuilderBase}} - implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}>{{#shouldImplementPlainDeserializable}}, {{TYPES.Client.Json.PlainDeserializable}}{{/shouldImplementPlainDeserializable}} + { + {{#shouldImplementPlainDeserializable}} + {{>ObjectShape/Builder/SelfImpl}} + + {{/shouldImplementPlainDeserializable}} {{>ObjectShape/Builder/Fields}} {{>ObjectShape/Builder/BuildImpl}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache index 7d897fe252..ce3c4f49ed 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache @@ -1,4 +1,4 @@ @Override -protected Builder self() { +{{#shouldImplementPlainDeserializable}}public{{/shouldImplementPlainDeserializable}}{{^shouldImplementPlainDeserializable}}protected{{/shouldImplementPlainDeserializable}} Builder self() { return this; } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache index ddb9adaddc..4d37bb6a2f 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache @@ -29,4 +29,8 @@ op.ignore({{#quoted}}{{key}}{{/quoted}}); {{/distinctDiscriminatorFieldValues}} + {{#shortcutProperty}} + + op.shortcutProperty({{#quoted}}{{.}}{{/quoted}}); + {{/shortcutProperty}} } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache index f73f6dd4a2..f73e867c2f 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache @@ -35,7 +35,7 @@ /** * Endpoint "{@code {{operationGroup}}}". */ - public static final {{TYPES.Client.Transport.Endpoint}}<{{className}}, {{responseType}}, {{TYPES.Client.OpenSearch._Types.ErrorResponse}}> _ENDPOINT = new {{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}<>( + public static final {{TYPES.Client.Transport.Endpoint}}<{{className}}, {{responseType}}, {{TYPES.Client.OpenSearch._Types.ErrorResponse}}> _ENDPOINT = new {{#isBooleanRequest}}{{TYPES.Client.Transport.Endpoints.BooleanEndpoint}}{{/isBooleanRequest}}{{^isBooleanRequest}}{{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}{{/isBooleanRequest}}<>( // Request method request -> {{#quoted}}{{httpMethod}}{{/quoted}}, // Request path @@ -92,9 +92,12 @@ {{^hasQueryParams}} {{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}.emptyMap(), {{/hasQueryParams}} - {{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}.emptyMap(), + {{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}.emptyMap() + {{^isBooleanRequest}} + , {{hasRequestBody}}, {{responseType}}._DESERIALIZER + {{/isBooleanRequest}} ); {{>ObjectShape/HashCode}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache index fd51d4d80a..21c3a05a47 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache @@ -146,7 +146,7 @@ {{/discriminated}} {{^discriminated}} private static {{TYPES.Client.Json.JsonpDeserializer}}<{{className}}> build{{className}}Deserializer() { - return new {{TYPES.Client.Json.UnionDeserializer.builderType}}<{{className}}, Kind, Object>({{className}}::new, {{canStringify}}) + return new {{TYPES.Client.Json.UnionDeserializer.builderType}}<{{className}}, Kind, Object>({{className}}::new, {{hasAmbiguities}}) {{#variants}}.addMember(Kind.{{#pascalCase}}{{name}}{{/pascalCase}}, {{#type}}{{>Type/deserializer}}{{/type}}){{/variants}} .build(); } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache index f0768a1e03..1f4eec4047 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache @@ -15,7 +15,16 @@ {{/type.isMap}} {{#type.isList}} for ({{type.listValueType}} item{{depth}} : {{value}}) { - {{#type.listValueType.serializer}}item{{depth}}{{/type.listValueType.serializer}} + {{#type.listValueType.isMap}} + generator.writeStartObject(); + if (item{{depth}} != null) { + {{#type.listValueType.directSerializer}}item{{depth}}{{/type.listValueType.directSerializer}} + } + generator.writeEnd(); + {{/type.listValueType.isMap}} + {{^type.listValueType.isMap}} + {{#type.listValueType.serializer}}item{{depth}}{{/type.listValueType.serializer}} + {{/type.listValueType.isMap}} } {{/type.isList}} {{^type.isListOrMap}}