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/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/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java index 960b374709..1b441c5070 100644 --- 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 @@ -59,6 +59,25 @@ public OpenSearchIndicesAsyncClientBase(OpenSearchTransport transport, @Nullable 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.exists /** 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 index 9c2fc174c3..2f113ea47d 100644 --- 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 @@ -58,6 +58,25 @@ public OpenSearchIndicesClientBase(OpenSearchTransport transport, @Nullable Tran 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.exists /** 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/OpenSearchIndicesAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClient.java index ba06a2da13..d4811a6974 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 @@ -248,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 /** 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 19c6a3c383..8d7881294d 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 @@ -235,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 /** 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 49f222f0d9..07819e4e3e 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,7 +43,7 @@ public class CodeGenerator { private static final OperationGroupMatcher OPERATION_MATCHER = or( and(namespace(""), named("info")), namespace("dangling_indices"), - and(namespace("indices"), named("exists", "get")), + and(namespace("indices"), named("create", "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/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index 8215e444c9..b30d2b9e95 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 @@ -180,6 +180,8 @@ 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.get": return "GetIndex"; case "snapshot.clone": 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 907f745c5f..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 @@ -72,7 +72,21 @@ 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 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(); }