From 44928cd887f4188dc5efcb00681caf1a3e0745dd Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 13 Dec 2024 19:26:23 +1300 Subject: [PATCH 1/7] Generate aliases operations Signed-off-by: Thomas Farr --- .../opensearch/indices/AliasDefinition.java | 173 +++++++- .../indices/DeleteAliasRequest.java | 285 +++++++----- .../indices/DeleteAliasResponse.java | 70 ++- .../indices/ExistsAliasRequest.java | 231 +++++++--- .../opensearch/indices/GetAliasRequest.java | 236 +++++++--- .../opensearch/indices/GetAliasResponse.java | 19 +- .../opensearch/indices/GetMappingRequest.java | 3 - .../OpenSearchIndicesAsyncClientBase.java | 118 +++++ .../indices/OpenSearchIndicesClientBase.java | 116 +++++ .../opensearch/indices/PutAliasRequest.java | 409 +++++++++++++----- .../opensearch/indices/PutAliasResponse.java | 68 ++- .../indices/UpdateAliasesRequest.java | 228 +++++++--- .../indices/UpdateAliasesResponse.java | 70 ++- .../indices/get_alias/IndexAliases.java | 99 ++++- .../indices/update_aliases/Action.java | 87 ++-- .../update_aliases/ActionBuilders.java | 11 +- .../indices/update_aliases/ActionVariant.java | 11 +- .../indices/update_aliases/AddAction.java | 270 +++++++++--- .../indices/update_aliases/RemoveAction.java | 138 +++++- .../update_aliases/RemoveIndexAction.java | 132 +++++- .../indices/ExistsAliasResponse.java | 49 --- .../indices/OpenSearchIndicesAsyncClient.java | 187 -------- .../indices/OpenSearchIndicesClient.java | 185 -------- .../client/codegen/CodeGenerator.java | 1 + .../client/codegen/model/RequestShape.java | 25 +- .../client/codegen/model/SpecTransformer.java | 7 +- 26 files changed, 2159 insertions(+), 1069 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/AliasDefinition.java (57%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/DeleteAliasRequest.java (56%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/DeleteAliasResponse.java (62%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/ExistsAliasRequest.java (55%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/GetAliasRequest.java (55%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/GetAliasResponse.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java (54%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/PutAliasResponse.java (61%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/UpdateAliasesRequest.java (65%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/UpdateAliasesResponse.java (62%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/get_alias/IndexAliases.java (66%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/update_aliases/Action.java (76%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/update_aliases/ActionBuilders.java (86%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/update_aliases/ActionVariant.java (82%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/update_aliases/AddAction.java (66%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveAction.java (69%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveIndexAction.java (61%) delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsAliasResponse.java diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/AliasDefinition.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AliasDefinition.java similarity index 57% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/AliasDefinition.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/AliasDefinition.java index eeb2c7e956..9cd7684159 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/AliasDefinition.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AliasDefinition.java @@ -30,10 +30,17 @@ * 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.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; @@ -42,19 +49,26 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.opensearch._types.query_dsl.Query; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; -// typedef: indices._types.AliasDefinition +// typedef: indices.AliasDefinition @JsonpDeserializable -public class AliasDefinition implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class AliasDefinition implements PlainJsonSerializable, ToCopyableBuilder { + @Nullable private final Query filter; @Nullable private final String indexRouting; + @Nullable + private final Boolean isHidden; + @Nullable private final Boolean isWriteIndex; @@ -67,16 +81,15 @@ public class AliasDefinition implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private AliasDefinition(Builder builder) { - this.filter = builder.filter; this.indexRouting = builder.indexRouting; + this.isHidden = builder.isHidden; this.isWriteIndex = builder.isWriteIndex; this.routing = builder.routing; this.searchRouting = builder.searchRouting; - } - public static AliasDefinition of(Function> fn) { + public static AliasDefinition of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -89,7 +102,11 @@ public final Query filter() { } /** + * Value used to route indexing operations to a specific shard. If specified, this overwrites the routing value for + * indexing operations. + *

* API name: {@code index_routing} + *

*/ @Nullable public final String indexRouting() { @@ -97,7 +114,21 @@ public final String indexRouting() { } /** + * If true, the alias is hidden. All indexes for the alias must have the same is_hidden value. + *

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

+ */ + @Nullable + public final Boolean isHidden() { + return this.isHidden; + } + + /** + * If true, the index is the write index for the alias. + *

* API name: {@code is_write_index} + *

*/ @Nullable public final Boolean isWriteIndex() { @@ -105,7 +136,10 @@ public final Boolean isWriteIndex() { } /** + * Value used to route indexing and search operations to a specific shard. + *

* API name: {@code routing} + *

*/ @Nullable public final String routing() { @@ -113,7 +147,11 @@ public final String routing() { } /** + * Value used to route search operations to a specific shard. If specified, this overwrites the routing value for search + * operations. + *

* API name: {@code search_routing} + *

*/ @Nullable public final String searchRouting() { @@ -123,6 +161,7 @@ public final String searchRouting() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -130,60 +169,97 @@ 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); - } - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link AliasDefinition}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private Query filter; - @Nullable private String indexRouting; - + @Nullable + private Boolean isHidden; @Nullable private Boolean isWriteIndex; - @Nullable private String routing; - @Nullable private String searchRouting; + public Builder() {} + + private Builder(AliasDefinition o) { + this.filter = o.filter; + this.indexRouting = o.indexRouting; + this.isHidden = o.isHidden; + this.isWriteIndex = o.isWriteIndex; + this.routing = o.routing; + this.searchRouting = o.searchRouting; + } + + private Builder(Builder o) { + this.filter = o.filter; + this.indexRouting = o.indexRouting; + this.isHidden = o.isHidden; + this.isWriteIndex = o.isWriteIndex; + this.routing = o.routing; + this.searchRouting = o.searchRouting; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * API name: {@code filter} */ + @Nonnull public final Builder filter(@Nullable Query value) { this.filter = value; return this; @@ -192,37 +268,68 @@ public final Builder filter(@Nullable Query value) { /** * API name: {@code filter} */ + @Nonnull public final Builder filter(Function> fn) { - return this.filter(fn.apply(new Query.Builder()).build()); + return filter(fn.apply(new Query.Builder()).build()); } /** + * Value used to route indexing operations to a specific shard. If specified, this overwrites the routing value for + * indexing operations. + *

* API name: {@code index_routing} + *

*/ + @Nonnull public final Builder indexRouting(@Nullable String value) { this.indexRouting = value; return this; } /** + * If true, the alias is hidden. All indexes for the alias must have the same is_hidden value. + *

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

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

* API name: {@code is_write_index} + *

*/ + @Nonnull public final Builder isWriteIndex(@Nullable Boolean value) { this.isWriteIndex = value; return this; } /** + * Value used to route indexing and search operations to a specific shard. + *

* API name: {@code routing} + *

*/ + @Nonnull public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** + * Value used to route search operations to a specific shard. If specified, this overwrites the routing value for + * search operations. + *

* API name: {@code search_routing} + *

*/ + @Nonnull public final Builder searchRouting(@Nullable String value) { this.searchRouting = value; return this; @@ -231,9 +338,10 @@ public final Builder searchRouting(@Nullable String value) { /** * Builds a {@link AliasDefinition}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public AliasDefinition build() { _checkSingleUse(); @@ -252,13 +360,36 @@ public AliasDefinition build() { ); protected static void setupAliasDefinitionDeserializer(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; + AliasDefinition other = (AliasDefinition) 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/DeleteAliasRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteAliasRequest.java similarity index 56% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteAliasRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteAliasRequest.java index 9f76067c40..d706fc851e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteAliasRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteAliasRequest.java @@ -30,13 +30,19 @@ * 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.RequestBase; @@ -44,26 +50,30 @@ import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.SimpleEndpoint; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.delete_alias.Request /** * Deletes an alias. - * */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class DeleteAliasRequest extends RequestBase implements ToCopyableBuilder { -public class DeleteAliasRequest extends RequestBase { + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull private final List index; @Deprecated @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - + @Nonnull private final List name; @Nullable @@ -72,33 +82,45 @@ public class DeleteAliasRequest extends RequestBase { // --------------------------------------------------------------------------------------------- private DeleteAliasRequest(Builder builder) { - + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.index = ApiTypeHelper.unmodifiableRequired(builder.index, this, "index"); this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.name = ApiTypeHelper.unmodifiableRequired(builder.name, this, "name"); this.timeout = builder.timeout; - } - public static DeleteAliasRequest of(Function> fn) { + public static DeleteAliasRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Required - A comma-separated list of index names (supports wildcards); use - * _all for all indices + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + /** + * Required - Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (*). *

* 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 cluster-manager node. If no response is received before the timeout expires, the request fails + * and returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated @Nullable @@ -107,29 +129,22 @@ 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; - } - - /** - * Required - A comma-separated list of aliases to delete (supports wildcards); - * use _all to delete all aliases for the specified indices. + * Required - Comma-separated list of aliases to remove. Supports wildcards (*). To remove all aliases, use * + * or _all. *

* API name: {@code name} + *

*/ + @Nonnull public final List name() { return this.name; } /** - * Explicit timestamp for the document + * 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() { @@ -138,142 +153,200 @@ public final Time timeout() { // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link DeleteAliasRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable + private Time clusterManagerTimeout; private List index; - - @Deprecated @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - private List name; - @Nullable private Time timeout; + public Builder() {} + + private Builder(DeleteAliasRequest o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.index = _listCopy(o.index); + this.masterTimeout = o.masterTimeout; + this.name = _listCopy(o.name); + this.timeout = o.timeout; + } + + private Builder(Builder o) { + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.index = _listCopy(o.index); + this.masterTimeout = o.masterTimeout; + this.name = _listCopy(o.name); + this.timeout = o.timeout; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** - * Required - A comma-separated list of index names (supports wildcards); use - * _all for all indices + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nonnull + 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} + *

+ */ + @Nonnull + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Required - Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (*). *

* API name: {@code index} + *

+ * *

* Adds all elements of list to index. + *

*/ + @Nonnull public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** - * Required - A comma-separated list of index names (supports wildcards); use - * _all for all indices + * Required - Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (*). *

* API name: {@code index} + *

+ * *

* Adds one or more values to index. + *

*/ + @Nonnull public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** - * Specify timeout for connection to master + * 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 master_timeout} + *

*/ @Deprecated + @Nonnull public final Builder masterTimeout(@Nullable Time value) { this.masterTimeout = value; return this; } /** - * Specify timeout for connection to master + * 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 master_timeout} + *

*/ @Deprecated + @Nonnull public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); + return 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()); - } - - /** - * Required - A comma-separated list of aliases to delete (supports wildcards); - * use _all to delete all aliases for the specified indices. + * Required - Comma-separated list of aliases to remove. Supports wildcards (*). To remove all aliases, use + * * or _all. *

* API name: {@code name} + *

+ * *

* Adds all elements of list to name. + *

*/ + @Nonnull public final Builder name(List list) { this.name = _listAddAll(this.name, list); return this; } /** - * Required - A comma-separated list of aliases to delete (supports wildcards); - * use _all to delete all aliases for the specified indices. + * Required - Comma-separated list of aliases to remove. Supports wildcards (*). To remove all aliases, use + * * or _all. *

* API name: {@code name} + *

+ * *

* Adds one or more values to name. + *

*/ + @Nonnull public final Builder name(String value, String... values) { this.name = _listAdd(this.name, value, values); return this; } /** - * Explicit timestamp for the document + * 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} + *

*/ + @Nonnull public final Builder timeout(@Nullable Time value) { this.timeout = value; return this; } /** - * Explicit timestamp for the document + * 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} + *

*/ + @Nonnull 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 DeleteAliasRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public DeleteAliasRequest build() { _checkSingleUse(); @@ -287,62 +360,56 @@ public DeleteAliasRequest build() { * Endpoint "{@code indices.delete_alias}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "DELETE"; - - }, - + request -> "DELETE", // Request path request -> { - final int _name = 1 << 0; - final int _index = 1 << 1; - - int propsSet = 0; - - propsSet |= _name; - propsSet |= _index; - - if (propsSet == (_index | _name)) { - StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - buf.append("/_alias"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name.stream().map(v -> v).collect(Collectors.joining(",")), buf); - return buf.toString(); - } - if (propsSet == (_index | _name)) { - StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - buf.append("/_aliases"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name.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); + buf.append("/_alias/"); + SimpleEndpoint.pathEncode(String.join(",", request.name), 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.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } return params; - }, SimpleEndpoint.emptyMap(), false, DeleteAliasResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + this.index.hashCode(); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + this.name.hashCode(); + 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; + DeleteAliasRequest other = (DeleteAliasRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && this.index.equals(other.index) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && this.name.equals(other.name) + && Objects.equals(this.timeout, other.timeout); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteAliasResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteAliasResponse.java similarity index 62% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteAliasResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteAliasResponse.java index 45f9a398d2..291e958910 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteAliasResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteAliasResponse.java @@ -30,39 +30,80 @@ * 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 javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.opensearch._types.AcknowledgedResponseBase; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.delete_alias.Response @JsonpDeserializable -public class DeleteAliasResponse extends AcknowledgedResponseBase { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class DeleteAliasResponse extends AcknowledgedResponseBase + implements + ToCopyableBuilder { + // --------------------------------------------------------------------------------------------- private DeleteAliasResponse(Builder builder) { super(builder); - } - public static DeleteAliasResponse of(Function> fn) { + public static DeleteAliasResponse of(Function> fn) { return fn.apply(new Builder()).build(); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link DeleteAliasResponse}. */ + public static class Builder extends AcknowledgedResponseBase.AbstractBuilder + implements + CopyableBuilder { + + public Builder() {} + + private Builder(DeleteAliasResponse o) { + super(o); + } + + private Builder(Builder o) { + super(o); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } - public static class Builder extends AcknowledgedResponseBase.AbstractBuilder implements ObjectBuilder { @Override + @Nonnull protected Builder self() { return this; } @@ -70,9 +111,10 @@ protected Builder self() { /** * Builds a {@link DeleteAliasResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public DeleteAliasResponse build() { _checkSingleUse(); @@ -91,8 +133,22 @@ public DeleteAliasResponse build() { ); protected static void setupDeleteAliasResponseDeserializer(ObjectDeserializer op) { - AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); + setupAcknowledgedResponseBaseDeserializer(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/ExistsAliasRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ExistsAliasRequest.java similarity index 55% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsAliasRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/ExistsAliasRequest.java index 225a5f1717..a5486e25de 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsAliasRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ExistsAliasRequest.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; @@ -46,55 +53,58 @@ import org.opensearch.client.transport.endpoints.BooleanResponse; import org.opensearch.client.transport.endpoints.SimpleEndpoint; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.exists_alias.Request /** * Returns information about whether a particular alias exists. - * */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class ExistsAliasRequest extends RequestBase implements ToCopyableBuilder { -public class ExistsAliasRequest extends RequestBase { @Nullable private final Boolean allowNoIndices; + @Nonnull private final List expandWildcards; @Nullable private final Boolean ignoreUnavailable; + @Nonnull private final List index; @Nullable private final Boolean local; + @Nonnull private final List name; // --------------------------------------------------------------------------------------------- private ExistsAliasRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.ignoreUnavailable = builder.ignoreUnavailable; this.index = ApiTypeHelper.unmodifiable(builder.index); this.local = builder.local; this.name = ApiTypeHelper.unmodifiableRequired(builder.name, this, "name"); - } - public static ExistsAliasRequest of(Function> fn) { + public static ExistsAliasRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Whether to ignore if a wildcard indices expression resolves into no concrete - * indices. (This includes _all string or when no indices have been - * specified) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets only + * missing or closed indexes. This behavior applies even if the request targets other open indexes. *

* API name: {@code allow_no_indices} + *

*/ @Nullable public final Boolean allowNoIndices() { @@ -102,20 +112,23 @@ public final Boolean allowNoIndices() { } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * 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; } /** - * Whether specified concrete indices should be ignored when unavailable - * (missing or closed) + * If false, requests that include a missing data stream or index in the target indexes or data streams return an error. *

* API name: {@code ignore_unavailable} + *

*/ @Nullable public final Boolean ignoreUnavailable() { @@ -123,19 +136,22 @@ public final Boolean ignoreUnavailable() { } /** - * A comma-separated list of index names to filter aliases + * Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (*). To target all data + * streams and indexes, omit this parameter or use * or _all. *

* 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() { @@ -143,141 +159,206 @@ public final Boolean local() { } /** - * Required - A comma-separated list of alias names to return + * Required - Comma-separated list of aliases to check. Supports wildcards (*). *

* API name: {@code name} + *

*/ + @Nonnull public final List name() { return this.name; } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link ExistsAliasRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private Boolean allowNoIndices; - @Nullable private List expandWildcards; - @Nullable private Boolean ignoreUnavailable; - @Nullable private List index; - @Nullable private Boolean local; - private List name; + public Builder() {} + + private Builder(ExistsAliasRequest o) { + this.allowNoIndices = o.allowNoIndices; + this.expandWildcards = _listCopy(o.expandWildcards); + this.ignoreUnavailable = o.ignoreUnavailable; + this.index = _listCopy(o.index); + this.local = o.local; + this.name = _listCopy(o.name); + } + + private Builder(Builder o) { + this.allowNoIndices = o.allowNoIndices; + this.expandWildcards = _listCopy(o.expandWildcards); + this.ignoreUnavailable = o.ignoreUnavailable; + this.index = _listCopy(o.index); + this.local = o.local; + this.name = _listCopy(o.name); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** - * Whether to ignore if a wildcard indices expression resolves into no concrete - * indices. (This includes _all string or when no indices have been - * specified) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets + * only missing or closed indexes. This behavior applies even if the request targets other open indexes. *

* API name: {@code allow_no_indices} + *

*/ + @Nonnull public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * 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. + *

*/ + @Nonnull public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * 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. + *

*/ + @Nonnull public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** - * Whether specified concrete indices should be ignored when unavailable - * (missing or closed) + * If false, requests that include a missing data stream or index in the target indexes or data streams return an + * error. *

* API name: {@code ignore_unavailable} + *

*/ + @Nonnull public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** - * A comma-separated list of index names to filter aliases + * Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (*). To target all + * data streams and indexes, omit this parameter or use * or _all. *

* API name: {@code index} + *

+ * *

* Adds all elements of list to index. + *

*/ + @Nonnull public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** - * A comma-separated list of index names to filter aliases + * Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (*). To target all + * data streams and indexes, omit this parameter or use * or _all. *

* API name: {@code index} + *

+ * *

* Adds one or more values to index. + *

*/ + @Nonnull public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** - * 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} + *

*/ + @Nonnull public final Builder local(@Nullable Boolean value) { this.local = value; return this; } /** - * Required - A comma-separated list of alias names to return + * Required - Comma-separated list of aliases to check. Supports wildcards (*). *

* API name: {@code name} + *

+ * *

* Adds all elements of list to name. + *

*/ + @Nonnull public final Builder name(List list) { this.name = _listAddAll(this.name, list); return this; } /** - * Required - A comma-separated list of alias names to return + * Required - Comma-separated list of aliases to check. Supports wildcards (*). *

* API name: {@code name} + *

+ * *

* Adds one or more values to name. + *

*/ + @Nonnull public final Builder name(String value, String... values) { this.name = _listAdd(this.name, value, values); return this; @@ -286,9 +367,10 @@ public final Builder name(String value, String... values) { /** * Builds a {@link ExistsAliasRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public ExistsAliasRequest build() { _checkSingleUse(); @@ -302,64 +384,77 @@ public ExistsAliasRequest build() { * Endpoint "{@code indices.exists_alias}". */ public static final Endpoint _ENDPOINT = new BooleanEndpoint<>( - "opensearch/indices.exists_alias", - // Request method - request -> { - return "HEAD"; - - }, - + request -> "HEAD", // Request path request -> { - final int _name = 1 << 0; - final int _index = 1 << 1; + final int _index = 1 << 0; + final int _name = 1 << 1; int propsSet = 0; - propsSet |= _name; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; + propsSet |= _name; - if (propsSet == (_name)) { + if (propsSet == (_index | _name)) { StringBuilder buf = new StringBuilder(); - buf.append("/_alias"); buf.append("/"); - SimpleEndpoint.pathEncode(request.name.stream().map(v -> v).collect(Collectors.joining(",")), buf); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + buf.append("/_alias/"); + SimpleEndpoint.pathEncode(String.join(",", request.name), buf); return buf.toString(); } - if (propsSet == (_index | _name)) { + if (propsSet == (_name)) { StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - buf.append("/_alias"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name.stream().map(v -> v).collect(Collectors.joining(",")), buf); + buf.append("/_alias/"); + SimpleEndpoint.pathEncode(String.join(",", request.name), buf); return buf.toString(); } - throw SimpleEndpoint.noPathTemplateFound("path"); + throw SimpleEndpoint.noPathTemplateFound("path"); }, - // Request parameters request -> { Map params = new HashMap<>(); + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); + } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } 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.local != null) { 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.expandWildcards); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + Objects.hashCode(this.index); + result = 31 * result + Objects.hashCode(this.local); + result = 31 * result + this.name.hashCode(); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + ExistsAliasRequest other = (ExistsAliasRequest) o; + return Objects.equals(this.allowNoIndices, other.allowNoIndices) + && Objects.equals(this.expandWildcards, other.expandWildcards) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.index, other.index) + && Objects.equals(this.local, other.local) + && this.name.equals(other.name); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetAliasRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetAliasRequest.java similarity index 55% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/GetAliasRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetAliasRequest.java index 391c6a635d..69c427fe1f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetAliasRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetAliasRequest.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; @@ -44,55 +51,58 @@ import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.SimpleEndpoint; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.get_alias.Request /** * Returns an alias. - * */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class GetAliasRequest extends RequestBase implements ToCopyableBuilder { -public class GetAliasRequest extends RequestBase { @Nullable private final Boolean allowNoIndices; + @Nonnull private final List expandWildcards; @Nullable private final Boolean ignoreUnavailable; + @Nonnull private final List index; @Nullable private final Boolean local; + @Nonnull private final List name; // --------------------------------------------------------------------------------------------- private GetAliasRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.ignoreUnavailable = builder.ignoreUnavailable; this.index = ApiTypeHelper.unmodifiable(builder.index); this.local = builder.local; this.name = ApiTypeHelper.unmodifiable(builder.name); - } - public static GetAliasRequest of(Function> fn) { + public static GetAliasRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Whether to ignore if a wildcard indices expression resolves into no concrete - * indices. (This includes _all string or when no indices have been - * specified) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets only + * missing or closed indexes. This behavior applies even if the request targets other open indexes. *

* API name: {@code allow_no_indices} + *

*/ @Nullable public final Boolean allowNoIndices() { @@ -100,20 +110,23 @@ public final Boolean allowNoIndices() { } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * 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; } /** - * Whether specified concrete indices should be ignored when unavailable - * (missing or closed) + * 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() { @@ -121,19 +134,22 @@ public final Boolean ignoreUnavailable() { } /** - * A comma-separated list of index names to filter aliases + * Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (*). To target all data + * streams and indexes, omit this parameter or use * or _all. *

* 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() { @@ -141,142 +157,209 @@ public final Boolean local() { } /** - * A comma-separated list of alias names to return + * Comma-separated list of aliases to retrieve. Supports wildcards (*). To retrieve all aliases, omit this parameter or use + * * or _all. *

* API name: {@code name} + *

*/ + @Nonnull public final List name() { return this.name; } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link GetAliasRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private Boolean allowNoIndices; - @Nullable private List expandWildcards; - @Nullable private Boolean ignoreUnavailable; - @Nullable private List index; - @Nullable private Boolean local; - @Nullable private List name; + public Builder() {} + + private Builder(GetAliasRequest o) { + this.allowNoIndices = o.allowNoIndices; + this.expandWildcards = _listCopy(o.expandWildcards); + this.ignoreUnavailable = o.ignoreUnavailable; + this.index = _listCopy(o.index); + this.local = o.local; + this.name = _listCopy(o.name); + } + + private Builder(Builder o) { + this.allowNoIndices = o.allowNoIndices; + this.expandWildcards = _listCopy(o.expandWildcards); + this.ignoreUnavailable = o.ignoreUnavailable; + this.index = _listCopy(o.index); + this.local = o.local; + this.name = _listCopy(o.name); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** - * Whether to ignore if a wildcard indices expression resolves into no concrete - * indices. (This includes _all string or when no indices have been - * specified) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets + * only missing or closed indexes. This behavior applies even if the request targets other open indexes. *

* API name: {@code allow_no_indices} + *

*/ + @Nonnull public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * 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. + *

*/ + @Nonnull public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * 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. + *

*/ + @Nonnull public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** - * Whether specified concrete indices should be ignored when unavailable - * (missing or closed) + * If false, the request returns an error if it targets a missing or closed index. *

* API name: {@code ignore_unavailable} + *

*/ + @Nonnull public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** - * A comma-separated list of index names to filter aliases + * Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (*). To target all + * data streams and indexes, omit this parameter or use * or _all. *

* API name: {@code index} + *

+ * *

* Adds all elements of list to index. + *

*/ + @Nonnull public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** - * A comma-separated list of index names to filter aliases + * Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (*). To target all + * data streams and indexes, omit this parameter or use * or _all. *

* API name: {@code index} + *

+ * *

* Adds one or more values to index. + *

*/ + @Nonnull public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** - * 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} + *

*/ + @Nonnull public final Builder local(@Nullable Boolean value) { this.local = value; return this; } /** - * A comma-separated list of alias names to return + * Comma-separated list of aliases to retrieve. Supports wildcards (*). To retrieve all aliases, omit this parameter or + * use * or _all. *

* API name: {@code name} + *

+ * *

* Adds all elements of list to name. + *

*/ + @Nonnull public final Builder name(List list) { this.name = _listAddAll(this.name, list); return this; } /** - * A comma-separated list of alias names to return + * Comma-separated list of aliases to retrieve. Supports wildcards (*). To retrieve all aliases, omit this parameter or + * use * or _all. *

* API name: {@code name} + *

+ * *

* Adds one or more values to name. + *

*/ + @Nonnull public final Builder name(String value, String... values) { this.name = _listAdd(this.name, value, values); return this; @@ -285,9 +368,10 @@ public final Builder name(String value, String... values) { /** * Builds a {@link GetAliasRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public GetAliasRequest build() { _checkSingleUse(); @@ -301,75 +385,89 @@ public GetAliasRequest build() { * Endpoint "{@code indices.get_alias}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "GET"; - - }, - + request -> "GET", // Request path request -> { - final int _name = 1 << 0; - final int _index = 1 << 1; + final int _index = 1 << 0; + final int _name = 1 << 1; int propsSet = 0; - if (ApiTypeHelper.isDefined(request.name())) propsSet |= _name; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; + if (ApiTypeHelper.isDefined(request.name())) propsSet |= _name; if (propsSet == 0) { - StringBuilder buf = new StringBuilder(); - buf.append("/_alias"); - return buf.toString(); + return "/_alias"; } - if (propsSet == (_name)) { + if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); - buf.append("/_alias"); buf.append("/"); - SimpleEndpoint.pathEncode(request.name.stream().map(v -> v).collect(Collectors.joining(",")), buf); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + buf.append("/_alias"); return buf.toString(); } if (propsSet == (_index | _name)) { StringBuilder buf = new StringBuilder(); buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - buf.append("/_alias"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name.stream().map(v -> v).collect(Collectors.joining(",")), buf); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + buf.append("/_alias/"); + SimpleEndpoint.pathEncode(String.join(",", request.name), buf); return buf.toString(); } - if (propsSet == (_index)) { + if (propsSet == (_name)) { StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - buf.append("/_alias"); + buf.append("/_alias/"); + SimpleEndpoint.pathEncode(String.join(",", request.name), buf); return buf.toString(); } - throw SimpleEndpoint.noPathTemplateFound("path"); + throw SimpleEndpoint.noPathTemplateFound("path"); }, - // Request parameters request -> { Map params = new HashMap<>(); + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); + } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } 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.local != null) { params.put("local", String.valueOf(request.local)); } return params; - }, SimpleEndpoint.emptyMap(), false, GetAliasResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allowNoIndices); + result = 31 * result + Objects.hashCode(this.expandWildcards); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + Objects.hashCode(this.index); + result = 31 * result + Objects.hashCode(this.local); + result = 31 * result + Objects.hashCode(this.name); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + GetAliasRequest other = (GetAliasRequest) o; + return Objects.equals(this.allowNoIndices, other.allowNoIndices) + && Objects.equals(this.expandWildcards, other.expandWildcards) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.index, other.index) + && Objects.equals(this.local, other.local) + && Objects.equals(this.name, other.name); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetAliasResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetAliasResponse.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/GetAliasResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetAliasResponse.java index 5ffbe81dee..a8ff732668 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetAliasResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetAliasResponse.java @@ -30,9 +30,15 @@ * 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 javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; @@ -44,15 +50,15 @@ // typedef: indices.get_alias.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetAliasResponse extends DictionaryResponse { // --------------------------------------------------------------------------------------------- private GetAliasResponse(Builder builder) { super(builder); - } - public static GetAliasResponse of(Function> fn) { + public static GetAliasResponse of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -61,11 +67,11 @@ public static GetAliasResponse of(Function implements ObjectBuilder { @Override + @Nonnull protected Builder self() { return this; } @@ -73,8 +79,7 @@ protected Builder self() { /** * Builds a {@link GetAliasResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public GetAliasResponse build() { _checkSingleUse(); @@ -96,8 +101,6 @@ public GetAliasResponse build() { ); protected static void setupGetAliasResponseDeserializer(ObjectDeserializer op) { - DictionaryResponse.setupDictionaryResponseDeserializer(op, JsonpDeserializer.stringDeserializer(), IndexAliases._DESERIALIZER); - + setupDictionaryResponseDeserializer(op, JsonpDeserializer.stringDeserializer(), IndexAliases._DESERIALIZER); } - } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetMappingRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetMappingRequest.java index baab0141c4..22723b2cf4 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetMappingRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetMappingRequest.java @@ -461,9 +461,6 @@ public GetMappingRequest build() { if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } - if (ApiTypeHelper.isDefined(request.index)) { - params.put("index", String.join(",", request.index)); - } if (request.local != null) { params.put("local", String.valueOf(request.local)); } 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 4e752a7ee1..be80746692 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 @@ -146,6 +146,26 @@ public final CompletableFuture delete(Function deleteAlias(DeleteAliasRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, DeleteAliasRequest._ENDPOINT, this.transportOptions); + } + + /** + * Deletes an alias. + * + * @param fn a function that initializes a builder to create the {@link DeleteAliasRequest} + */ + public final CompletableFuture deleteAlias( + Function> fn + ) throws IOException, OpenSearchException { + return deleteAlias(fn.apply(new DeleteAliasRequest.Builder()).build()); + } + // ----- Endpoint: indices.delete_data_stream /** @@ -227,6 +247,25 @@ public final CompletableFuture exists(Function existsAlias(ExistsAliasRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, ExistsAliasRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about whether a particular alias exists. + * + * @param fn a function that initializes a builder to create the {@link ExistsAliasRequest} + */ + public final CompletableFuture existsAlias(Function> fn) + throws IOException, OpenSearchException { + return existsAlias(fn.apply(new ExistsAliasRequest.Builder()).build()); + } + // ----- Endpoint: indices.exists_index_template /** @@ -287,6 +326,32 @@ public final CompletableFuture get(Function getAlias(GetAliasRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, GetAliasRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns an alias. + * + * @param fn a function that initializes a builder to create the {@link GetAliasRequest} + */ + public final CompletableFuture getAlias(Function> fn) + throws IOException, OpenSearchException { + return getAlias(fn.apply(new GetAliasRequest.Builder()).build()); + } + + /** + * Returns an alias. + */ + public final CompletableFuture getAlias() throws IOException, OpenSearchException { + return getAlias(new GetAliasRequest.Builder().build()); + } + // ----- Endpoint: indices.get_data_stream /** @@ -423,6 +488,32 @@ public final CompletableFuture getTemplate() throws IOExcep return getTemplate(new GetTemplateRequest.Builder().build()); } + // ----- Endpoint: indices.put_alias + + /** + * Creates or updates an alias. + */ + public CompletableFuture putAlias(PutAliasRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, PutAliasRequest._ENDPOINT, this.transportOptions); + } + + /** + * Creates or updates an alias. + * + * @param fn a function that initializes a builder to create the {@link PutAliasRequest} + */ + public final CompletableFuture putAlias(Function> fn) + throws IOException, OpenSearchException { + return putAlias(fn.apply(new PutAliasRequest.Builder()).build()); + } + + /** + * Creates or updates an alias. + */ + public final CompletableFuture putAlias() throws IOException, OpenSearchException { + return putAlias(new PutAliasRequest.Builder().build()); + } + // ----- Endpoint: indices.put_index_template /** @@ -545,4 +636,31 @@ public final CompletableFuture simulateTemplate( ) throws IOException, OpenSearchException { return simulateTemplate(fn.apply(new SimulateTemplateRequest.Builder()).build()); } + + // ----- Endpoint: indices.update_aliases + + /** + * Updates index aliases. + */ + public CompletableFuture updateAliases(UpdateAliasesRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, UpdateAliasesRequest._ENDPOINT, this.transportOptions); + } + + /** + * Updates index aliases. + * + * @param fn a function that initializes a builder to create the {@link UpdateAliasesRequest} + */ + public final CompletableFuture updateAliases( + Function> fn + ) throws IOException, OpenSearchException { + return updateAliases(fn.apply(new UpdateAliasesRequest.Builder()).build()); + } + + /** + * Updates index aliases. + */ + public final CompletableFuture updateAliases() throws IOException, OpenSearchException { + return updateAliases(new UpdateAliasesRequest.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 index d0acea740b..8a8738d0d9 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 @@ -143,6 +143,25 @@ public final DeleteIndexResponse delete(Function> fn) + throws IOException, OpenSearchException { + return deleteAlias(fn.apply(new DeleteAliasRequest.Builder()).build()); + } + // ----- Endpoint: indices.delete_data_stream /** @@ -221,6 +240,25 @@ public final BooleanResponse exists(Function> fn) throws IOException, + OpenSearchException { + return existsAlias(fn.apply(new ExistsAliasRequest.Builder()).build()); + } + // ----- Endpoint: indices.exists_index_template /** @@ -279,6 +317,32 @@ public final GetIndexResponse get(Function> fn) throws IOException, + OpenSearchException { + return getAlias(fn.apply(new GetAliasRequest.Builder()).build()); + } + + /** + * Returns an alias. + */ + public final GetAliasResponse getAlias() throws IOException, OpenSearchException { + return getAlias(new GetAliasRequest.Builder().build()); + } + // ----- Endpoint: indices.get_data_stream /** @@ -411,6 +475,32 @@ public final GetTemplateResponse getTemplate() throws IOException, OpenSearchExc return getTemplate(new GetTemplateRequest.Builder().build()); } + // ----- Endpoint: indices.put_alias + + /** + * Creates or updates an alias. + */ + public PutAliasResponse putAlias(PutAliasRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, PutAliasRequest._ENDPOINT, this.transportOptions); + } + + /** + * Creates or updates an alias. + * + * @param fn a function that initializes a builder to create the {@link PutAliasRequest} + */ + public final PutAliasResponse putAlias(Function> fn) throws IOException, + OpenSearchException { + return putAlias(fn.apply(new PutAliasRequest.Builder()).build()); + } + + /** + * Creates or updates an alias. + */ + public final PutAliasResponse putAlias() throws IOException, OpenSearchException { + return putAlias(new PutAliasRequest.Builder().build()); + } + // ----- Endpoint: indices.put_index_template /** @@ -529,4 +619,30 @@ public final SimulateTemplateResponse simulateTemplate( ) throws IOException, OpenSearchException { return simulateTemplate(fn.apply(new SimulateTemplateRequest.Builder()).build()); } + + // ----- Endpoint: indices.update_aliases + + /** + * Updates index aliases. + */ + public UpdateAliasesResponse updateAliases(UpdateAliasesRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, UpdateAliasesRequest._ENDPOINT, this.transportOptions); + } + + /** + * Updates index aliases. + * + * @param fn a function that initializes a builder to create the {@link UpdateAliasesRequest} + */ + public final UpdateAliasesResponse updateAliases(Function> fn) + throws IOException, OpenSearchException { + return updateAliases(fn.apply(new UpdateAliasesRequest.Builder()).build()); + } + + /** + * Updates index aliases. + */ + public final UpdateAliasesResponse updateAliases() throws IOException, OpenSearchException { + return updateAliases(new UpdateAliasesRequest.Builder().build()); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java similarity index 54% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java index ee78e89b7a..243a20b7b0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java @@ -30,14 +30,20 @@ * 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.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.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -52,25 +58,41 @@ import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.SimpleEndpoint; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.put_alias.Request /** * Creates or updates an alias. - * */ @JsonpDeserializable -public class PutAliasRequest extends RequestBase implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class PutAliasRequest extends RequestBase + implements + PlainJsonSerializable, + ToCopyableBuilder { + + @Nullable + private final String alias; + + @Nullable + private final Time clusterManagerTimeout; + @Nullable private final Query filter; + @Nonnull private final List index; @Nullable private final String indexRouting; + @Nullable + private final Boolean isHidden; + @Nullable private final Boolean isWriteIndex; @@ -79,8 +101,6 @@ public class PutAliasRequest extends RequestBase implements PlainJsonSerializabl private final Time masterTimeout; @Nullable - private final Time clusterManagerTimeout; - private final String name; @Nullable @@ -95,24 +115,43 @@ public class PutAliasRequest extends RequestBase implements PlainJsonSerializabl // --------------------------------------------------------------------------------------------- private PutAliasRequest(Builder builder) { - + this.alias = builder.alias; + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.filter = builder.filter; - this.index = ApiTypeHelper.unmodifiableRequired(builder.index, this, "index"); + this.index = ApiTypeHelper.unmodifiable(builder.index); this.indexRouting = builder.indexRouting; + this.isHidden = builder.isHidden; this.isWriteIndex = builder.isWriteIndex; this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); + this.name = builder.name; this.routing = builder.routing; this.searchRouting = builder.searchRouting; this.timeout = builder.timeout; - } - public static PutAliasRequest of(Function> fn) { + public static PutAliasRequest of(Function> fn) { return fn.apply(new Builder()).build(); } + /** + * API name: {@code alias} + */ + @Nullable + public final String alias() { + return this.alias; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + /** * API name: {@code filter} */ @@ -122,12 +161,13 @@ public final Query filter() { } /** - * Required - A comma-separated list of index names the alias should point to - * (supports wildcards); use _all to perform the operation on all - * indices. + * Comma-separated list of data streams or indexes to add. Supports wildcards (*). Wildcard patterns that match both data + * streams and indexes return an error. *

* API name: {@code index} + *

*/ + @Nonnull public final List index() { return this.index; } @@ -141,7 +181,24 @@ public final String indexRouting() { } /** + * If true, the alias will be hidden`. + *

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

+ */ + @Nullable + public final Boolean isHidden() { + return this.isHidden; + } + + /** + * If true, sets the write index or data stream for the alias. If an alias points to multiple indexes or data streams and + * is_write_index isn't set, the alias rejects write requests. If an index alias points to one index and + * is_write_index isn't set, the index automatically acts as the write index. Data stream aliases don't automatically set a + * write data stream, even if the alias points to one data stream. + *

* API name: {@code is_write_index} + *

*/ @Nullable public final Boolean isWriteIndex() { @@ -149,9 +206,11 @@ public final Boolean isWriteIndex() { } /** - * Specify timeout for connection to master + * 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 master_timeout} + *

*/ @Deprecated @Nullable @@ -160,20 +219,12 @@ 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; - } - - /** - * Required - The name of the alias to be created or updated + * Alias to update. If the alias doesn't exist, the request creates it. Index alias names support date math. *

* API name: {@code name} + *

*/ + @Nullable public final String name() { return this.name; } @@ -195,9 +246,10 @@ public final String searchRouting() { } /** - * Explicit timestamp for the document + * 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() { @@ -207,6 +259,7 @@ public final Time timeout() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -214,74 +267,157 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.alias != null) { + generator.writeKey("alias"); + generator.write(this.alias); + } 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); - } + } + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link PutAliasRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable + private String alias; + @Nullable + private Time clusterManagerTimeout; @Nullable private Query filter; - + @Nullable private List index; - @Nullable private String indexRouting; - + @Nullable + private Boolean isHidden; @Nullable private Boolean isWriteIndex; - - @Deprecated @Nullable private Time masterTimeout; - @Nullable - private Time clusterManagerTimeout; - private String name; - @Nullable private String routing; - @Nullable private String searchRouting; - @Nullable private Time timeout; + public Builder() {} + + private Builder(PutAliasRequest o) { + this.alias = o.alias; + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.filter = o.filter; + this.index = _listCopy(o.index); + this.indexRouting = o.indexRouting; + this.isHidden = o.isHidden; + this.isWriteIndex = o.isWriteIndex; + this.masterTimeout = o.masterTimeout; + this.name = o.name; + this.routing = o.routing; + this.searchRouting = o.searchRouting; + this.timeout = o.timeout; + } + + private Builder(Builder o) { + this.alias = o.alias; + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.filter = o.filter; + this.index = _listCopy(o.index); + this.indexRouting = o.indexRouting; + this.isHidden = o.isHidden; + this.isWriteIndex = o.isWriteIndex; + this.masterTimeout = o.masterTimeout; + this.name = o.name; + this.routing = o.routing; + this.searchRouting = o.searchRouting; + this.timeout = o.timeout; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + + /** + * API name: {@code alias} + */ + @Nonnull + public final Builder alias(@Nullable String value) { + this.alias = value; + return this; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nonnull + 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} + *

+ */ + @Nonnull + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + /** * API name: {@code filter} */ + @Nonnull public final Builder filter(@Nullable Query value) { this.filter = value; return this; @@ -290,33 +426,40 @@ public final Builder filter(@Nullable Query value) { /** * API name: {@code filter} */ + @Nonnull public final Builder filter(Function> fn) { - return this.filter(fn.apply(new Query.Builder()).build()); + return filter(fn.apply(new Query.Builder()).build()); } /** - * Required - A comma-separated list of index names the alias should point to - * (supports wildcards); use _all to perform the operation on all - * indices. + * Comma-separated list of data streams or indexes to add. Supports wildcards (*). Wildcard patterns that match both + * data streams and indexes return an error. *

* API name: {@code index} + *

+ * *

* Adds all elements of list to index. + *

*/ + @Nonnull public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** - * Required - A comma-separated list of index names the alias should point to - * (supports wildcards); use _all to perform the operation on all - * indices. + * Comma-separated list of data streams or indexes to add. Supports wildcards (*). Wildcard patterns that match both + * data streams and indexes return an error. *

* API name: {@code index} + *

+ * *

* Adds one or more values to index. + *

*/ + @Nonnull public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; @@ -325,65 +468,74 @@ public final Builder index(String value, String... values) { /** * API name: {@code index_routing} */ + @Nonnull public final Builder indexRouting(@Nullable String value) { this.indexRouting = value; return this; } /** + * If true, the alias will be hidden`. + *

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

+ */ + @Nonnull + public final Builder isHidden(@Nullable Boolean value) { + this.isHidden = value; + return this; + } + + /** + * If true, sets the write index or data stream for the alias. If an alias points to multiple indexes or data streams + * and is_write_index isn't set, the alias rejects write requests. If an index alias points to one index and + * is_write_index isn't set, the index automatically acts as the write index. Data stream aliases don't automatically + * set a write data stream, even if the alias points to one data stream. + *

* API name: {@code is_write_index} + *

*/ + @Nonnull public final Builder isWriteIndex(@Nullable Boolean value) { this.isWriteIndex = value; return this; } /** - * Specify timeout for connection to master + * 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 master_timeout} + *

*/ @Deprecated + @Nonnull public final Builder masterTimeout(@Nullable Time value) { this.masterTimeout = value; return this; } /** - * Specify timeout for connection to master + * 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 master_timeout} + *

*/ @Deprecated + @Nonnull 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()); } /** - * Required - The name of the alias to be created or updated + * Alias to update. If the alias doesn't exist, the request creates it. Index alias names support date math. *

* API name: {@code name} + *

*/ - public final Builder name(String value) { + @Nonnull + public final Builder name(@Nullable String value) { this.name = value; return this; } @@ -391,6 +543,7 @@ public final Builder name(String value) { /** * API name: {@code routing} */ + @Nonnull public final Builder routing(@Nullable String value) { this.routing = value; return this; @@ -399,36 +552,42 @@ public final Builder routing(@Nullable String value) { /** * API name: {@code search_routing} */ + @Nonnull public final Builder searchRouting(@Nullable String value) { this.searchRouting = value; return this; } /** - * Explicit timestamp for the document + * 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} + *

*/ + @Nonnull public final Builder timeout(@Nullable Time value) { this.timeout = value; return this; } /** - * Explicit timestamp for the document + * 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} + *

*/ + @Nonnull 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 PutAliasRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public PutAliasRequest build() { _checkSingleUse(); @@ -447,13 +606,15 @@ public PutAliasRequest build() { ); protected static void setupPutAliasRequestDeserializer(ObjectDeserializer op) { - + op.add(Builder::alias, JsonpDeserializer.stringDeserializer(), "alias"); op.add(Builder::filter, Query._DESERIALIZER, "filter"); + op.add(Builder::index, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "index"); 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::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "routing"); op.add(Builder::searchRouting, JsonpDeserializer.stringDeserializer(), "search_routing"); - } // --------------------------------------------------------------------------------------------- @@ -462,62 +623,98 @@ protected static void setupPutAliasRequestDeserializer(ObjectDeserializer _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "PUT"; - - }, - + request -> "PUT", // Request path request -> { - final int _name = 1 << 0; - final int _index = 1 << 1; + final int _index = 1 << 0; + final int _name = 1 << 1; int propsSet = 0; - propsSet |= _name; - propsSet |= _index; + if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; + if (request.name() != null) propsSet |= _name; - if (propsSet == (_index | _name)) { + if (propsSet == 0) { + return "/_alias"; + } + if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); buf.append("/_alias"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name, buf); return buf.toString(); } if (propsSet == (_index | _name)) { StringBuilder buf = new StringBuilder(); buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - buf.append("/_aliases"); - buf.append("/"); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + buf.append("/_alias/"); + SimpleEndpoint.pathEncode(request.name, buf); + return buf.toString(); + } + if (propsSet == (_name)) { + StringBuilder buf = new StringBuilder(); + buf.append("/_alias/"); SimpleEndpoint.pathEncode(request.name, buf); return buf.toString(); } - throw SimpleEndpoint.noPathTemplateFound("path"); + throw SimpleEndpoint.noPathTemplateFound("path"); }, - // 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.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } return params; - }, SimpleEndpoint.emptyMap(), true, PutAliasResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.alias); + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.filter); + result = 31 * result + Objects.hashCode(this.index); + 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.masterTimeout); + result = 31 * result + Objects.hashCode(this.name); + result = 31 * result + Objects.hashCode(this.routing); + result = 31 * result + Objects.hashCode(this.searchRouting); + 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; + PutAliasRequest other = (PutAliasRequest) o; + return Objects.equals(this.alias, other.alias) + && Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.filter, other.filter) + && Objects.equals(this.index, other.index) + && Objects.equals(this.indexRouting, other.indexRouting) + && Objects.equals(this.isHidden, other.isHidden) + && Objects.equals(this.isWriteIndex, other.isWriteIndex) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && Objects.equals(this.name, other.name) + && Objects.equals(this.routing, other.routing) + && Objects.equals(this.searchRouting, other.searchRouting) + && Objects.equals(this.timeout, other.timeout); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/PutAliasResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutAliasResponse.java similarity index 61% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/PutAliasResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutAliasResponse.java index aee5a38a9b..777606ce9e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/PutAliasResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutAliasResponse.java @@ -30,39 +30,78 @@ * 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 javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.opensearch._types.AcknowledgedResponseBase; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.put_alias.Response @JsonpDeserializable -public class PutAliasResponse extends AcknowledgedResponseBase { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class PutAliasResponse extends AcknowledgedResponseBase implements ToCopyableBuilder { + // --------------------------------------------------------------------------------------------- private PutAliasResponse(Builder builder) { super(builder); - } - public static PutAliasResponse of(Function> fn) { + public static PutAliasResponse of(Function> fn) { return fn.apply(new Builder()).build(); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link PutAliasResponse}. */ + public static class Builder extends AcknowledgedResponseBase.AbstractBuilder + implements + CopyableBuilder { + + public Builder() {} + + private Builder(PutAliasResponse o) { + super(o); + } + + private Builder(Builder o) { + super(o); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } - public static class Builder extends AcknowledgedResponseBase.AbstractBuilder implements ObjectBuilder { @Override + @Nonnull protected Builder self() { return this; } @@ -70,9 +109,10 @@ protected Builder self() { /** * Builds a {@link PutAliasResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public PutAliasResponse build() { _checkSingleUse(); @@ -91,8 +131,22 @@ public PutAliasResponse build() { ); protected static void setupPutAliasResponseDeserializer(ObjectDeserializer op) { - AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); + setupAcknowledgedResponseBaseDeserializer(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/UpdateAliasesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/UpdateAliasesRequest.java similarity index 65% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/UpdateAliasesRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/UpdateAliasesRequest.java index a9e3d29d0c..633d6255d6 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/UpdateAliasesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/UpdateAliasesRequest.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 jakarta.json.stream.JsonGenerator; import java.util.HashMap; 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.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -51,25 +58,32 @@ import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.SimpleEndpoint; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.update_aliases.Request /** * Updates index aliases. - * */ @JsonpDeserializable -public class UpdateAliasesRequest extends RequestBase implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class UpdateAliasesRequest extends RequestBase + implements + PlainJsonSerializable, + ToCopyableBuilder { + + @Nonnull private final List actions; - @Deprecated @Nullable - private final Time masterTimeout; + private final Time clusterManagerTimeout; + @Deprecated @Nullable - private final Time clusterManagerTimeout; + private final Time masterTimeout; @Nullable private final Time timeout; @@ -77,50 +91,56 @@ public class UpdateAliasesRequest extends RequestBase implements PlainJsonSerial // --------------------------------------------------------------------------------------------- private UpdateAliasesRequest(Builder builder) { - this.actions = ApiTypeHelper.unmodifiable(builder.actions); - this.masterTimeout = builder.masterTimeout; this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.masterTimeout = builder.masterTimeout; this.timeout = builder.timeout; - } - public static UpdateAliasesRequest of(Function> fn) { + public static UpdateAliasesRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** + * Actions to perform. + *

* API name: {@code actions} + *

*/ + @Nonnull public final List actions() { return this.actions; } /** - * Specify timeout for connection to master + * Operation timeout for connection to cluster-manager node. *

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

*/ - @Deprecated @Nullable - public final Time masterTimeout() { - return this.masterTimeout; + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; } /** - * Specify timeout for connection to cluster-manager + * 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} + * API name: {@code master_timeout} + *

*/ + @Deprecated @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; + public final Time masterTimeout() { + return this.masterTimeout; } /** - * Request 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() { @@ -130,6 +150,7 @@ public final Time timeout() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -137,134 +158,190 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.actions)) { generator.writeKey("actions"); generator.writeStartArray(); for (Action item0 : this.actions) { item0.serialize(generator, mapper); - } generator.writeEnd(); - } + } + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link UpdateAliasesRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private List actions; - - @Deprecated - @Nullable - private Time masterTimeout; - @Nullable private Time clusterManagerTimeout; - + @Nullable + private Time masterTimeout; @Nullable private Time timeout; + public Builder() {} + + private Builder(UpdateAliasesRequest o) { + this.actions = _listCopy(o.actions); + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.masterTimeout = o.masterTimeout; + this.timeout = o.timeout; + } + + private Builder(Builder o) { + this.actions = _listCopy(o.actions); + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.masterTimeout = o.masterTimeout; + this.timeout = o.timeout; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** + * Actions to perform. + *

* API name: {@code actions} + *

+ * *

* Adds all elements of list to actions. + *

*/ + @Nonnull public final Builder actions(List list) { this.actions = _listAddAll(this.actions, list); return this; } /** + * Actions to perform. + *

* API name: {@code actions} + *

+ * *

* Adds one or more values to actions. + *

*/ + @Nonnull public final Builder actions(Action value, Action... values) { this.actions = _listAdd(this.actions, value, values); return this; } /** + * Actions to perform. + *

* API name: {@code actions} + *

+ * *

* Adds a value to actions using a builder lambda. + *

*/ + @Nonnull public final Builder actions(Function> fn) { return actions(fn.apply(new Action.Builder()).build()); } /** - * Specify timeout for connection to master + * Operation timeout for connection to cluster-manager node. *

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

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

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

*/ - @Deprecated - public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); + @Nonnull + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); } /** - * Specify timeout for connection to cluster-manager + * 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} + * API name: {@code master_timeout} + *

*/ - public final Builder clusterManagerTimeout(@Nullable Time value) { - this.clusterManagerTimeout = value; + @Deprecated + @Nonnull + public final Builder masterTimeout(@Nullable Time value) { + this.masterTimeout = value; return this; } /** - * Specify timeout for connection to cluster-manager + * 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} + * API name: {@code master_timeout} + *

*/ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + @Deprecated + @Nonnull + public final Builder masterTimeout(Function> fn) { + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** - * Request 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} + *

*/ + @Nonnull public final Builder timeout(@Nullable Time value) { this.timeout = value; return this; } /** - * Request 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} + *

*/ + @Nonnull 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 UpdateAliasesRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public UpdateAliasesRequest build() { _checkSingleUse(); @@ -283,9 +360,7 @@ public UpdateAliasesRequest build() { ); protected static void setupUpdateAliasesRequestDeserializer(ObjectDeserializer op) { - op.add(Builder::actions, JsonpDeserializer.arrayDeserializer(Action._DESERIALIZER), "actions"); - } // --------------------------------------------------------------------------------------------- @@ -294,36 +369,47 @@ protected static void setupUpdateAliasesRequestDeserializer(ObjectDeserializer _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "POST"; - - }, - + request -> "POST", // Request path - request -> { - return "/_aliases"; - - }, - + request -> "/_aliases", // 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.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } return params; - }, SimpleEndpoint.emptyMap(), true, UpdateAliasesResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.actions); + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + 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; + UpdateAliasesRequest other = (UpdateAliasesRequest) o; + return Objects.equals(this.actions, other.actions) + && Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && 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/UpdateAliasesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/UpdateAliasesResponse.java similarity index 62% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/UpdateAliasesResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/UpdateAliasesResponse.java index c2d4e215b4..e2c69c855d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/UpdateAliasesResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/UpdateAliasesResponse.java @@ -30,39 +30,80 @@ * 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 javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.opensearch._types.AcknowledgedResponseBase; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.update_aliases.Response @JsonpDeserializable -public class UpdateAliasesResponse extends AcknowledgedResponseBase { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class UpdateAliasesResponse extends AcknowledgedResponseBase + implements + ToCopyableBuilder { + // --------------------------------------------------------------------------------------------- private UpdateAliasesResponse(Builder builder) { super(builder); - } - public static UpdateAliasesResponse of(Function> fn) { + public static UpdateAliasesResponse of(Function> fn) { return fn.apply(new Builder()).build(); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link UpdateAliasesResponse}. */ + public static class Builder extends AcknowledgedResponseBase.AbstractBuilder + implements + CopyableBuilder { + + public Builder() {} + + private Builder(UpdateAliasesResponse o) { + super(o); + } + + private Builder(Builder o) { + super(o); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } - public static class Builder extends AcknowledgedResponseBase.AbstractBuilder implements ObjectBuilder { @Override + @Nonnull protected Builder self() { return this; } @@ -70,9 +111,10 @@ protected Builder self() { /** * Builds a {@link UpdateAliasesResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public UpdateAliasesResponse build() { _checkSingleUse(); @@ -91,8 +133,22 @@ public UpdateAliasesResponse build() { ); protected static void setupUpdateAliasesResponseDeserializer(ObjectDeserializer op) { - AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); + setupAcknowledgedResponseBaseDeserializer(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/get_alias/IndexAliases.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/get_alias/IndexAliases.java similarity index 66% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/get_alias/IndexAliases.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/get_alias/IndexAliases.java index 7cc67a7562..b977b85284 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/get_alias/IndexAliases.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/get_alias/IndexAliases.java @@ -30,11 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.get_alias; import jakarta.json.stream.JsonGenerator; import java.util.Map; 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; @@ -43,30 +49,34 @@ import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.opensearch.indices.AliasDefinition; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.get_alias.IndexAliases @JsonpDeserializable -public class IndexAliases implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class IndexAliases implements PlainJsonSerializable, ToCopyableBuilder { + + @Nonnull private final Map aliases; // --------------------------------------------------------------------------------------------- private IndexAliases(Builder builder) { - this.aliases = ApiTypeHelper.unmodifiableRequired(builder.aliases, this, "aliases"); - } - public static IndexAliases of(Function> fn) { + public static IndexAliases of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code aliases} */ + @Nonnull public final Map aliases() { return this.aliases; } @@ -74,6 +84,7 @@ public final Map aliases() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -81,35 +92,58 @@ 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(); - + generator.writeKey("aliases"); + generator.writeStartObject(); + for (Map.Entry item0 : this.aliases.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); } - + generator.writeEnd(); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link IndexAliases}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private Map aliases; + public Builder() {} + + private Builder(IndexAliases o) { + this.aliases = _mapCopy(o.aliases); + } + + private Builder(Builder o) { + this.aliases = _mapCopy(o.aliases); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * Required - API name: {@code aliases} + * *

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

*/ + @Nonnull public final Builder aliases(Map map) { this.aliases = _mapPutAll(this.aliases, map); return this; @@ -117,9 +151,12 @@ public final Builder aliases(Map map) { /** * Required - API name: {@code aliases} + * *

* Adds an entry to aliases. + *

*/ + @Nonnull public final Builder aliases(String key, AliasDefinition value) { this.aliases = _mapPut(this.aliases, key, value); return this; @@ -127,9 +164,12 @@ public final Builder aliases(String key, AliasDefinition value) { /** * Required - API name: {@code aliases} + * *

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

*/ + @Nonnull public final Builder aliases(String key, Function> fn) { return aliases(key, fn.apply(new AliasDefinition.Builder()).build()); } @@ -137,9 +177,10 @@ public final Builder aliases(String key, Function op) { - op.add(Builder::aliases, JsonpDeserializer.stringMapDeserializer(AliasDefinition._DESERIALIZER), "aliases"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.aliases.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndexAliases other = (IndexAliases) o; + return this.aliases.equals(other.aliases); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/Action.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/Action.java similarity index 76% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/Action.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/Action.java index 708b8a8477..2f31b802fe 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/Action.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/Action.java @@ -30,10 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.update_aliases; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -41,6 +48,7 @@ import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; @@ -50,23 +58,15 @@ // typedef: indices.update_aliases.Action @JsonpDeserializable -public class Action implements TaggedUnion, JsonpSerializable { - - /** - * {@link Action} variant kinds. - */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class Action implements TaggedUnion, PlainJsonSerializable { /** * {@link Action} variant kinds. */ - public enum Kind implements JsonEnum { Add("add"), - Remove("remove"), - - RemoveIndex("remove_index"), - - ; + RemoveIndex("remove_index"); private final String jsonValue; @@ -74,14 +74,14 @@ public enum Kind implements JsonEnum { this.jsonValue = jsonValue; } + @Override public String jsonValue() { - return this.jsonValue; + return jsonValue; } - } private final Kind _kind; - private final Object _value; + private final ActionVariant _value; @Override public final Kind _kind() { @@ -89,25 +89,21 @@ public final Kind _kind() { } @Override - public final Object _get() { + public final ActionVariant _get() { return _value; } public Action(ActionVariant value) { - this._kind = ApiTypeHelper.requireNonNull(value._actionKind(), this, ""); this._value = ApiTypeHelper.requireNonNull(value, this, ""); - } private Action(Builder builder) { - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - } - public static Action of(Function> fn) { + public static Action of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -121,8 +117,7 @@ public boolean isAdd() { /** * Get the {@code add} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code add} kind. + * @throws IllegalStateException if the current variant is not the {@code add} kind. */ public AddAction add() { return TaggedUnionUtils.get(this, Kind.Add); @@ -138,8 +133,7 @@ public boolean isRemove() { /** * Get the {@code remove} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code remove} kind. + * @throws IllegalStateException if the current variant is not the {@code remove} kind. */ public RemoveAction remove() { return TaggedUnionUtils.get(this, Kind.Remove); @@ -155,31 +149,42 @@ public boolean isRemoveIndex() { /** * Get the {@code remove_index} variant value. * - * @throws IllegalStateException - * if the current variant is not of the {@code remove_index} kind. + * @throws IllegalStateException if the current variant is not the {@code remove_index} kind. */ public RemoveIndexAction removeIndex() { return TaggedUnionUtils.get(this, Kind.RemoveIndex); } @Override - @SuppressWarnings("unchecked") public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - generator.writeKey(_kind.jsonValue()); if (_value instanceof JsonpSerializable) { ((JsonpSerializable) _value).serialize(generator, mapper); } - generator.writeEnd(); + } + + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + @Nonnull + public static Builder builder() { + return new Builder(); } public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Kind _kind; - private Object _value; + private ActionVariant _value; + + public Builder() {} + + private Builder(Action o) { + this._kind = o._kind; + this._value = o._value; + } public ObjectBuilder add(AddAction v) { this._kind = Kind.Add; @@ -211,19 +216,17 @@ public ObjectBuilder removeIndex(Function op) { - op.add(Builder::add, AddAction._DESERIALIZER, "add"); op.add(Builder::remove, RemoveAction._DESERIALIZER, "remove"); op.add(Builder::removeIndex, RemoveIndexAction._DESERIALIZER, "remove_index"); - } public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( @@ -231,4 +234,20 @@ protected static void setupActionDeserializer(ObjectDeserializer op) { Action::setupActionDeserializer, Builder::build ); + + @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; + Action other = (Action) 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/update_aliases/ActionBuilders.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/ActionBuilders.java similarity index 86% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/ActionBuilders.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/ActionBuilders.java index eb7408cda7..db44ed997a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/ActionBuilders.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/ActionBuilders.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.update_aliases; +import javax.annotation.Generated; + /** * Builders for {@link Action} variants. */ +@Generated("org.opensearch.client.codegen.CodeGenerator") public class ActionBuilders { private ActionBuilders() {} @@ -53,11 +60,9 @@ public static RemoveAction.Builder remove() { } /** - * Creates a builder for the {@link RemoveIndexAction remove_index} - * {@code Action} variant. + * Creates a builder for the {@link RemoveIndexAction remove_index} {@code Action} variant. */ public static RemoveIndexAction.Builder removeIndex() { return new RemoveIndexAction.Builder(); } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/ActionVariant.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/ActionVariant.java similarity index 82% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/ActionVariant.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/ActionVariant.java index a36046777b..f717530c14 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/ActionVariant.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/ActionVariant.java @@ -30,17 +30,22 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.update_aliases; +import javax.annotation.Generated; + /** * Base interface for {@link Action} variants. */ +@Generated("org.opensearch.client.codegen.CodeGenerator") public interface ActionVariant { - Action.Kind _actionKind(); - default Action _toAction() { + default Action toAction() { return new Action(this); } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/AddAction.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/AddAction.java similarity index 66% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/AddAction.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/AddAction.java index cbbd6ff830..4dad6fde3f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/AddAction.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/AddAction.java @@ -30,30 +30,42 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.update_aliases; 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; import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.opensearch._types.query_dsl.Query; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.update_aliases.AddAction @JsonpDeserializable -public class AddAction implements ActionVariant, JsonpSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class AddAction implements ActionVariant, PlainJsonSerializable, ToCopyableBuilder { + @Nullable private final String alias; + @Nonnull private final List aliases; @Nullable @@ -62,17 +74,21 @@ public class AddAction implements ActionVariant, JsonpSerializable { @Nullable private final String index; - private final List indices; - @Nullable private final String indexRouting; + @Nonnull + private final List indices; + @Nullable private final Boolean isHidden; @Nullable private final Boolean isWriteIndex; + @Nullable + private final Boolean mustExist; + @Nullable private final String routing; @@ -82,26 +98,25 @@ public class AddAction implements ActionVariant, JsonpSerializable { // --------------------------------------------------------------------------------------------- private AddAction(Builder builder) { - this.alias = builder.alias; this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); this.filter = builder.filter; this.index = builder.index; - this.indices = ApiTypeHelper.unmodifiable(builder.indices); this.indexRouting = builder.indexRouting; + this.indices = ApiTypeHelper.unmodifiable(builder.indices); this.isHidden = builder.isHidden; this.isWriteIndex = builder.isWriteIndex; + this.mustExist = builder.mustExist; this.routing = builder.routing; this.searchRouting = builder.searchRouting; - } - public static AddAction of(Function> fn) { + public static AddAction of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Action variant kind. + * {@link Action} variant kind. */ @Override public Action.Kind _actionKind() { @@ -117,8 +132,12 @@ public final String alias() { } /** + * Aliases for the action. Index alias names support date math. + *

* API name: {@code aliases} + *

*/ + @Nonnull public final List aliases() { return this.aliases; } @@ -139,13 +158,6 @@ public final String index() { return this.index; } - /** - * API name: {@code indices} - */ - public final List indices() { - return this.indices; - } - /** * API name: {@code index_routing} */ @@ -155,7 +167,18 @@ public final String indexRouting() { } /** + * API name: {@code indices} + */ + @Nonnull + public final List indices() { + return this.indices; + } + + /** + * If true, the alias is hidden. + *

* API name: {@code is_hidden} + *

*/ @Nullable public final Boolean isHidden() { @@ -163,13 +186,27 @@ public final Boolean isHidden() { } /** + * If true, sets the write index or data stream for the alias. + *

* API name: {@code is_write_index} + *

*/ @Nullable public final Boolean isWriteIndex() { return this.isWriteIndex; } + /** + * If true, the alias must exist to perform the action. + *

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

+ */ + @Nullable + public final Boolean mustExist() { + return this.mustExist; + } + /** * API name: {@code routing} */ @@ -189,6 +226,7 @@ public final String searchRouting() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -196,130 +234,182 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.alias != null) { generator.writeKey("alias"); generator.write(this.alias); - } + if (ApiTypeHelper.isDefined(this.aliases)) { generator.writeKey("aliases"); generator.writeStartArray(); for (String item0 : this.aliases) { generator.write(item0); - } generator.writeEnd(); - } + if (this.filter != null) { generator.writeKey("filter"); this.filter.serialize(generator, mapper); - } + if (this.index != null) { generator.writeKey("index"); generator.write(this.index); + } + if (this.indexRouting != null) { + generator.writeKey("index_routing"); + generator.write(this.indexRouting); } + if (ApiTypeHelper.isDefined(this.indices)) { generator.writeKey("indices"); generator.writeStartArray(); for (String item0 : this.indices) { generator.write(item0); - } generator.writeEnd(); - } - 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.mustExist != null) { + generator.writeKey("must_exist"); + generator.write(this.mustExist); } + if (this.routing != null) { generator.writeKey("routing"); generator.write(this.routing); - } + if (this.searchRouting != null) { generator.writeKey("search_routing"); generator.write(this.searchRouting); - } - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link AddAction}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private String alias; - @Nullable private List aliases; - @Nullable private Query filter; - @Nullable private String index; - - @Nullable - private List indices; - @Nullable private String indexRouting; - + @Nullable + private List indices; @Nullable private Boolean isHidden; - @Nullable private Boolean isWriteIndex; - + @Nullable + private Boolean mustExist; @Nullable private String routing; - @Nullable private String searchRouting; + public Builder() {} + + private Builder(AddAction o) { + this.alias = o.alias; + this.aliases = _listCopy(o.aliases); + this.filter = o.filter; + this.index = o.index; + this.indexRouting = o.indexRouting; + this.indices = _listCopy(o.indices); + this.isHidden = o.isHidden; + this.isWriteIndex = o.isWriteIndex; + this.mustExist = o.mustExist; + this.routing = o.routing; + this.searchRouting = o.searchRouting; + } + + private Builder(Builder o) { + this.alias = o.alias; + this.aliases = _listCopy(o.aliases); + this.filter = o.filter; + this.index = o.index; + this.indexRouting = o.indexRouting; + this.indices = _listCopy(o.indices); + this.isHidden = o.isHidden; + this.isWriteIndex = o.isWriteIndex; + this.mustExist = o.mustExist; + this.routing = o.routing; + this.searchRouting = o.searchRouting; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * API name: {@code alias} */ + @Nonnull public final Builder alias(@Nullable String value) { this.alias = value; return this; } /** + * Aliases for the action. Index alias names support date math. + *

* API name: {@code aliases} + *

+ * *

* Adds all elements of list to aliases. + *

*/ + @Nonnull public final Builder aliases(List list) { this.aliases = _listAddAll(this.aliases, list); return this; } /** + * Aliases for the action. Index alias names support date math. + *

* API name: {@code aliases} + *

+ * *

* Adds one or more values to aliases. + *

*/ + @Nonnull public final Builder aliases(String value, String... values) { this.aliases = _listAdd(this.aliases, value, values); return this; @@ -328,6 +418,7 @@ public final Builder aliases(String value, String... values) { /** * API name: {@code filter} */ + @Nonnull public final Builder filter(@Nullable Query value) { this.filter = value; return this; @@ -336,23 +427,37 @@ public final Builder filter(@Nullable Query value) { /** * API name: {@code filter} */ + @Nonnull public final Builder filter(Function> fn) { - return this.filter(fn.apply(new Query.Builder()).build()); + return filter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code index} */ + @Nonnull public final Builder index(@Nullable String value) { this.index = value; return this; } + /** + * API name: {@code index_routing} + */ + @Nonnull + public final Builder indexRouting(@Nullable String value) { + this.indexRouting = value; + return this; + } + /** * API name: {@code indices} + * *

* Adds all elements of list to indices. + *

*/ + @Nonnull public final Builder indices(List list) { this.indices = _listAddAll(this.indices, list); return this; @@ -360,41 +465,57 @@ public final Builder indices(List list) { /** * API name: {@code indices} + * *

* Adds one or more values to indices. + *

*/ + @Nonnull public final Builder indices(String value, String... values) { this.indices = _listAdd(this.indices, value, values); return this; } /** - * API name: {@code index_routing} - */ - public final Builder indexRouting(@Nullable String value) { - this.indexRouting = value; - return this; - } - - /** + * If true, the alias is hidden. + *

* API name: {@code is_hidden} + *

*/ + @Nonnull public final Builder isHidden(@Nullable Boolean value) { this.isHidden = value; return this; } /** + * If true, sets the write index or data stream for the alias. + *

* API name: {@code is_write_index} + *

*/ + @Nonnull public final Builder isWriteIndex(@Nullable Boolean value) { this.isWriteIndex = value; return this; } + /** + * If true, the alias must exist to perform the action. + *

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

+ */ + @Nonnull + public final Builder mustExist(@Nullable Boolean value) { + this.mustExist = value; + return this; + } + /** * API name: {@code routing} */ + @Nonnull public final Builder routing(@Nullable String value) { this.routing = value; return this; @@ -403,6 +524,7 @@ public final Builder routing(@Nullable String value) { /** * API name: {@code search_routing} */ + @Nonnull public final Builder searchRouting(@Nullable String value) { this.searchRouting = value; return this; @@ -411,9 +533,10 @@ public final Builder searchRouting(@Nullable String value) { /** * Builds a {@link AddAction}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public AddAction build() { _checkSingleUse(); @@ -432,18 +555,51 @@ public AddAction build() { ); protected static void setupAddActionDeserializer(ObjectDeserializer op) { - op.add(Builder::alias, JsonpDeserializer.stringDeserializer(), "alias"); op.add(Builder::aliases, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "aliases"); op.add(Builder::filter, Query._DESERIALIZER, "filter"); op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); - op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); op.add(Builder::indexRouting, JsonpDeserializer.stringDeserializer(), "index_routing"); + op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); op.add(Builder::isHidden, JsonpDeserializer.booleanDeserializer(), "is_hidden"); op.add(Builder::isWriteIndex, JsonpDeserializer.booleanDeserializer(), "is_write_index"); + op.add(Builder::mustExist, JsonpDeserializer.booleanDeserializer(), "must_exist"); 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.alias); + result = 31 * result + Objects.hashCode(this.aliases); + result = 31 * result + Objects.hashCode(this.filter); + result = 31 * result + Objects.hashCode(this.index); + result = 31 * result + Objects.hashCode(this.indexRouting); + result = 31 * result + Objects.hashCode(this.indices); + result = 31 * result + Objects.hashCode(this.isHidden); + result = 31 * result + Objects.hashCode(this.isWriteIndex); + result = 31 * result + Objects.hashCode(this.mustExist); + 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; + AddAction other = (AddAction) o; + return Objects.equals(this.alias, other.alias) + && Objects.equals(this.aliases, other.aliases) + && Objects.equals(this.filter, other.filter) + && Objects.equals(this.index, other.index) + && Objects.equals(this.indexRouting, other.indexRouting) + && Objects.equals(this.indices, other.indices) + && Objects.equals(this.isHidden, other.isHidden) + && Objects.equals(this.isWriteIndex, other.isWriteIndex) + && Objects.equals(this.mustExist, other.mustExist) + && 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/update_aliases/RemoveAction.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveAction.java similarity index 69% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveAction.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveAction.java index a55048f146..6940de8c18 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveAction.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveAction.java @@ -30,34 +30,47 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.update_aliases; 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; import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.update_aliases.RemoveAction @JsonpDeserializable -public class RemoveAction implements ActionVariant, JsonpSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class RemoveAction implements ActionVariant, PlainJsonSerializable, ToCopyableBuilder { + @Nullable private final String alias; + @Nonnull private final List aliases; @Nullable private final String index; + @Nonnull private final List indices; @Nullable @@ -66,21 +79,19 @@ public class RemoveAction implements ActionVariant, JsonpSerializable { // --------------------------------------------------------------------------------------------- private RemoveAction(Builder builder) { - this.alias = builder.alias; this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); this.index = builder.index; this.indices = ApiTypeHelper.unmodifiable(builder.indices); this.mustExist = builder.mustExist; - } - public static RemoveAction of(Function> fn) { + public static RemoveAction of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Action variant kind. + * {@link Action} variant kind. */ @Override public Action.Kind _actionKind() { @@ -96,8 +107,12 @@ public final String alias() { } /** + * Aliases for the action. Index alias names support date math. + *

* API name: {@code aliases} + *

*/ + @Nonnull public final List aliases() { return this.aliases; } @@ -113,12 +128,16 @@ public final String index() { /** * API name: {@code indices} */ + @Nonnull public final List indices() { return this.indices; } /** + * If true, the alias must exist to perform the action. + *

* API name: {@code must_exist} + *

*/ @Nullable public final Boolean mustExist() { @@ -128,6 +147,7 @@ public final Boolean mustExist() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -135,90 +155,128 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.alias != null) { generator.writeKey("alias"); generator.write(this.alias); - } + if (ApiTypeHelper.isDefined(this.aliases)) { generator.writeKey("aliases"); generator.writeStartArray(); for (String item0 : this.aliases) { generator.write(item0); - } generator.writeEnd(); - } + if (this.index != null) { generator.writeKey("index"); generator.write(this.index); - } + if (ApiTypeHelper.isDefined(this.indices)) { generator.writeKey("indices"); generator.writeStartArray(); for (String item0 : this.indices) { generator.write(item0); - } generator.writeEnd(); - } + if (this.mustExist != null) { generator.writeKey("must_exist"); generator.write(this.mustExist); - } - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link RemoveAction}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private String alias; - @Nullable private List aliases; - @Nullable private String index; - @Nullable private List indices; - @Nullable private Boolean mustExist; + public Builder() {} + + private Builder(RemoveAction o) { + this.alias = o.alias; + this.aliases = _listCopy(o.aliases); + this.index = o.index; + this.indices = _listCopy(o.indices); + this.mustExist = o.mustExist; + } + + private Builder(Builder o) { + this.alias = o.alias; + this.aliases = _listCopy(o.aliases); + this.index = o.index; + this.indices = _listCopy(o.indices); + this.mustExist = o.mustExist; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * API name: {@code alias} */ + @Nonnull public final Builder alias(@Nullable String value) { this.alias = value; return this; } /** + * Aliases for the action. Index alias names support date math. + *

* API name: {@code aliases} + *

+ * *

* Adds all elements of list to aliases. + *

*/ + @Nonnull public final Builder aliases(List list) { this.aliases = _listAddAll(this.aliases, list); return this; } /** + * Aliases for the action. Index alias names support date math. + *

* API name: {@code aliases} + *

+ * *

* Adds one or more values to aliases. + *

*/ + @Nonnull public final Builder aliases(String value, String... values) { this.aliases = _listAdd(this.aliases, value, values); return this; @@ -227,6 +285,7 @@ public final Builder aliases(String value, String... values) { /** * API name: {@code index} */ + @Nonnull public final Builder index(@Nullable String value) { this.index = value; return this; @@ -234,9 +293,12 @@ public final Builder index(@Nullable String value) { /** * API name: {@code indices} + * *

* Adds all elements of list to indices. + *

*/ + @Nonnull public final Builder indices(List list) { this.indices = _listAddAll(this.indices, list); return this; @@ -244,17 +306,24 @@ public final Builder indices(List list) { /** * API name: {@code indices} + * *

* Adds one or more values to indices. + *

*/ + @Nonnull public final Builder indices(String value, String... values) { this.indices = _listAdd(this.indices, value, values); return this; } /** + * If true, the alias must exist to perform the action. + *

* API name: {@code must_exist} + *

*/ + @Nonnull public final Builder mustExist(@Nullable Boolean value) { this.mustExist = value; return this; @@ -263,9 +332,10 @@ public final Builder mustExist(@Nullable Boolean value) { /** * Builds a {@link RemoveAction}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public RemoveAction build() { _checkSingleUse(); @@ -284,13 +354,33 @@ public RemoveAction build() { ); protected static void setupRemoveActionDeserializer(ObjectDeserializer op) { - op.add(Builder::alias, JsonpDeserializer.stringDeserializer(), "alias"); op.add(Builder::aliases, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "aliases"); op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); op.add(Builder::mustExist, JsonpDeserializer.booleanDeserializer(), "must_exist"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.alias); + result = 31 * result + Objects.hashCode(this.aliases); + result = 31 * result + Objects.hashCode(this.index); + result = 31 * result + Objects.hashCode(this.indices); + result = 31 * result + Objects.hashCode(this.mustExist); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + RemoveAction other = (RemoveAction) o; + return Objects.equals(this.alias, other.alias) + && Objects.equals(this.aliases, other.aliases) + && Objects.equals(this.index, other.index) + && Objects.equals(this.indices, other.indices) + && Objects.equals(this.mustExist, other.mustExist); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveIndexAction.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveIndexAction.java similarity index 61% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveIndexAction.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveIndexAction.java index f5ce998396..17103c84ee 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveIndexAction.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/update_aliases/RemoveIndexAction.java @@ -30,46 +30,64 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.update_aliases; 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; import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.update_aliases.RemoveIndexAction @JsonpDeserializable -public class RemoveIndexAction implements ActionVariant, JsonpSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class RemoveIndexAction + implements + ActionVariant, + PlainJsonSerializable, + ToCopyableBuilder { + @Nullable private final String index; + @Nonnull private final List indices; + @Nullable + private final Boolean mustExist; + // --------------------------------------------------------------------------------------------- private RemoveIndexAction(Builder builder) { - this.index = builder.index; this.indices = ApiTypeHelper.unmodifiable(builder.indices); - + this.mustExist = builder.mustExist; } - public static RemoveIndexAction of(Function> fn) { + public static RemoveIndexAction of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Action variant kind. + * {@link Action} variant kind. */ @Override public Action.Kind _actionKind() { @@ -87,13 +105,26 @@ public final String index() { /** * API name: {@code indices} */ + @Nonnull public final List indices() { return this.indices; } + /** + * If true, the alias must exist to perform the action. + *

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

+ */ + @Nullable + public final Boolean mustExist() { + return this.mustExist; + } + /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -101,41 +132,74 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.index != null) { generator.writeKey("index"); generator.write(this.index); - } + if (ApiTypeHelper.isDefined(this.indices)) { generator.writeKey("indices"); generator.writeStartArray(); for (String item0 : this.indices) { generator.write(item0); - } generator.writeEnd(); - } + if (this.mustExist != null) { + generator.writeKey("must_exist"); + generator.write(this.mustExist); + } } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link RemoveIndexAction}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private String index; - @Nullable private List indices; + @Nullable + private Boolean mustExist; + + public Builder() {} + + private Builder(RemoveIndexAction o) { + this.index = o.index; + this.indices = _listCopy(o.indices); + this.mustExist = o.mustExist; + } + + private Builder(Builder o) { + this.index = o.index; + this.indices = _listCopy(o.indices); + this.mustExist = o.mustExist; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } /** * API name: {@code index} */ + @Nonnull public final Builder index(@Nullable String value) { this.index = value; return this; @@ -143,9 +207,12 @@ public final Builder index(@Nullable String value) { /** * API name: {@code indices} + * *

* Adds all elements of list to indices. + *

*/ + @Nonnull public final Builder indices(List list) { this.indices = _listAddAll(this.indices, list); return this; @@ -153,20 +220,36 @@ public final Builder indices(List list) { /** * API name: {@code indices} + * *

* Adds one or more values to indices. + *

*/ + @Nonnull public final Builder indices(String value, String... values) { this.indices = _listAdd(this.indices, value, values); return this; } + /** + * If true, the alias must exist to perform the action. + *

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

+ */ + @Nonnull + public final Builder mustExist(@Nullable Boolean value) { + this.mustExist = value; + return this; + } + /** * Builds a {@link RemoveIndexAction}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public RemoveIndexAction build() { _checkSingleUse(); @@ -185,10 +268,27 @@ public RemoveIndexAction build() { ); protected static void setupRemoveIndexActionDeserializer(ObjectDeserializer op) { - op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); + op.add(Builder::mustExist, JsonpDeserializer.booleanDeserializer(), "must_exist"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.index); + result = 31 * result + Objects.hashCode(this.indices); + result = 31 * result + Objects.hashCode(this.mustExist); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + RemoveIndexAction other = (RemoveIndexAction) o; + return Objects.equals(this.index, other.index) + && Objects.equals(this.indices, other.indices) + && Objects.equals(this.mustExist, other.mustExist); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsAliasResponse.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsAliasResponse.java deleted file mode 100644 index 266bf5a10b..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsAliasResponse.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_alias.Response - -public class ExistsAliasResponse { - public ExistsAliasResponse() {} - - /** - * Singleton instance for {@link ExistsAliasResponse}. - */ - public static final ExistsAliasResponse _INSTANCE = new ExistsAliasResponse(); - - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.fixedValue(ExistsAliasResponse._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 fcf4f5f2d2..81254854c4 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 @@ -41,7 +41,6 @@ import org.opensearch.client.transport.JsonEndpoint; 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; /** @@ -248,39 +247,6 @@ public final CompletableFuture close(Function deleteAlias(DeleteAliasRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteAliasRequest, - DeleteAliasResponse, - ErrorResponse>) DeleteAliasRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Deletes an alias. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteAliasRequest} - * - */ - - public final CompletableFuture deleteAlias( - Function> fn - ) throws IOException, OpenSearchException { - return deleteAlias(fn.apply(new DeleteAliasRequest.Builder()).build()); - } - // ----- Endpoint: indices.disk_usage /** @@ -313,38 +279,6 @@ public final CompletableFuture diskUsage(Function existsAlias(ExistsAliasRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ExistsAliasRequest, - BooleanResponse, - ErrorResponse>) ExistsAliasRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a particular alias exists. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsAliasRequest} - * - */ - - public final CompletableFuture existsAlias(Function> fn) - throws IOException, OpenSearchException { - return existsAlias(fn.apply(new ExistsAliasRequest.Builder()).build()); - } - // ----- Endpoint: indices.flush /** @@ -433,48 +367,6 @@ public CompletableFuture forcemerge() throws IOException, Op ); } - // ----- Endpoint: indices.get_alias - - /** - * Returns an alias. - * - * - */ - - public CompletableFuture getAlias(GetAliasRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetAliasRequest, - GetAliasResponse, - ErrorResponse>) GetAliasRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns an alias. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetAliasRequest} - * - */ - - public final CompletableFuture getAlias(Function> fn) - throws IOException, OpenSearchException { - return getAlias(fn.apply(new GetAliasRequest.Builder()).build()); - } - - /** - * Returns an alias. - * - * - */ - - public CompletableFuture getAlias() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new GetAliasRequest.Builder().build(), GetAliasRequest._ENDPOINT, this.transportOptions); - } - // ----- Endpoint: indices.get_field_mapping /** @@ -587,38 +479,6 @@ public final CompletableFuture open(Function putAlias(PutAliasRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - PutAliasRequest, - PutAliasResponse, - ErrorResponse>) PutAliasRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates an alias. - * - * @param fn - * a function that initializes a builder to create the - * {@link PutAliasRequest} - * - */ - - public final CompletableFuture putAlias(Function> fn) - throws IOException, OpenSearchException { - return putAlias(fn.apply(new PutAliasRequest.Builder()).build()); - } - // ----- Endpoint: indices.recovery /** @@ -971,53 +831,6 @@ public CompletableFuture stats() throws IOException, OpenS ); } - // ----- Endpoint: indices.update_aliases - - /** - * Updates index aliases. - * - * - */ - - public CompletableFuture updateAliases(UpdateAliasesRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - UpdateAliasesRequest, - UpdateAliasesResponse, - ErrorResponse>) UpdateAliasesRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Updates index aliases. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateAliasesRequest} - * - */ - - public final CompletableFuture updateAliases( - Function> fn - ) throws IOException, OpenSearchException { - return updateAliases(fn.apply(new UpdateAliasesRequest.Builder()).build()); - } - - /** - * Updates index aliases. - * - * - */ - - public CompletableFuture updateAliases() throws IOException, OpenSearchException { - return this.transport.performRequestAsync( - new UpdateAliasesRequest.Builder().build(), - UpdateAliasesRequest._ENDPOINT, - this.transportOptions - ); - } - // ----- Endpoint: indices.upgrade /** 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 ce118e402a..91b68a1039 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 @@ -40,7 +40,6 @@ import org.opensearch.client.transport.JsonEndpoint; 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; /** @@ -235,38 +234,6 @@ public final CloseIndexResponse close(Function endpoint = (JsonEndpoint< - DeleteAliasRequest, - DeleteAliasResponse, - ErrorResponse>) DeleteAliasRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Deletes an alias. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteAliasRequest} - * - */ - - public final DeleteAliasResponse deleteAlias(Function> fn) - throws IOException, OpenSearchException { - return deleteAlias(fn.apply(new DeleteAliasRequest.Builder()).build()); - } - // ----- Endpoint: indices.disk_usage /** @@ -299,38 +266,6 @@ public final DiskUsageResponse diskUsage(Function endpoint = (JsonEndpoint< - ExistsAliasRequest, - BooleanResponse, - ErrorResponse>) ExistsAliasRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a particular alias exists. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsAliasRequest} - * - */ - - public final BooleanResponse existsAlias(Function> fn) throws IOException, - OpenSearchException { - return existsAlias(fn.apply(new ExistsAliasRequest.Builder()).build()); - } - // ----- Endpoint: indices.flush /** @@ -415,48 +350,6 @@ public ForcemergeResponse forcemerge() throws IOException, OpenSearchException { return this.transport.performRequest(new ForcemergeRequest.Builder().build(), ForcemergeRequest._ENDPOINT, this.transportOptions); } - // ----- Endpoint: indices.get_alias - - /** - * Returns an alias. - * - * - */ - - public GetAliasResponse getAlias(GetAliasRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetAliasRequest, - GetAliasResponse, - ErrorResponse>) GetAliasRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns an alias. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetAliasRequest} - * - */ - - public final GetAliasResponse getAlias(Function> fn) throws IOException, - OpenSearchException { - return getAlias(fn.apply(new GetAliasRequest.Builder()).build()); - } - - /** - * Returns an alias. - * - * - */ - - public GetAliasResponse getAlias() throws IOException, OpenSearchException { - return this.transport.performRequest(new GetAliasRequest.Builder().build(), GetAliasRequest._ENDPOINT, this.transportOptions); - } - // ----- Endpoint: indices.get_field_mapping /** @@ -562,38 +455,6 @@ public final OpenResponse open(Function endpoint = (JsonEndpoint< - PutAliasRequest, - PutAliasResponse, - ErrorResponse>) PutAliasRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates an alias. - * - * @param fn - * a function that initializes a builder to create the - * {@link PutAliasRequest} - * - */ - - public final PutAliasResponse putAlias(Function> fn) throws IOException, - OpenSearchException { - return putAlias(fn.apply(new PutAliasRequest.Builder()).build()); - } - // ----- Endpoint: indices.recovery /** @@ -940,52 +801,6 @@ public IndicesStatsResponse stats() throws IOException, OpenSearchException { ); } - // ----- Endpoint: indices.update_aliases - - /** - * Updates index aliases. - * - * - */ - - public UpdateAliasesResponse updateAliases(UpdateAliasesRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - UpdateAliasesRequest, - UpdateAliasesResponse, - ErrorResponse>) UpdateAliasesRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Updates index aliases. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateAliasesRequest} - * - */ - - public final UpdateAliasesResponse updateAliases(Function> fn) - throws IOException, OpenSearchException { - return updateAliases(fn.apply(new UpdateAliasesRequest.Builder()).build()); - } - - /** - * Updates index aliases. - * - * - */ - - public UpdateAliasesResponse updateAliases() throws IOException, OpenSearchException { - return this.transport.performRequest( - new UpdateAliasesRequest.Builder().build(), - UpdateAliasesRequest._ENDPOINT, - this.transportOptions - ); - } - // ----- Endpoint: indices.upgrade /** 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 b1d377ea34..88c8f6111d 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 @@ -53,6 +53,7 @@ public class CodeGenerator { namespace(is("indices")), name( or( + contains("alias"), contains("data_stream"), and(endsWith("mapping"), isNot("get_field_mapping")), endsWith("settings"), 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 f8c39d37cd..5373632cc1 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 @@ -20,11 +20,14 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.opensearch.client.codegen.model.overrides.ShouldGenerate; import org.opensearch.client.codegen.utils.Streams; import org.opensearch.client.codegen.utils.Strings; public class RequestShape extends ObjectShape { + private static final Logger LOGGER = LogManager.getLogger(); @Nonnull private final OperationGroup operationGroup; @Nonnull @@ -124,8 +127,9 @@ public boolean hasRequestBody() { } public void addQueryParam(Field field) { - queryParams.put(field.getName(), field); - addField(field); + if (addField(field)) { + queryParams.put(field.getName(), field); + } } public Collection getQueryParams() { @@ -153,8 +157,9 @@ public boolean hasSinglePath() { } public void addPathParam(Field field) { - pathParams.put(field.getName(), field); - addField(field); + if (addField(field)) { + pathParams.put(field.getName(), field); + } } public Collection> getIndexedPathParams() { @@ -172,8 +177,9 @@ public Collection getPathParams() { @Override public void addBodyField(Field field) { - super.addBodyField(field); - addField(field); + if (addField(field)) { + super.addBodyField(field); + } } public void setDelegatedBodyField(String name, Type type) { @@ -189,9 +195,14 @@ public Field getDelegatedBodyField() { return delegatedBodyField; } - private void addField(Field field) { + private boolean addField(Field field) { + if (fields.containsKey(field.getName())) { + LOGGER.warn("Attempted to add duplicate field {} to request {}", field.getName(), getOperationGroup()); + return false; + } fields.put(field.getName(), field); tryAddReference(ReferenceKind.Field, field.getType()); + return true; } @Override 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 49a3fc34e2..5277e76afe 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 @@ -20,7 +20,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nonnull; import org.apache.commons.lang3.NotImplementedException; @@ -237,13 +236,11 @@ private RequestShape visit(@Nonnull Namespace parent, @Nonnull OperationGroup gr } }); - var bodyFieldNames = (shape.hasDelegatedBodyField() - ? (ObjectShapeBase) shape.getDelegatedBodyField().getType().getTargetShape().orElseThrow() - : shape).getBodyFields().stream().map(Field::getWireName).collect(Collectors.toSet()); + var seenQueryParams = new HashSet(); variants.stream() .flatMap(v -> v.getAllRelevantParameters(In.Query).stream()) - .filter(p -> !p.isGlobal() && !bodyFieldNames.contains(p.getName().orElseThrow())) + .filter(p -> seenQueryParams.add(p.getName().orElseThrow()) && !p.isGlobal()) .map(this::visit) .forEachOrdered(shape::addQueryParam); From 26f63d2db1dc892d3b9eb7d9b9e8cdf7267fc81d Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 13 Dec 2024 19:32:41 +1300 Subject: [PATCH 2/7] Generate indices.add_block Signed-off-by: Thomas Farr --- .../opensearch/indices/AddBlockRequest.java | 330 ++++++++++++------ .../opensearch/indices/AddBlockResponse.java | 140 ++++++-- .../OpenSearchIndicesAsyncClientBase.java | 19 + .../indices/OpenSearchIndicesClientBase.java | 19 + .../add_block/IndicesBlockOptions.java | 12 +- .../indices/add_block/IndicesBlockStatus.java | 108 ++++-- .../indices/OpenSearchIndicesAsyncClient.java | 32 -- .../indices/OpenSearchIndicesClient.java | 30 -- java-codegen/opensearch-openapi.yaml | 27 +- .../client/codegen/CodeGenerator.java | 4 +- 10 files changed, 461 insertions(+), 260 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/AddBlockRequest.java (58%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/AddBlockResponse.java (67%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockOptions.java (84%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockStatus.java (70%) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/AddBlockRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AddBlockRequest.java similarity index 58% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/AddBlockRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/AddBlockRequest.java index 00895d4883..7714853e04 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/AddBlockRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AddBlockRequest.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; @@ -46,64 +53,67 @@ import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.SimpleEndpoint; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.add_block.Request /** * Adds a block to an index. - * */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class AddBlockRequest extends RequestBase implements ToCopyableBuilder { -public class AddBlockRequest extends RequestBase { @Nullable private final Boolean allowNoIndices; + @Nonnull private final IndicesBlockOptions block; + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull private final List expandWildcards; @Nullable private final Boolean ignoreUnavailable; - private final String index; + @Nonnull + private final List index; @Deprecated @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - @Nullable private final Time timeout; // --------------------------------------------------------------------------------------------- private AddBlockRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; this.block = ApiTypeHelper.requireNonNull(builder.block, this, "block"); + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.ignoreUnavailable = builder.ignoreUnavailable; - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); + this.index = ApiTypeHelper.unmodifiableRequired(builder.index, this, "index"); this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.timeout = builder.timeout; - } - public static AddBlockRequest of(Function> fn) { + public static AddBlockRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Whether to ignore if a wildcard indices expression resolves into no concrete - * indices. (This includes _all string or when no indices have been - * specified) + * Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes _all string or when + * no indexes have been specified). *

* API name: {@code allow_no_indices} + *

*/ @Nullable public final Boolean allowNoIndices() { @@ -111,29 +121,43 @@ public final Boolean allowNoIndices() { } /** - * Required - The block to add (one of read, write, read_only or metadata) + * Required - The block to add (one of read, write, read_only or metadata). *

* API name: {@code block} + *

*/ + @Nonnull public final IndicesBlockOptions block() { return this.block; } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + /** + * Whether to expand wildcard expression to concrete indexes that are open, closed or both. *

* API name: {@code expand_wildcards} + *

*/ + @Nonnull public final List expandWildcards() { return this.expandWildcards; } /** - * Whether specified concrete indices should be ignored when unavailable - * (missing or closed) + * Whether specified concrete indexes should be ignored when unavailable (missing or closed). *

* API name: {@code ignore_unavailable} + *

*/ @Nullable public final Boolean ignoreUnavailable() { @@ -141,18 +165,21 @@ public final Boolean ignoreUnavailable() { } /** - * Required - A comma separated list of indices to add a block to + * Required - A comma separated list of indexes to add a block to. *

* API name: {@code index} + *

*/ - public final String index() { + @Nonnull + public final List index() { return this.index; } /** - * Specify timeout for connection to master + * Specify timeout for connection to cluster manager. *

* API name: {@code master_timeout} + *

*/ @Deprecated @Nullable @@ -160,20 +187,11 @@ 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; - } - /** * Explicit operation timeout *

* API name: {@code timeout} + *

*/ @Nullable public final Time timeout() { @@ -182,148 +200,222 @@ public final Time timeout() { // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link AddBlockRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private Boolean allowNoIndices; - private IndicesBlockOptions block; - + @Nullable + private Time clusterManagerTimeout; @Nullable private List expandWildcards; - @Nullable private Boolean ignoreUnavailable; - - private String index; - - @Deprecated + private List index; @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - @Nullable private Time timeout; + public Builder() {} + + private Builder(AddBlockRequest o) { + this.allowNoIndices = o.allowNoIndices; + this.block = o.block; + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.expandWildcards = _listCopy(o.expandWildcards); + this.ignoreUnavailable = o.ignoreUnavailable; + this.index = _listCopy(o.index); + this.masterTimeout = o.masterTimeout; + this.timeout = o.timeout; + } + + private Builder(Builder o) { + this.allowNoIndices = o.allowNoIndices; + this.block = o.block; + this.clusterManagerTimeout = o.clusterManagerTimeout; + this.expandWildcards = _listCopy(o.expandWildcards); + this.ignoreUnavailable = o.ignoreUnavailable; + this.index = _listCopy(o.index); + this.masterTimeout = o.masterTimeout; + this.timeout = o.timeout; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** - * Whether to ignore if a wildcard indices expression resolves into no concrete - * indices. (This includes _all string or when no indices have been - * specified) + * Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes _all string or + * when no indexes have been specified). *

* API name: {@code allow_no_indices} + *

*/ + @Nonnull public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** - * Required - The block to add (one of read, write, read_only or metadata) + * Required - The block to add (one of read, write, read_only or metadata). *

* API name: {@code block} + *

*/ + @Nonnull public final Builder block(IndicesBlockOptions value) { this.block = value; return this; } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * Operation timeout for connection to cluster-manager node. + *

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

+ */ + @Nonnull + 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} + *

+ */ + @Nonnull + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Whether to expand wildcard expression to concrete indexes that are open, closed or both. *

* API name: {@code expand_wildcards} + *

+ * *

* Adds all elements of list to expandWildcards. + *

*/ + @Nonnull public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * Whether to expand wildcard expression to concrete indexes that are open, closed or both. *

* API name: {@code expand_wildcards} + *

+ * *

* Adds one or more values to expandWildcards. + *

*/ + @Nonnull public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** - * Whether specified concrete indices should be ignored when unavailable - * (missing or closed) + * Whether specified concrete indexes should be ignored when unavailable (missing or closed). *

* API name: {@code ignore_unavailable} + *

*/ + @Nonnull public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** - * Required - A comma separated list of indices to add a block to + * Required - A comma separated list of indexes to add a block to. *

* API name: {@code index} + *

+ * + *

+ * Adds all elements of list to index. + *

*/ - public final Builder index(String value) { - this.index = value; + @Nonnull + public final Builder index(List list) { + this.index = _listAddAll(this.index, list); return this; } /** - * Specify timeout for connection to master + * Required - A comma separated list of indexes to add a block to. *

- * API name: {@code master_timeout} + * API name: {@code index} + *

+ * + *

+ * Adds one or more values to index. + *

*/ - @Deprecated - public final Builder masterTimeout(@Nullable Time value) { - this.masterTimeout = value; + @Nonnull + public final Builder index(String value, String... values) { + this.index = _listAdd(this.index, value, values); return this; } /** - * Specify timeout for connection to master + * Specify timeout for connection to cluster manager. *

* 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; + @Nonnull + public final Builder masterTimeout(@Nullable Time value) { + this.masterTimeout = value; return this; } /** - * Specify timeout for connection to cluster-manager + * Specify timeout for connection to cluster manager. *

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

*/ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + @Deprecated + @Nonnull + public final Builder masterTimeout(Function> fn) { + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** * Explicit operation timeout *

* API name: {@code timeout} + *

*/ + @Nonnull public final Builder timeout(@Nullable Time value) { this.timeout = value; return this; @@ -333,17 +425,20 @@ public final Builder timeout(@Nullable Time value) { * Explicit operation timeout *

* API name: {@code timeout} + *

*/ + @Nonnull 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 AddBlockRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public AddBlockRequest build() { _checkSingleUse(); @@ -357,41 +452,22 @@ public AddBlockRequest build() { * Endpoint "{@code indices.add_block}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "PUT"; - - }, - + request -> "PUT", // Request path request -> { - final int _index = 1 << 0; - final int _block = 1 << 1; - - int propsSet = 0; - - propsSet |= _index; - propsSet |= _block; - - if (propsSet == (_index | _block)) { - StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index, buf); - buf.append("/_block"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.block.jsonValue(), buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/"); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + buf.append("/_block/"); + SimpleEndpoint.pathEncode(request.block.jsonValue(), 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()); @@ -402,17 +478,45 @@ public AddBlockRequest 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, AddBlockResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allowNoIndices); + result = 31 * result + this.block.hashCode(); + 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; + AddBlockRequest other = (AddBlockRequest) o; + return Objects.equals(this.allowNoIndices, other.allowNoIndices) + && this.block.equals(other.block) + && 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/AddBlockResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AddBlockResponse.java similarity index 67% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/AddBlockResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/AddBlockResponse.java index aa32491d36..c2520e02e4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/AddBlockResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AddBlockResponse.java @@ -30,11 +30,17 @@ * 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.List; 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; @@ -43,87 +49,117 @@ import org.opensearch.client.opensearch._types.AcknowledgedResponseBase; import org.opensearch.client.opensearch.indices.add_block.IndicesBlockStatus; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.add_block.Response @JsonpDeserializable -public class AddBlockResponse extends AcknowledgedResponseBase { - private final boolean shardsAcknowledged; +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class AddBlockResponse extends AcknowledgedResponseBase implements ToCopyableBuilder { + @Nonnull private final List indices; + private final boolean shardsAcknowledged; + // --------------------------------------------------------------------------------------------- private AddBlockResponse(Builder builder) { super(builder); - - this.shardsAcknowledged = ApiTypeHelper.requireNonNull(builder.shardsAcknowledged, this, "shardsAcknowledged"); this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); - + this.shardsAcknowledged = ApiTypeHelper.requireNonNull(builder.shardsAcknowledged, this, "shardsAcknowledged"); } - public static AddBlockResponse of(Function> fn) { + public static AddBlockResponse of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Required - API name: {@code shards_acknowledged} + * Required - API name: {@code indices} */ - public final boolean shardsAcknowledged() { - return this.shardsAcknowledged; + @Nonnull + public final List indices() { + return this.indices; } /** - * Required - API name: {@code indices} + * Required - API name: {@code shards_acknowledged} */ - public final List indices() { - return this.indices; + public final boolean shardsAcknowledged() { + return this.shardsAcknowledged; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - super.serializeInternal(generator, mapper); + generator.writeKey("indices"); + generator.writeStartArray(); + for (IndicesBlockStatus item0 : this.indices) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + generator.writeKey("shards_acknowledged"); generator.write(this.shardsAcknowledged); + } - if (ApiTypeHelper.isDefined(this.indices)) { - generator.writeKey("indices"); - generator.writeStartArray(); - for (IndicesBlockStatus item0 : this.indices) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - - } + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link AddBlockResponse}. */ - - public static class Builder extends AcknowledgedResponseBase.AbstractBuilder implements ObjectBuilder { + public static class Builder extends AcknowledgedResponseBase.AbstractBuilder + implements + CopyableBuilder { + private List indices; private Boolean shardsAcknowledged; - private List indices; + public Builder() {} - /** - * Required - API name: {@code shards_acknowledged} - */ - public final Builder shardsAcknowledged(boolean value) { - this.shardsAcknowledged = value; + private Builder(AddBlockResponse o) { + super(o); + this.indices = _listCopy(o.indices); + this.shardsAcknowledged = o.shardsAcknowledged; + } + + private Builder(Builder o) { + super(o); + this.indices = _listCopy(o.indices); + this.shardsAcknowledged = o.shardsAcknowledged; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + + @Override + @Nonnull + protected Builder self() { return this; } /** * Required - API name: {@code indices} + * *

* Adds all elements of list to indices. + *

*/ + @Nonnull public final Builder indices(List list) { this.indices = _listAddAll(this.indices, list); return this; @@ -131,9 +167,12 @@ public final Builder indices(List list) { /** * Required - API name: {@code indices} + * *

* Adds one or more values to indices. + *

*/ + @Nonnull public final Builder indices(IndicesBlockStatus value, IndicesBlockStatus... values) { this.indices = _listAdd(this.indices, value, values); return this; @@ -141,24 +180,32 @@ public final Builder indices(IndicesBlockStatus value, IndicesBlockStatus... val /** * Required - API name: {@code indices} + * *

* Adds a value to indices using a builder lambda. + *

*/ + @Nonnull public final Builder indices(Function> fn) { return indices(fn.apply(new IndicesBlockStatus.Builder()).build()); } - @Override - protected Builder self() { + /** + * Required - API name: {@code shards_acknowledged} + */ + @Nonnull + public final Builder shardsAcknowledged(boolean value) { + this.shardsAcknowledged = value; return this; } /** * Builds a {@link AddBlockResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public AddBlockResponse build() { _checkSingleUse(); @@ -177,10 +224,27 @@ public AddBlockResponse build() { ); protected static void setupAddBlockResponseDeserializer(ObjectDeserializer op) { - AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); - op.add(Builder::shardsAcknowledged, JsonpDeserializer.booleanDeserializer(), "shards_acknowledged"); + setupAcknowledgedResponseBaseDeserializer(op); op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(IndicesBlockStatus._DESERIALIZER), "indices"); + op.add(Builder::shardsAcknowledged, JsonpDeserializer.booleanDeserializer(), "shards_acknowledged"); + } + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + this.indices.hashCode(); + result = 31 * result + Boolean.hashCode(this.shardsAcknowledged); + 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; + AddBlockResponse other = (AddBlockResponse) o; + return this.indices.equals(other.indices) && 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 be80746692..49ba9dbbb2 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.add_block + + /** + * Adds a block to an index. + */ + public CompletableFuture addBlock(AddBlockRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, AddBlockRequest._ENDPOINT, this.transportOptions); + } + + /** + * Adds a block to an index. + * + * @param fn a function that initializes a builder to create the {@link AddBlockRequest} + */ + public final CompletableFuture addBlock(Function> fn) + throws IOException, OpenSearchException { + return addBlock(fn.apply(new AddBlockRequest.Builder()).build()); + } + // ----- Endpoint: indices.create /** 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 8a8738d0d9..47fe955a51 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.add_block + + /** + * Adds a block to an index. + */ + public AddBlockResponse addBlock(AddBlockRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, AddBlockRequest._ENDPOINT, this.transportOptions); + } + + /** + * Adds a block to an index. + * + * @param fn a function that initializes a builder to create the {@link AddBlockRequest} + */ + public final AddBlockResponse addBlock(Function> fn) throws IOException, + OpenSearchException { + return addBlock(fn.apply(new AddBlockRequest.Builder()).build()); + } + // ----- Endpoint: indices.create /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockOptions.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockOptions.java similarity index 84% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockOptions.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockOptions.java index f8f767129e..6e2e77cf0b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockOptions.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockOptions.java @@ -30,12 +30,20 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.add_block; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: indices.add_block.IndicesBlockOptions + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum IndicesBlockOptions implements JsonEnum { Metadata("metadata"), @@ -43,9 +51,7 @@ public enum IndicesBlockOptions implements JsonEnum { ReadOnly("read_only"), - Write("write"), - - ; + Write("write"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockStatus.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockStatus.java similarity index 70% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockStatus.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockStatus.java index af21361b93..7c29b862a4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockStatus.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/add_block/IndicesBlockStatus.java @@ -30,10 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.add_block; 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; @@ -41,47 +47,52 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.add_block.IndicesBlockStatus @JsonpDeserializable -public class IndicesBlockStatus implements PlainJsonSerializable { - private final String name; +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class IndicesBlockStatus implements PlainJsonSerializable, ToCopyableBuilder { private final boolean blocked; + @Nonnull + private final String name; + // --------------------------------------------------------------------------------------------- private IndicesBlockStatus(Builder builder) { - - this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.blocked = ApiTypeHelper.requireNonNull(builder.blocked, this, "blocked"); - + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); } - public static IndicesBlockStatus of(Function> fn) { + public static IndicesBlockStatus of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Required - API name: {@code name} + * Required - API name: {@code blocked} */ - public final String name() { - return this.name; + public final boolean blocked() { + return this.blocked; } /** - * Required - API name: {@code blocked} + * Required - API name: {@code name} */ - public final boolean blocked() { - return this.blocked; + @Nonnull + public final String name() { + return this.name; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -89,48 +100,76 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey("blocked"); + generator.write(this.blocked); generator.writeKey("name"); generator.write(this.name); + } - generator.writeKey("blocked"); - generator.write(this.blocked); + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link IndicesBlockStatus}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + private Boolean blocked; private String name; - private Boolean blocked; + public Builder() {} - /** - * Required - API name: {@code name} - */ - public final Builder name(String value) { - this.name = value; - return this; + private Builder(IndicesBlockStatus o) { + this.blocked = o.blocked; + this.name = o.name; + } + + private Builder(Builder o) { + this.blocked = o.blocked; + this.name = o.name; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); } /** * Required - API name: {@code blocked} */ + @Nonnull public final Builder blocked(boolean value) { this.blocked = value; return this; } + /** + * Required - API name: {@code name} + */ + @Nonnull + public final Builder name(String value) { + this.name = value; + return this; + } + /** * Builds a {@link IndicesBlockStatus}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public IndicesBlockStatus build() { _checkSingleUse(); @@ -149,10 +188,23 @@ public IndicesBlockStatus build() { ); protected static void setupIndicesBlockStatusDeserializer(ObjectDeserializer op) { - - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::blocked, JsonpDeserializer.booleanDeserializer(), "blocked"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.blocked); + result = 31 * result + this.name.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndicesBlockStatus other = (IndicesBlockStatus) o; + return this.blocked == other.blocked && this.name.equals(other.name); + } } 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 81254854c4..72ad5500c8 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 @@ -61,38 +61,6 @@ public OpenSearchIndicesAsyncClient withTransportOptions(@Nullable TransportOpti return new OpenSearchIndicesAsyncClient(this.transport, transportOptions); } - // ----- Endpoint: indices.add_block - - /** - * Adds a block to an index. - * - * - */ - - public CompletableFuture addBlock(AddBlockRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - AddBlockRequest, - AddBlockResponse, - ErrorResponse>) AddBlockRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Adds a block to an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link AddBlockRequest} - * - */ - - public final CompletableFuture addBlock(Function> fn) - throws IOException, OpenSearchException { - return addBlock(fn.apply(new AddBlockRequest.Builder()).build()); - } - // ----- Endpoint: indices.analyze /** 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 91b68a1039..9163dc1a4b 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 @@ -60,36 +60,6 @@ public OpenSearchIndicesClient withTransportOptions(@Nullable TransportOptions t return new OpenSearchIndicesClient(this.transport, transportOptions); } - // ----- Endpoint: indices.add_block - - /** - * Adds a block to an index. - * - */ - - public AddBlockResponse addBlock(AddBlockRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - AddBlockRequest, - AddBlockResponse, - ErrorResponse>) AddBlockRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Adds a block to an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link AddBlockRequest} - */ - - public final AddBlockResponse addBlock(Function> fn) throws IOException, - OpenSearchException { - return addBlock(fn.apply(new AddBlockRequest.Builder()).build()); - } - // ----- Endpoint: indices.analyze /** diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index 27ce083408..48db1f179e 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -29263,20 +29263,19 @@ components: content: application/json: schema: - type: object - properties: - acknowledged: - type: boolean - shards_acknowledged: - type: boolean - indices: - type: array - items: - $ref: '#/components/schemas/indices.add_block___IndicesBlockStatus' - required: - - acknowledged - - indices - - shards_acknowledged + allOf: + - $ref: '#/components/schemas/_common___AcknowledgedResponseBase' + - type: object + properties: + shards_acknowledged: + type: boolean + indices: + type: array + items: + $ref: '#/components/schemas/indices.add_block___IndicesBlockStatus' + required: + - indices + - shards_acknowledged description: '' indices.analyze___200: content: 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 88c8f6111d..2483f22ff9 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 @@ -53,12 +53,12 @@ public class CodeGenerator { namespace(is("indices")), name( or( + isOneOf("add_block", "create", "delete", "exists", "get"), contains("alias"), contains("data_stream"), and(endsWith("mapping"), isNot("get_field_mapping")), endsWith("settings"), - endsWith("template"), - isOneOf("create", "delete", "exists", "get") + endsWith("template") ) ) ), From b6e50caa7d2310be793a7d8cc261175d4ef27159 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 13 Dec 2024 19:44:30 +1300 Subject: [PATCH 3/7] Generate indices.analyze Signed-off-by: Thomas Farr --- UPGRADING.md | 9 +- .../opensearch/indices/AnalyzeRequest.java | 273 ++++++++++++++---- .../opensearch/indices/AnalyzeResponse.java | 92 +++++- .../OpenSearchIndicesAsyncClientBase.java | 26 ++ .../indices/OpenSearchIndicesClientBase.java | 26 ++ .../indices/analyze/AnalyzeDetail.java | 129 +++++++-- .../indices/analyze/AnalyzeToken.java | 150 +++++++--- .../indices/analyze/AnalyzerDetail.java | 100 +++++-- .../indices/analyze/CharFilterDetail.java | 98 +++++-- .../indices/analyze/ExplainAnalyzeToken.java | 190 ++++++++---- .../indices/analyze/TokenDetail.java | 100 +++++-- .../indices/OpenSearchIndicesAsyncClient.java | 45 --- .../indices/OpenSearchIndicesClient.java | 42 --- java-codegen/opensearch-openapi.yaml | 27 +- .../client/codegen/CodeGenerator.java | 2 +- 15 files changed, 962 insertions(+), 347 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java (67%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/AnalyzeResponse.java (72%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeDetail.java (74%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeToken.java (60%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/analyze/AnalyzerDetail.java (70%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/analyze/CharFilterDetail.java (68%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/analyze/ExplainAnalyzeToken.java (59%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/analyze/TokenDetail.java (70%) diff --git a/UPGRADING.md b/UPGRADING.md index 1a782f2d94..1809c8c5af 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -191,4 +191,11 @@ After: ### snapshot.ShardsStatsSummaryItem renamed to snapshot.SnapshotShardsStatsSummaryItem - The `snapshot.ShardsStatsSummaryItem` class has been renamed to `snapshot.SnapshotShardsStatsSummaryItem`, this affects: - - `snapshot.SnapshotShardsStatsSummary`'s (previously `snapshot.ShardsStatsSummary`) `incremental` and `total` fields. \ No newline at end of file + - `snapshot.SnapshotShardsStatsSummary`'s (previously `snapshot.ShardsStatsSummary`) `incremental` and `total` fields. + +### AnalyzeToken +- The `endOffset`, `position`, `positionLength` and `startOffset` properties have been corrected to be of type `int` instead of `long`. + +### ExplainAnalyzeToken +- The `endOffset`, `position`, `positionLength`, `startOffset` and `termFrequency` properties have been corrected to be of type `int` instead of `long`. +- The `positionlength` and `termfrequency` properties have had their casing corrected to `positionLength` and `termFrequency` respectively. \ No newline at end of file diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java similarity index 67% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java index 464c2fdc3b..e94f5708e8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java @@ -30,12 +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.Collections; 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; @@ -51,23 +57,30 @@ import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.SimpleEndpoint; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.analyze.Request /** - * Performs the analysis process on a text and return the tokens breakdown of - * the text. - * + * Performs the analysis process on a text and return the tokens breakdown of the text. */ @JsonpDeserializable -public class AnalyzeRequest extends RequestBase implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class AnalyzeRequest extends RequestBase + implements + PlainJsonSerializable, + ToCopyableBuilder { + @Nullable private final String analyzer; + @Nonnull private final List attributes; + @Nonnull private final List charFilter; @Nullable @@ -76,6 +89,7 @@ public class AnalyzeRequest extends RequestBase implements PlainJsonSerializable @Nullable private final String field; + @Nonnull private final List filter; @Nullable @@ -84,6 +98,7 @@ public class AnalyzeRequest extends RequestBase implements PlainJsonSerializable @Nullable private final String normalizer; + @Nonnull private final List text; @Nullable @@ -92,7 +107,6 @@ public class AnalyzeRequest extends RequestBase implements PlainJsonSerializable // --------------------------------------------------------------------------------------------- private AnalyzeRequest(Builder builder) { - this.analyzer = builder.analyzer; this.attributes = ApiTypeHelper.unmodifiable(builder.attributes); this.charFilter = ApiTypeHelper.unmodifiable(builder.charFilter); @@ -103,15 +117,18 @@ private AnalyzeRequest(Builder builder) { this.normalizer = builder.normalizer; this.text = ApiTypeHelper.unmodifiable(builder.text); this.tokenizer = builder.tokenizer; - } - public static AnalyzeRequest of(Function> fn) { + public static AnalyzeRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** + * The name of the analyzer that should be applied to the provided text. This could be a built-in analyzer, or an analyzer + * that's been configured in the index. + *

* API name: {@code analyzer} + *

*/ @Nullable public final String analyzer() { @@ -119,21 +136,32 @@ public final String analyzer() { } /** + * Array of token attributes used to filter the output of the explain parameter. + *

* API name: {@code attributes} + *

*/ + @Nonnull public final List attributes() { return this.attributes; } /** + * Array of character filters used to preprocess characters before the tokenizer. + *

* API name: {@code char_filter} + *

*/ + @Nonnull public final List charFilter() { return this.charFilter; } /** + * If true, the response includes token attributes and additional details. + *

* API name: {@code explain} + *

*/ @Nullable public final Boolean explain() { @@ -149,16 +177,22 @@ public final String field() { } /** + * Array of token filters used to apply after the tokenizer. + *

* API name: {@code filter} + *

*/ + @Nonnull public final List filter() { return this.filter; } /** - * The name of the index to scope the operation + * Index used to derive the analyzer. If specified, the analyzer or field parameter overrides this value. If no index is + * specified or the index does not have a default analyzer, the analyze API uses the standard analyzer. *

* API name: {@code index} + *

*/ @Nullable public final String index() { @@ -166,7 +200,10 @@ public final String index() { } /** + * Normalizer to use to convert text into a single token. + *

* API name: {@code normalizer} + *

*/ @Nullable public final String normalizer() { @@ -176,6 +213,7 @@ public final String normalizer() { /** * API name: {@code text} */ + @Nonnull public final List text() { return this.text; } @@ -191,6 +229,7 @@ public final Tokenizer tokenizer() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -198,172 +237,238 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.analyzer != null) { generator.writeKey("analyzer"); generator.write(this.analyzer); - } + if (ApiTypeHelper.isDefined(this.attributes)) { generator.writeKey("attributes"); generator.writeStartArray(); for (String item0 : this.attributes) { generator.write(item0); - } generator.writeEnd(); - } + if (ApiTypeHelper.isDefined(this.charFilter)) { generator.writeKey("char_filter"); generator.writeStartArray(); for (CharFilter item0 : this.charFilter) { item0.serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); - } + if (this.field != null) { generator.writeKey("field"); generator.write(this.field); - } + if (ApiTypeHelper.isDefined(this.filter)) { generator.writeKey("filter"); generator.writeStartArray(); for (TokenFilter item0 : this.filter) { item0.serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.normalizer != null) { generator.writeKey("normalizer"); generator.write(this.normalizer); - } + if (ApiTypeHelper.isDefined(this.text)) { generator.writeKey("text"); generator.writeStartArray(); for (String item0 : this.text) { generator.write(item0); - } generator.writeEnd(); - } + if (this.tokenizer != null) { generator.writeKey("tokenizer"); this.tokenizer.serialize(generator, mapper); - } + } + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link AnalyzeRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private String analyzer; - @Nullable private List attributes; - @Nullable private List charFilter; - @Nullable private Boolean explain; - @Nullable private String field; - @Nullable private List filter; - @Nullable private String index; - @Nullable private String normalizer; - @Nullable private List text; - @Nullable private Tokenizer tokenizer; + public Builder() {} + + private Builder(AnalyzeRequest o) { + this.analyzer = o.analyzer; + this.attributes = _listCopy(o.attributes); + this.charFilter = _listCopy(o.charFilter); + this.explain = o.explain; + this.field = o.field; + this.filter = _listCopy(o.filter); + this.index = o.index; + this.normalizer = o.normalizer; + this.text = _listCopy(o.text); + this.tokenizer = o.tokenizer; + } + + private Builder(Builder o) { + this.analyzer = o.analyzer; + this.attributes = _listCopy(o.attributes); + this.charFilter = _listCopy(o.charFilter); + this.explain = o.explain; + this.field = o.field; + this.filter = _listCopy(o.filter); + this.index = o.index; + this.normalizer = o.normalizer; + this.text = _listCopy(o.text); + this.tokenizer = o.tokenizer; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** + * The name of the analyzer that should be applied to the provided text. This could be a built-in analyzer, or an + * analyzer that's been configured in the index. + *

* API name: {@code analyzer} + *

*/ + @Nonnull public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** + * Array of token attributes used to filter the output of the explain parameter. + *

* API name: {@code attributes} + *

+ * *

* Adds all elements of list to attributes. + *

*/ + @Nonnull public final Builder attributes(List list) { this.attributes = _listAddAll(this.attributes, list); return this; } /** + * Array of token attributes used to filter the output of the explain parameter. + *

* API name: {@code attributes} + *

+ * *

* Adds one or more values to attributes. + *

*/ + @Nonnull public final Builder attributes(String value, String... values) { this.attributes = _listAdd(this.attributes, value, values); return this; } /** + * Array of character filters used to preprocess characters before the tokenizer. + *

* API name: {@code char_filter} + *

+ * *

* Adds all elements of list to charFilter. + *

*/ + @Nonnull public final Builder charFilter(List list) { this.charFilter = _listAddAll(this.charFilter, list); return this; } /** + * Array of character filters used to preprocess characters before the tokenizer. + *

* API name: {@code char_filter} + *

+ * *

* Adds one or more values to charFilter. + *

*/ + @Nonnull public final Builder charFilter(CharFilter value, CharFilter... values) { this.charFilter = _listAdd(this.charFilter, value, values); return this; } /** + * Array of character filters used to preprocess characters before the tokenizer. + *

* API name: {@code char_filter} + *

+ * *

* Adds a value to charFilter using a builder lambda. + *

*/ + @Nonnull public final Builder charFilter(Function> fn) { return charFilter(fn.apply(new CharFilter.Builder()).build()); } /** + * If true, the response includes token attributes and additional details. + *

* API name: {@code explain} + *

*/ + @Nonnull public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; @@ -372,53 +477,79 @@ public final Builder explain(@Nullable Boolean value) { /** * API name: {@code field} */ + @Nonnull public final Builder field(@Nullable String value) { this.field = value; return this; } /** + * Array of token filters used to apply after the tokenizer. + *

* API name: {@code filter} + *

+ * *

* Adds all elements of list to filter. + *

*/ + @Nonnull public final Builder filter(List list) { this.filter = _listAddAll(this.filter, list); return this; } /** + * Array of token filters used to apply after the tokenizer. + *

* API name: {@code filter} + *

+ * *

* Adds one or more values to filter. + *

*/ + @Nonnull public final Builder filter(TokenFilter value, TokenFilter... values) { this.filter = _listAdd(this.filter, value, values); return this; } /** + * Array of token filters used to apply after the tokenizer. + *

* API name: {@code filter} + *

+ * *

* Adds a value to filter using a builder lambda. + *

*/ + @Nonnull public final Builder filter(Function> fn) { return filter(fn.apply(new TokenFilter.Builder()).build()); } /** - * The name of the index to scope the operation + * Index used to derive the analyzer. If specified, the analyzer or field parameter overrides this value. If no index + * is specified or the index does not have a default analyzer, the analyze API uses the standard analyzer. *

* API name: {@code index} + *

*/ + @Nonnull public final Builder index(@Nullable String value) { this.index = value; return this; } /** + * Normalizer to use to convert text into a single token. + *

* API name: {@code normalizer} + *

*/ + @Nonnull public final Builder normalizer(@Nullable String value) { this.normalizer = value; return this; @@ -426,9 +557,12 @@ public final Builder normalizer(@Nullable String value) { /** * API name: {@code text} + * *

* Adds all elements of list to text. + *

*/ + @Nonnull public final Builder text(List list) { this.text = _listAddAll(this.text, list); return this; @@ -436,9 +570,12 @@ public final Builder text(List list) { /** * API name: {@code text} + * *

* Adds one or more values to text. + *

*/ + @Nonnull public final Builder text(String value, String... values) { this.text = _listAdd(this.text, value, values); return this; @@ -447,6 +584,7 @@ public final Builder text(String value, String... values) { /** * API name: {@code tokenizer} */ + @Nonnull public final Builder tokenizer(@Nullable Tokenizer value) { this.tokenizer = value; return this; @@ -455,16 +593,18 @@ public final Builder tokenizer(@Nullable Tokenizer value) { /** * API name: {@code tokenizer} */ + @Nonnull public final Builder tokenizer(Function> fn) { - return this.tokenizer(fn.apply(new Tokenizer.Builder()).build()); + return tokenizer(fn.apply(new Tokenizer.Builder()).build()); } /** * Builds a {@link AnalyzeRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public AnalyzeRequest build() { _checkSingleUse(); @@ -483,17 +623,16 @@ public AnalyzeRequest build() { ); protected static void setupAnalyzeRequestDeserializer(ObjectDeserializer op) { - op.add(Builder::analyzer, JsonpDeserializer.stringDeserializer(), "analyzer"); op.add(Builder::attributes, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "attributes"); op.add(Builder::charFilter, JsonpDeserializer.arrayDeserializer(CharFilter._DESERIALIZER), "char_filter"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::field, JsonpDeserializer.stringDeserializer(), "field"); op.add(Builder::filter, JsonpDeserializer.arrayDeserializer(TokenFilter._DESERIALIZER), "filter"); + op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); op.add(Builder::normalizer, JsonpDeserializer.stringDeserializer(), "normalizer"); op.add(Builder::text, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "text"); op.add(Builder::tokenizer, Tokenizer._DESERIALIZER, "tokenizer"); - } // --------------------------------------------------------------------------------------------- @@ -502,13 +641,8 @@ protected static void setupAnalyzeRequestDeserializer(ObjectDeserializer _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "POST"; - - }, - + request -> "POST", // Request path request -> { final int _index = 1 << 0; @@ -518,9 +652,7 @@ protected static void setupAnalyzeRequestDeserializer(ObjectDeserializer { - return Collections.emptyMap(); - - }, + SimpleEndpoint.emptyMap(), SimpleEndpoint.emptyMap(), true, AnalyzeResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.analyzer); + result = 31 * result + Objects.hashCode(this.attributes); + result = 31 * result + Objects.hashCode(this.charFilter); + result = 31 * result + Objects.hashCode(this.explain); + result = 31 * result + Objects.hashCode(this.field); + result = 31 * result + Objects.hashCode(this.filter); + result = 31 * result + Objects.hashCode(this.index); + result = 31 * result + Objects.hashCode(this.normalizer); + result = 31 * result + Objects.hashCode(this.text); + result = 31 * result + Objects.hashCode(this.tokenizer); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + AnalyzeRequest other = (AnalyzeRequest) o; + return Objects.equals(this.analyzer, other.analyzer) + && Objects.equals(this.attributes, other.attributes) + && Objects.equals(this.charFilter, other.charFilter) + && Objects.equals(this.explain, other.explain) + && Objects.equals(this.field, other.field) + && Objects.equals(this.filter, other.filter) + && Objects.equals(this.index, other.index) + && Objects.equals(this.normalizer, other.normalizer) + && Objects.equals(this.text, other.text) + && Objects.equals(this.tokenizer, other.tokenizer); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/AnalyzeResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AnalyzeResponse.java similarity index 72% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/AnalyzeResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/AnalyzeResponse.java index 8c46aad120..e1ed24fbc1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/AnalyzeResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AnalyzeResponse.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.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; @@ -45,28 +52,31 @@ import org.opensearch.client.opensearch.indices.analyze.AnalyzeDetail; import org.opensearch.client.opensearch.indices.analyze.AnalyzeToken; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.analyze.Response @JsonpDeserializable -public class AnalyzeResponse implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class AnalyzeResponse implements PlainJsonSerializable, ToCopyableBuilder { + @Nullable private final AnalyzeDetail detail; + @Nonnull private final List tokens; // --------------------------------------------------------------------------------------------- private AnalyzeResponse(Builder builder) { - this.detail = builder.detail; this.tokens = ApiTypeHelper.unmodifiable(builder.tokens); - } - public static AnalyzeResponse of(Function> fn) { + public static AnalyzeResponse of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -81,6 +91,7 @@ public final AnalyzeDetail detail() { /** * API name: {@code tokens} */ + @Nonnull public final List tokens() { return this.tokens; } @@ -88,6 +99,7 @@ public final List tokens() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -95,41 +107,65 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.detail != null) { generator.writeKey("detail"); this.detail.serialize(generator, mapper); - } + if (ApiTypeHelper.isDefined(this.tokens)) { generator.writeKey("tokens"); generator.writeStartArray(); for (AnalyzeToken item0 : this.tokens) { item0.serialize(generator, mapper); - } generator.writeEnd(); - } - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link AnalyzeResponse}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private AnalyzeDetail detail; - @Nullable private List tokens; + public Builder() {} + + private Builder(AnalyzeResponse o) { + this.detail = o.detail; + this.tokens = _listCopy(o.tokens); + } + + private Builder(Builder o) { + this.detail = o.detail; + this.tokens = _listCopy(o.tokens); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * API name: {@code detail} */ + @Nonnull public final Builder detail(@Nullable AnalyzeDetail value) { this.detail = value; return this; @@ -138,15 +174,19 @@ public final Builder detail(@Nullable AnalyzeDetail value) { /** * API name: {@code detail} */ + @Nonnull public final Builder detail(Function> fn) { - return this.detail(fn.apply(new AnalyzeDetail.Builder()).build()); + return detail(fn.apply(new AnalyzeDetail.Builder()).build()); } /** * API name: {@code tokens} + * *

* Adds all elements of list to tokens. + *

*/ + @Nonnull public final Builder tokens(List list) { this.tokens = _listAddAll(this.tokens, list); return this; @@ -154,9 +194,12 @@ public final Builder tokens(List list) { /** * API name: {@code tokens} + * *

* Adds one or more values to tokens. + *

*/ + @Nonnull public final Builder tokens(AnalyzeToken value, AnalyzeToken... values) { this.tokens = _listAdd(this.tokens, value, values); return this; @@ -164,9 +207,12 @@ public final Builder tokens(AnalyzeToken value, AnalyzeToken... values) { /** * API name: {@code tokens} + * *

* Adds a value to tokens using a builder lambda. + *

*/ + @Nonnull public final Builder tokens(Function> fn) { return tokens(fn.apply(new AnalyzeToken.Builder()).build()); } @@ -174,9 +220,10 @@ public final Builder tokens(Function op) { - op.add(Builder::detail, AnalyzeDetail._DESERIALIZER, "detail"); op.add(Builder::tokens, JsonpDeserializer.arrayDeserializer(AnalyzeToken._DESERIALIZER), "tokens"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.detail); + result = 31 * result + Objects.hashCode(this.tokens); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + AnalyzeResponse other = (AnalyzeResponse) o; + return Objects.equals(this.detail, other.detail) && Objects.equals(this.tokens, other.tokens); + } } 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 49ba9dbbb2..a4f049b6ff 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 @@ -78,6 +78,32 @@ public final CompletableFuture addBlock(Function analyze(AnalyzeRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, AnalyzeRequest._ENDPOINT, this.transportOptions); + } + + /** + * Performs the analysis process on a text and return the tokens breakdown of the text. + * + * @param fn a function that initializes a builder to create the {@link AnalyzeRequest} + */ + public final CompletableFuture analyze(Function> fn) + throws IOException, OpenSearchException { + return analyze(fn.apply(new AnalyzeRequest.Builder()).build()); + } + + /** + * Performs the analysis process on a text and return the tokens breakdown of the text. + */ + public final CompletableFuture analyze() throws IOException, OpenSearchException { + return analyze(new AnalyzeRequest.Builder().build()); + } + // ----- Endpoint: indices.create /** 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 47fe955a51..28b05f2466 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 @@ -77,6 +77,32 @@ public final AddBlockResponse addBlock(Function> fn) throws IOException, + OpenSearchException { + return analyze(fn.apply(new AnalyzeRequest.Builder()).build()); + } + + /** + * Performs the analysis process on a text and return the tokens breakdown of the text. + */ + public final AnalyzeResponse analyze() throws IOException, OpenSearchException { + return analyze(new AnalyzeRequest.Builder().build()); + } + // ----- Endpoint: indices.create /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeDetail.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeDetail.java similarity index 74% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeDetail.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeDetail.java index 21caa7e48a..f32ef449d4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeDetail.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeDetail.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.analyze; 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; @@ -43,20 +50,26 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.analyze.AnalyzeDetail @JsonpDeserializable -public class AnalyzeDetail implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class AnalyzeDetail implements PlainJsonSerializable, ToCopyableBuilder { + @Nullable private final AnalyzerDetail analyzer; + @Nonnull private final List charfilters; private final boolean customAnalyzer; + @Nonnull private final List tokenfilters; @Nullable @@ -65,16 +78,14 @@ public class AnalyzeDetail implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private AnalyzeDetail(Builder builder) { - this.analyzer = builder.analyzer; this.charfilters = ApiTypeHelper.unmodifiable(builder.charfilters); this.customAnalyzer = ApiTypeHelper.requireNonNull(builder.customAnalyzer, this, "customAnalyzer"); this.tokenfilters = ApiTypeHelper.unmodifiable(builder.tokenfilters); this.tokenizer = builder.tokenizer; - } - public static AnalyzeDetail of(Function> fn) { + public static AnalyzeDetail of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -89,6 +100,7 @@ public final AnalyzerDetail analyzer() { /** * API name: {@code charfilters} */ + @Nonnull public final List charfilters() { return this.charfilters; } @@ -103,6 +115,7 @@ public final boolean customAnalyzer() { /** * API name: {@code tokenfilters} */ + @Nonnull public final List tokenfilters() { return this.tokenfilters; } @@ -118,6 +131,7 @@ public final TokenDetail tokenizer() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -125,22 +139,20 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.analyzer != null) { generator.writeKey("analyzer"); this.analyzer.serialize(generator, mapper); - } + if (ApiTypeHelper.isDefined(this.charfilters)) { generator.writeKey("charfilters"); generator.writeStartArray(); for (CharFilterDetail item0 : this.charfilters) { item0.serialize(generator, mapper); - } generator.writeEnd(); - } + generator.writeKey("custom_analyzer"); generator.write(this.customAnalyzer); @@ -149,43 +161,71 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartArray(); for (TokenDetail item0 : this.tokenfilters) { item0.serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.tokenizer != null) { generator.writeKey("tokenizer"); this.tokenizer.serialize(generator, mapper); - } - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link AnalyzeDetail}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private AnalyzerDetail analyzer; - @Nullable private List charfilters; - private Boolean customAnalyzer; - @Nullable private List tokenfilters; - @Nullable private TokenDetail tokenizer; + public Builder() {} + + private Builder(AnalyzeDetail o) { + this.analyzer = o.analyzer; + this.charfilters = _listCopy(o.charfilters); + this.customAnalyzer = o.customAnalyzer; + this.tokenfilters = _listCopy(o.tokenfilters); + this.tokenizer = o.tokenizer; + } + + private Builder(Builder o) { + this.analyzer = o.analyzer; + this.charfilters = _listCopy(o.charfilters); + this.customAnalyzer = o.customAnalyzer; + this.tokenfilters = _listCopy(o.tokenfilters); + this.tokenizer = o.tokenizer; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * API name: {@code analyzer} */ + @Nonnull public final Builder analyzer(@Nullable AnalyzerDetail value) { this.analyzer = value; return this; @@ -194,15 +234,19 @@ public final Builder analyzer(@Nullable AnalyzerDetail value) { /** * API name: {@code analyzer} */ + @Nonnull public final Builder analyzer(Function> fn) { - return this.analyzer(fn.apply(new AnalyzerDetail.Builder()).build()); + return analyzer(fn.apply(new AnalyzerDetail.Builder()).build()); } /** * API name: {@code charfilters} + * *

* Adds all elements of list to charfilters. + *

*/ + @Nonnull public final Builder charfilters(List list) { this.charfilters = _listAddAll(this.charfilters, list); return this; @@ -210,9 +254,12 @@ public final Builder charfilters(List list) { /** * API name: {@code charfilters} + * *

* Adds one or more values to charfilters. + *

*/ + @Nonnull public final Builder charfilters(CharFilterDetail value, CharFilterDetail... values) { this.charfilters = _listAdd(this.charfilters, value, values); return this; @@ -220,9 +267,12 @@ public final Builder charfilters(CharFilterDetail value, CharFilterDetail... val /** * API name: {@code charfilters} + * *

* Adds a value to charfilters using a builder lambda. + *

*/ + @Nonnull public final Builder charfilters(Function> fn) { return charfilters(fn.apply(new CharFilterDetail.Builder()).build()); } @@ -230,6 +280,7 @@ public final Builder charfilters(Function * Adds all elements of list to tokenfilters. + *

*/ + @Nonnull public final Builder tokenfilters(List list) { this.tokenfilters = _listAddAll(this.tokenfilters, list); return this; @@ -247,9 +301,12 @@ public final Builder tokenfilters(List list) { /** * API name: {@code tokenfilters} + * *

* Adds one or more values to tokenfilters. + *

*/ + @Nonnull public final Builder tokenfilters(TokenDetail value, TokenDetail... values) { this.tokenfilters = _listAdd(this.tokenfilters, value, values); return this; @@ -257,9 +314,12 @@ public final Builder tokenfilters(TokenDetail value, TokenDetail... values) { /** * API name: {@code tokenfilters} + * *

* Adds a value to tokenfilters using a builder lambda. + *

*/ + @Nonnull public final Builder tokenfilters(Function> fn) { return tokenfilters(fn.apply(new TokenDetail.Builder()).build()); } @@ -267,6 +327,7 @@ public final Builder tokenfilters(Function> fn) { - return this.tokenizer(fn.apply(new TokenDetail.Builder()).build()); + return tokenizer(fn.apply(new TokenDetail.Builder()).build()); } /** * Builds a {@link AnalyzeDetail}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public AnalyzeDetail build() { _checkSingleUse(); @@ -303,13 +366,33 @@ public AnalyzeDetail build() { ); protected static void setupAnalyzeDetailDeserializer(ObjectDeserializer op) { - op.add(Builder::analyzer, AnalyzerDetail._DESERIALIZER, "analyzer"); op.add(Builder::charfilters, JsonpDeserializer.arrayDeserializer(CharFilterDetail._DESERIALIZER), "charfilters"); op.add(Builder::customAnalyzer, JsonpDeserializer.booleanDeserializer(), "custom_analyzer"); op.add(Builder::tokenfilters, JsonpDeserializer.arrayDeserializer(TokenDetail._DESERIALIZER), "tokenfilters"); op.add(Builder::tokenizer, TokenDetail._DESERIALIZER, "tokenizer"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.analyzer); + result = 31 * result + Objects.hashCode(this.charfilters); + result = 31 * result + Boolean.hashCode(this.customAnalyzer); + result = 31 * result + Objects.hashCode(this.tokenfilters); + result = 31 * result + Objects.hashCode(this.tokenizer); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + AnalyzeDetail other = (AnalyzeDetail) o; + return Objects.equals(this.analyzer, other.analyzer) + && Objects.equals(this.charfilters, other.charfilters) + && this.customAnalyzer == other.customAnalyzer + && Objects.equals(this.tokenfilters, other.tokenfilters) + && Objects.equals(this.tokenizer, other.tokenizer); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeToken.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeToken.java similarity index 60% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeToken.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeToken.java index 64ef1ff083..f273069a10 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeToken.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/AnalyzeToken.java @@ -30,10 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.analyze; import jakarta.json.stream.JsonGenerator; +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; @@ -42,75 +49,80 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.analyze.AnalyzeToken @JsonpDeserializable -public class AnalyzeToken implements PlainJsonSerializable { - private final long endOffset; +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class AnalyzeToken implements PlainJsonSerializable, ToCopyableBuilder { + + private final int endOffset; - private final long position; + private final int position; @Nullable - private final Long positionLength; + private final Integer positionLength; - private final long startOffset; + private final int startOffset; + @Nonnull private final String token; + @Nonnull private final String type; // --------------------------------------------------------------------------------------------- private AnalyzeToken(Builder builder) { - this.endOffset = ApiTypeHelper.requireNonNull(builder.endOffset, this, "endOffset"); this.position = ApiTypeHelper.requireNonNull(builder.position, this, "position"); this.positionLength = builder.positionLength; this.startOffset = ApiTypeHelper.requireNonNull(builder.startOffset, this, "startOffset"); this.token = ApiTypeHelper.requireNonNull(builder.token, this, "token"); this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - } - public static AnalyzeToken of(Function> fn) { + public static AnalyzeToken of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code end_offset} */ - public final long endOffset() { + public final int endOffset() { return this.endOffset; } /** * Required - API name: {@code position} */ - public final long position() { + public final int position() { return this.position; } /** - * API name: {@code position_length} + * API name: {@code positionLength} */ @Nullable - public final Long positionLength() { + public final Integer positionLength() { return this.positionLength; } /** * Required - API name: {@code start_offset} */ - public final long startOffset() { + public final int startOffset() { return this.startOffset; } /** * Required - API name: {@code token} */ + @Nonnull public final String token() { return this.token; } @@ -118,6 +130,7 @@ public final String token() { /** * Required - API name: {@code type} */ + @Nonnull public final String type() { return this.type; } @@ -125,6 +138,7 @@ public final String type() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -132,7 +146,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("end_offset"); generator.write(this.endOffset); @@ -140,10 +153,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.position); if (this.positionLength != null) { - generator.writeKey("position_length"); + generator.writeKey("positionLength"); generator.write(this.positionLength); - } + generator.writeKey("start_offset"); generator.write(this.startOffset); @@ -152,33 +165,64 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("type"); generator.write(this.type); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link AnalyzeToken}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long endOffset; - - private Long position; - + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + private Integer endOffset; + private Integer position; @Nullable - private Long positionLength; + private Integer positionLength; + private Integer startOffset; + private String token; + private String type; - private Long startOffset; + public Builder() {} - private String token; + private Builder(AnalyzeToken o) { + this.endOffset = o.endOffset; + this.position = o.position; + this.positionLength = o.positionLength; + this.startOffset = o.startOffset; + this.token = o.token; + this.type = o.type; + } - private String type; + private Builder(Builder o) { + this.endOffset = o.endOffset; + this.position = o.position; + this.positionLength = o.positionLength; + this.startOffset = o.startOffset; + this.token = o.token; + this.type = o.type; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } /** * Required - API name: {@code end_offset} */ - public final Builder endOffset(long value) { + @Nonnull + public final Builder endOffset(int value) { this.endOffset = value; return this; } @@ -186,15 +230,17 @@ public final Builder endOffset(long value) { /** * Required - API name: {@code position} */ - public final Builder position(long value) { + @Nonnull + public final Builder position(int value) { this.position = value; return this; } /** - * API name: {@code position_length} + * API name: {@code positionLength} */ - public final Builder positionLength(@Nullable Long value) { + @Nonnull + public final Builder positionLength(@Nullable Integer value) { this.positionLength = value; return this; } @@ -202,7 +248,8 @@ public final Builder positionLength(@Nullable Long value) { /** * Required - API name: {@code start_offset} */ - public final Builder startOffset(long value) { + @Nonnull + public final Builder startOffset(int value) { this.startOffset = value; return this; } @@ -210,6 +257,7 @@ public final Builder startOffset(long value) { /** * Required - API name: {@code token} */ + @Nonnull public final Builder token(String value) { this.token = value; return this; @@ -218,6 +266,7 @@ public final Builder token(String value) { /** * Required - API name: {@code type} */ + @Nonnull public final Builder type(String value) { this.type = value; return this; @@ -226,9 +275,10 @@ public final Builder type(String value) { /** * Builds a {@link AnalyzeToken}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public AnalyzeToken build() { _checkSingleUse(); @@ -247,14 +297,36 @@ public AnalyzeToken build() { ); protected static void setupAnalyzeTokenDeserializer(ObjectDeserializer op) { - - op.add(Builder::endOffset, JsonpDeserializer.longDeserializer(), "end_offset"); - op.add(Builder::position, JsonpDeserializer.longDeserializer(), "position"); - op.add(Builder::positionLength, JsonpDeserializer.longDeserializer(), "position_length"); - op.add(Builder::startOffset, JsonpDeserializer.longDeserializer(), "start_offset"); + op.add(Builder::endOffset, JsonpDeserializer.integerDeserializer(), "end_offset"); + op.add(Builder::position, JsonpDeserializer.integerDeserializer(), "position"); + op.add(Builder::positionLength, JsonpDeserializer.integerDeserializer(), "positionLength"); + op.add(Builder::startOffset, JsonpDeserializer.integerDeserializer(), "start_offset"); op.add(Builder::token, JsonpDeserializer.stringDeserializer(), "token"); op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Integer.hashCode(this.endOffset); + result = 31 * result + Integer.hashCode(this.position); + result = 31 * result + Objects.hashCode(this.positionLength); + result = 31 * result + Integer.hashCode(this.startOffset); + result = 31 * result + this.token.hashCode(); + result = 31 * result + this.type.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + AnalyzeToken other = (AnalyzeToken) o; + return this.endOffset == other.endOffset + && this.position == other.position + && Objects.equals(this.positionLength, other.positionLength) + && this.startOffset == other.startOffset + && this.token.equals(other.token) + && this.type.equals(other.type); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/AnalyzerDetail.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/AnalyzerDetail.java similarity index 70% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/AnalyzerDetail.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/AnalyzerDetail.java index bd1b4d4585..c1d148a573 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/AnalyzerDetail.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/AnalyzerDetail.java @@ -30,11 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.analyze; import jakarta.json.stream.JsonGenerator; import java.util.List; 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; @@ -42,33 +48,38 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.analyze.AnalyzerDetail @JsonpDeserializable -public class AnalyzerDetail implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class AnalyzerDetail implements PlainJsonSerializable, ToCopyableBuilder { + + @Nonnull private final String name; + @Nonnull private final List tokens; // --------------------------------------------------------------------------------------------- private AnalyzerDetail(Builder builder) { - this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.tokens = ApiTypeHelper.unmodifiableRequired(builder.tokens, this, "tokens"); - } - public static AnalyzerDetail of(Function> fn) { + public static AnalyzerDetail of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code name} */ + @Nonnull public final String name() { return this.name; } @@ -76,6 +87,7 @@ public final String name() { /** * Required - API name: {@code tokens} */ + @Nonnull public final List tokens() { return this.tokens; } @@ -83,6 +95,7 @@ public final List tokens() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -90,37 +103,59 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("name"); generator.write(this.name); - if (ApiTypeHelper.isDefined(this.tokens)) { - generator.writeKey("tokens"); - generator.writeStartArray(); - for (ExplainAnalyzeToken item0 : this.tokens) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - + generator.writeKey("tokens"); + generator.writeStartArray(); + for (ExplainAnalyzeToken item0 : this.tokens) { + item0.serialize(generator, mapper); } - + generator.writeEnd(); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link AnalyzerDetail}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private String name; - private List tokens; + public Builder() {} + + private Builder(AnalyzerDetail o) { + this.name = o.name; + this.tokens = _listCopy(o.tokens); + } + + private Builder(Builder o) { + this.name = o.name; + this.tokens = _listCopy(o.tokens); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * Required - API name: {@code name} */ + @Nonnull public final Builder name(String value) { this.name = value; return this; @@ -128,9 +163,12 @@ public final Builder name(String value) { /** * Required - API name: {@code tokens} + * *

* Adds all elements of list to tokens. + *

*/ + @Nonnull public final Builder tokens(List list) { this.tokens = _listAddAll(this.tokens, list); return this; @@ -138,9 +176,12 @@ public final Builder tokens(List list) { /** * Required - API name: {@code tokens} + * *

* Adds one or more values to tokens. + *

*/ + @Nonnull public final Builder tokens(ExplainAnalyzeToken value, ExplainAnalyzeToken... values) { this.tokens = _listAdd(this.tokens, value, values); return this; @@ -148,9 +189,12 @@ public final Builder tokens(ExplainAnalyzeToken value, ExplainAnalyzeToken... va /** * Required - API name: {@code tokens} + * *

* Adds a value to tokens using a builder lambda. + *

*/ + @Nonnull public final Builder tokens(Function> fn) { return tokens(fn.apply(new ExplainAnalyzeToken.Builder()).build()); } @@ -158,9 +202,10 @@ public final Builder tokens(Function op) { - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::tokens, JsonpDeserializer.arrayDeserializer(ExplainAnalyzeToken._DESERIALIZER), "tokens"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.name.hashCode(); + result = 31 * result + this.tokens.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + AnalyzerDetail other = (AnalyzerDetail) o; + return this.name.equals(other.name) && this.tokens.equals(other.tokens); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/CharFilterDetail.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/CharFilterDetail.java similarity index 68% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/CharFilterDetail.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/CharFilterDetail.java index 7f8fa6c61f..f7a2c0e451 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/CharFilterDetail.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/CharFilterDetail.java @@ -30,11 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.analyze; import jakarta.json.stream.JsonGenerator; import java.util.List; 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; @@ -42,33 +48,38 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.analyze.CharFilterDetail @JsonpDeserializable -public class CharFilterDetail implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class CharFilterDetail implements PlainJsonSerializable, ToCopyableBuilder { + + @Nonnull private final List filteredText; + @Nonnull private final String name; // --------------------------------------------------------------------------------------------- private CharFilterDetail(Builder builder) { - this.filteredText = ApiTypeHelper.unmodifiableRequired(builder.filteredText, this, "filteredText"); this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); - } - public static CharFilterDetail of(Function> fn) { + public static CharFilterDetail of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code filtered_text} */ + @Nonnull public final List filteredText() { return this.filteredText; } @@ -76,6 +87,7 @@ public final List filteredText() { /** * Required - API name: {@code name} */ + @Nonnull public final String name() { return this.name; } @@ -83,6 +95,7 @@ public final String name() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -90,38 +103,63 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.filteredText)) { - generator.writeKey("filtered_text"); - generator.writeStartArray(); - for (String item0 : this.filteredText) { - generator.write(item0); - - } - generator.writeEnd(); - + generator.writeKey("filtered_text"); + generator.writeStartArray(); + for (String item0 : this.filteredText) { + generator.write(item0); } + generator.writeEnd(); + generator.writeKey("name"); generator.write(this.name); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link CharFilterDetail}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private List filteredText; - private String name; + public Builder() {} + + private Builder(CharFilterDetail o) { + this.filteredText = _listCopy(o.filteredText); + this.name = o.name; + } + + private Builder(Builder o) { + this.filteredText = _listCopy(o.filteredText); + this.name = o.name; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * Required - API name: {@code filtered_text} + * *

* Adds all elements of list to filteredText. + *

*/ + @Nonnull public final Builder filteredText(List list) { this.filteredText = _listAddAll(this.filteredText, list); return this; @@ -129,9 +167,12 @@ public final Builder filteredText(List list) { /** * Required - API name: {@code filtered_text} + * *

* Adds one or more values to filteredText. + *

*/ + @Nonnull public final Builder filteredText(String value, String... values) { this.filteredText = _listAdd(this.filteredText, value, values); return this; @@ -140,6 +181,7 @@ public final Builder filteredText(String value, String... values) { /** * Required - API name: {@code name} */ + @Nonnull public final Builder name(String value) { this.name = value; return this; @@ -148,9 +190,10 @@ public final Builder name(String value) { /** * Builds a {@link CharFilterDetail}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public CharFilterDetail build() { _checkSingleUse(); @@ -169,10 +212,23 @@ public CharFilterDetail build() { ); protected static void setupCharFilterDetailDeserializer(ObjectDeserializer op) { - op.add(Builder::filteredText, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "filtered_text"); op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.filteredText.hashCode(); + result = 31 * result + this.name.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + CharFilterDetail other = (CharFilterDetail) o; + return this.filteredText.equals(other.filteredText) && this.name.equals(other.name); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/ExplainAnalyzeToken.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/ExplainAnalyzeToken.java similarity index 59% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/ExplainAnalyzeToken.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/ExplainAnalyzeToken.java index b7ac17bfb4..276d3a71aa 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/ExplainAnalyzeToken.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/ExplainAnalyzeToken.java @@ -30,10 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.analyze; import jakarta.json.stream.JsonGenerator; +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; @@ -42,55 +49,61 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.analyze.ExplainAnalyzeToken @JsonpDeserializable -public class ExplainAnalyzeToken implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class ExplainAnalyzeToken implements PlainJsonSerializable, ToCopyableBuilder { + + @Nonnull private final String bytes; - private final long endOffset; + private final int endOffset; @Nullable private final Boolean keyword; - private final long position; + private final int position; - private final long positionlength; + private final int positionLength; - private final long startOffset; + private final int startOffset; - private final long termfrequency; + private final int termFrequency; + @Nonnull private final String token; + @Nonnull private final String type; // --------------------------------------------------------------------------------------------- private ExplainAnalyzeToken(Builder builder) { - this.bytes = ApiTypeHelper.requireNonNull(builder.bytes, this, "bytes"); this.endOffset = ApiTypeHelper.requireNonNull(builder.endOffset, this, "endOffset"); this.keyword = builder.keyword; this.position = ApiTypeHelper.requireNonNull(builder.position, this, "position"); - this.positionlength = ApiTypeHelper.requireNonNull(builder.positionlength, this, "positionlength"); + this.positionLength = ApiTypeHelper.requireNonNull(builder.positionLength, this, "positionLength"); this.startOffset = ApiTypeHelper.requireNonNull(builder.startOffset, this, "startOffset"); - this.termfrequency = ApiTypeHelper.requireNonNull(builder.termfrequency, this, "termfrequency"); + this.termFrequency = ApiTypeHelper.requireNonNull(builder.termFrequency, this, "termFrequency"); this.token = ApiTypeHelper.requireNonNull(builder.token, this, "token"); this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - } - public static ExplainAnalyzeToken of(Function> fn) { + public static ExplainAnalyzeToken of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code bytes} */ + @Nonnull public final String bytes() { return this.bytes; } @@ -98,7 +111,7 @@ public final String bytes() { /** * Required - API name: {@code end_offset} */ - public final long endOffset() { + public final int endOffset() { return this.endOffset; } @@ -113,34 +126,35 @@ public final Boolean keyword() { /** * Required - API name: {@code position} */ - public final long position() { + public final int position() { return this.position; } /** * Required - API name: {@code positionLength} */ - public final long positionlength() { - return this.positionlength; + public final int positionLength() { + return this.positionLength; } /** * Required - API name: {@code start_offset} */ - public final long startOffset() { + public final int startOffset() { return this.startOffset; } /** * Required - API name: {@code termFrequency} */ - public final long termfrequency() { - return this.termfrequency; + public final int termFrequency() { + return this.termFrequency; } /** * Required - API name: {@code token} */ + @Nonnull public final String token() { return this.token; } @@ -148,6 +162,7 @@ public final String token() { /** * Required - API name: {@code type} */ + @Nonnull public final String type() { return this.type; } @@ -155,6 +170,7 @@ public final String type() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -162,7 +178,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("bytes"); generator.write(this.bytes); @@ -172,57 +187,91 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (this.keyword != null) { generator.writeKey("keyword"); generator.write(this.keyword); - } + generator.writeKey("position"); generator.write(this.position); generator.writeKey("positionLength"); - generator.write(this.positionlength); + generator.write(this.positionLength); generator.writeKey("start_offset"); generator.write(this.startOffset); generator.writeKey("termFrequency"); - generator.write(this.termfrequency); + generator.write(this.termFrequency); generator.writeKey("token"); generator.write(this.token); generator.writeKey("type"); generator.write(this.type); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link ExplainAnalyzeToken}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private String bytes; - - private Long endOffset; - + private Integer endOffset; @Nullable private Boolean keyword; + private Integer position; + private Integer positionLength; + private Integer startOffset; + private Integer termFrequency; + private String token; + private String type; - private Long position; - - private Long positionlength; - - private Long startOffset; - - private Long termfrequency; + public Builder() {} + + private Builder(ExplainAnalyzeToken o) { + this.bytes = o.bytes; + this.endOffset = o.endOffset; + this.keyword = o.keyword; + this.position = o.position; + this.positionLength = o.positionLength; + this.startOffset = o.startOffset; + this.termFrequency = o.termFrequency; + this.token = o.token; + this.type = o.type; + } - private String token; + private Builder(Builder o) { + this.bytes = o.bytes; + this.endOffset = o.endOffset; + this.keyword = o.keyword; + this.position = o.position; + this.positionLength = o.positionLength; + this.startOffset = o.startOffset; + this.termFrequency = o.termFrequency; + this.token = o.token; + this.type = o.type; + } - private String type; + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } /** * Required - API name: {@code bytes} */ + @Nonnull public final Builder bytes(String value) { this.bytes = value; return this; @@ -231,7 +280,8 @@ public final Builder bytes(String value) { /** * Required - API name: {@code end_offset} */ - public final Builder endOffset(long value) { + @Nonnull + public final Builder endOffset(int value) { this.endOffset = value; return this; } @@ -239,6 +289,7 @@ public final Builder endOffset(long value) { /** * API name: {@code keyword} */ + @Nonnull public final Builder keyword(@Nullable Boolean value) { this.keyword = value; return this; @@ -247,7 +298,8 @@ public final Builder keyword(@Nullable Boolean value) { /** * Required - API name: {@code position} */ - public final Builder position(long value) { + @Nonnull + public final Builder position(int value) { this.position = value; return this; } @@ -255,15 +307,17 @@ public final Builder position(long value) { /** * Required - API name: {@code positionLength} */ - public final Builder positionlength(long value) { - this.positionlength = value; + @Nonnull + public final Builder positionLength(int value) { + this.positionLength = value; return this; } /** * Required - API name: {@code start_offset} */ - public final Builder startOffset(long value) { + @Nonnull + public final Builder startOffset(int value) { this.startOffset = value; return this; } @@ -271,14 +325,16 @@ public final Builder startOffset(long value) { /** * Required - API name: {@code termFrequency} */ - public final Builder termfrequency(long value) { - this.termfrequency = value; + @Nonnull + public final Builder termFrequency(int value) { + this.termFrequency = value; return this; } /** * Required - API name: {@code token} */ + @Nonnull public final Builder token(String value) { this.token = value; return this; @@ -287,6 +343,7 @@ public final Builder token(String value) { /** * Required - API name: {@code type} */ + @Nonnull public final Builder type(String value) { this.type = value; return this; @@ -295,9 +352,10 @@ public final Builder type(String value) { /** * Builds a {@link ExplainAnalyzeToken}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public ExplainAnalyzeToken build() { _checkSingleUse(); @@ -316,17 +374,45 @@ public ExplainAnalyzeToken build() { ); protected static void setupExplainAnalyzeTokenDeserializer(ObjectDeserializer op) { - op.add(Builder::bytes, JsonpDeserializer.stringDeserializer(), "bytes"); - op.add(Builder::endOffset, JsonpDeserializer.longDeserializer(), "end_offset"); + op.add(Builder::endOffset, JsonpDeserializer.integerDeserializer(), "end_offset"); op.add(Builder::keyword, JsonpDeserializer.booleanDeserializer(), "keyword"); - op.add(Builder::position, JsonpDeserializer.longDeserializer(), "position"); - op.add(Builder::positionlength, JsonpDeserializer.longDeserializer(), "positionLength"); - op.add(Builder::startOffset, JsonpDeserializer.longDeserializer(), "start_offset"); - op.add(Builder::termfrequency, JsonpDeserializer.longDeserializer(), "termFrequency"); + op.add(Builder::position, JsonpDeserializer.integerDeserializer(), "position"); + op.add(Builder::positionLength, JsonpDeserializer.integerDeserializer(), "positionLength"); + op.add(Builder::startOffset, JsonpDeserializer.integerDeserializer(), "start_offset"); + op.add(Builder::termFrequency, JsonpDeserializer.integerDeserializer(), "termFrequency"); op.add(Builder::token, JsonpDeserializer.stringDeserializer(), "token"); op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.bytes.hashCode(); + result = 31 * result + Integer.hashCode(this.endOffset); + result = 31 * result + Objects.hashCode(this.keyword); + result = 31 * result + Integer.hashCode(this.position); + result = 31 * result + Integer.hashCode(this.positionLength); + result = 31 * result + Integer.hashCode(this.startOffset); + result = 31 * result + Integer.hashCode(this.termFrequency); + result = 31 * result + this.token.hashCode(); + result = 31 * result + this.type.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + ExplainAnalyzeToken other = (ExplainAnalyzeToken) o; + return this.bytes.equals(other.bytes) + && this.endOffset == other.endOffset + && Objects.equals(this.keyword, other.keyword) + && this.position == other.position + && this.positionLength == other.positionLength + && this.startOffset == other.startOffset + && this.termFrequency == other.termFrequency + && this.token.equals(other.token) + && this.type.equals(other.type); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/TokenDetail.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/TokenDetail.java similarity index 70% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/TokenDetail.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/TokenDetail.java index 3a6a9c0c29..c8637839cb 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/analyze/TokenDetail.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/analyze/TokenDetail.java @@ -30,11 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.analyze; import jakarta.json.stream.JsonGenerator; import java.util.List; 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; @@ -42,33 +48,38 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.analyze.TokenDetail @JsonpDeserializable -public class TokenDetail implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class TokenDetail implements PlainJsonSerializable, ToCopyableBuilder { + + @Nonnull private final String name; + @Nonnull private final List tokens; // --------------------------------------------------------------------------------------------- private TokenDetail(Builder builder) { - this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.tokens = ApiTypeHelper.unmodifiableRequired(builder.tokens, this, "tokens"); - } - public static TokenDetail of(Function> fn) { + public static TokenDetail of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code name} */ + @Nonnull public final String name() { return this.name; } @@ -76,6 +87,7 @@ public final String name() { /** * Required - API name: {@code tokens} */ + @Nonnull public final List tokens() { return this.tokens; } @@ -83,6 +95,7 @@ public final List tokens() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -90,37 +103,59 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("name"); generator.write(this.name); - if (ApiTypeHelper.isDefined(this.tokens)) { - generator.writeKey("tokens"); - generator.writeStartArray(); - for (ExplainAnalyzeToken item0 : this.tokens) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - + generator.writeKey("tokens"); + generator.writeStartArray(); + for (ExplainAnalyzeToken item0 : this.tokens) { + item0.serialize(generator, mapper); } - + generator.writeEnd(); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link TokenDetail}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { private String name; - private List tokens; + public Builder() {} + + private Builder(TokenDetail o) { + this.name = o.name; + this.tokens = _listCopy(o.tokens); + } + + private Builder(Builder o) { + this.name = o.name; + this.tokens = _listCopy(o.tokens); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * Required - API name: {@code name} */ + @Nonnull public final Builder name(String value) { this.name = value; return this; @@ -128,9 +163,12 @@ public final Builder name(String value) { /** * Required - API name: {@code tokens} + * *

* Adds all elements of list to tokens. + *

*/ + @Nonnull public final Builder tokens(List list) { this.tokens = _listAddAll(this.tokens, list); return this; @@ -138,9 +176,12 @@ public final Builder tokens(List list) { /** * Required - API name: {@code tokens} + * *

* Adds one or more values to tokens. + *

*/ + @Nonnull public final Builder tokens(ExplainAnalyzeToken value, ExplainAnalyzeToken... values) { this.tokens = _listAdd(this.tokens, value, values); return this; @@ -148,9 +189,12 @@ public final Builder tokens(ExplainAnalyzeToken value, ExplainAnalyzeToken... va /** * Required - API name: {@code tokens} + * *

* Adds a value to tokens using a builder lambda. + *

*/ + @Nonnull public final Builder tokens(Function> fn) { return tokens(fn.apply(new ExplainAnalyzeToken.Builder()).build()); } @@ -158,9 +202,10 @@ public final Builder tokens(Function op) { - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::tokens, JsonpDeserializer.arrayDeserializer(ExplainAnalyzeToken._DESERIALIZER), "tokens"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.name.hashCode(); + result = 31 * result + this.tokens.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + TokenDetail other = (TokenDetail) o; + return this.name.equals(other.name) && this.tokens.equals(other.tokens); + } } 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 72ad5500c8..4ed3d69935 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 @@ -61,51 +61,6 @@ public OpenSearchIndicesAsyncClient withTransportOptions(@Nullable TransportOpti return new OpenSearchIndicesAsyncClient(this.transport, transportOptions); } - // ----- Endpoint: indices.analyze - - /** - * Performs the analysis process on a text and return the tokens breakdown of - * the text. - * - * - */ - - public CompletableFuture analyze(AnalyzeRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - AnalyzeRequest, - AnalyzeResponse, - ErrorResponse>) AnalyzeRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Performs the analysis process on a text and return the tokens breakdown of - * the text. - * - * @param fn - * a function that initializes a builder to create the - * {@link AnalyzeRequest} - * - */ - - public final CompletableFuture analyze(Function> fn) - throws IOException, OpenSearchException { - return analyze(fn.apply(new AnalyzeRequest.Builder()).build()); - } - - /** - * Performs the analysis process on a text and return the tokens breakdown of - * the text. - * - * - */ - - public CompletableFuture analyze() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new AnalyzeRequest.Builder().build(), AnalyzeRequest._ENDPOINT, this.transportOptions); - } - // ----- Endpoint: indices.clear_cache /** 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 9163dc1a4b..c84ff0775f 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 @@ -60,48 +60,6 @@ public OpenSearchIndicesClient withTransportOptions(@Nullable TransportOptions t return new OpenSearchIndicesClient(this.transport, transportOptions); } - // ----- Endpoint: indices.analyze - - /** - * Performs the analysis process on a text and return the tokens breakdown of - * the text. - * - */ - - public AnalyzeResponse analyze(AnalyzeRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - AnalyzeRequest, - AnalyzeResponse, - ErrorResponse>) AnalyzeRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Performs the analysis process on a text and return the tokens breakdown of - * the text. - * - * @param fn - * a function that initializes a builder to create the - * {@link AnalyzeRequest} - */ - - public final AnalyzeResponse analyze(Function> fn) throws IOException, - OpenSearchException { - return analyze(fn.apply(new AnalyzeRequest.Builder()).build()); - } - - /** - * Performs the analysis process on a text and return the tokens breakdown of - * the text. - * - */ - - public AnalyzeResponse analyze() throws IOException, OpenSearchException { - return this.transport.performRequest(new AnalyzeRequest.Builder().build(), AnalyzeRequest._ENDPOINT, this.transportOptions); - } - // ----- Endpoint: indices.clear_cache /** diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index 48db1f179e..e5f8b7b4d5 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -50820,13 +50820,17 @@ components: type: object properties: end_offset: - type: number + type: integer + format: int32 position: - type: number + type: integer + format: int32 positionLength: - type: number + type: integer + format: int32 start_offset: - type: number + type: integer + format: int32 token: type: string type: @@ -50855,17 +50859,22 @@ components: bytes: type: string end_offset: - type: number + type: integer + format: int32 keyword: type: boolean position: - type: number + type: integer + format: int32 positionLength: - type: number + type: integer + format: int32 start_offset: - type: number + type: integer + format: int32 termFrequency: - type: number + type: integer + format: int32 token: type: string type: 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 2483f22ff9..928fafbf1d 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 @@ -53,7 +53,7 @@ public class CodeGenerator { namespace(is("indices")), name( or( - isOneOf("add_block", "create", "delete", "exists", "get"), + isOneOf("add_block", "analyze", "create", "delete", "exists", "get"), contains("alias"), contains("data_stream"), and(endsWith("mapping"), isNot("get_field_mapping")), From 3a63740d0160d42948b4749c733798cbc7948920 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 16 Dec 2024 10:10:19 +1300 Subject: [PATCH 4/7] Generate indices.clear_cache Signed-off-by: Thomas Farr --- .../_types/ShardsOperationResponseBase.java | 52 +++- .../opensearch/indices/ClearCacheRequest.java | 288 +++++++++++++----- .../indices/ClearCacheResponse.java | 70 ++++- .../OpenSearchIndicesAsyncClientBase.java | 26 ++ .../indices/OpenSearchIndicesClientBase.java | 26 ++ .../indices/OpenSearchIndicesAsyncClient.java | 46 --- .../indices/OpenSearchIndicesClient.java | 39 --- .../client/codegen/CodeGenerator.java | 2 +- 8 files changed, 374 insertions(+), 175 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/ShardsOperationResponseBase.java (73%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/ClearCacheRequest.java (53%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/ClearCacheResponse.java (62%) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ShardsOperationResponseBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardsOperationResponseBase.java similarity index 73% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/ShardsOperationResponseBase.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardsOperationResponseBase.java index a934ae5adb..83c1375376 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ShardsOperationResponseBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardsOperationResponseBase.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.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; @@ -43,20 +49,22 @@ // typedef: _types.ShardsOperationResponseBase +@Generated("org.opensearch.client.codegen.CodeGenerator") public abstract class ShardsOperationResponseBase implements PlainJsonSerializable { + + @Nonnull private final ShardStatistics shards; // --------------------------------------------------------------------------------------------- protected ShardsOperationResponseBase(AbstractBuilder builder) { - this.shards = ApiTypeHelper.requireNonNull(builder.shards, this, "shards"); - } /** * Required - API name: {@code _shards} */ + @Nonnull public final ShardStatistics shards() { return this.shards; } @@ -64,6 +72,7 @@ public final ShardStatistics shards() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -71,18 +80,32 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("_shards"); this.shards.serialize(generator, mapper); - } + // --------------------------------------------------------------------------------------------- + protected abstract static class AbstractBuilder> extends ObjectBuilderBase { private ShardStatistics shards; + protected AbstractBuilder() {} + + protected AbstractBuilder(ShardsOperationResponseBase o) { + this.shards = o.shards; + } + + protected AbstractBuilder(AbstractBuilder o) { + this.shards = o.shards; + } + + @Nonnull + protected abstract BuilderT self(); + /** * Required - API name: {@code _shards} */ + @Nonnull public final BuilderT shards(ShardStatistics value) { this.shards = value; return self(); @@ -91,21 +114,32 @@ public final BuilderT shards(ShardStatistics value) { /** * Required - API name: {@code _shards} */ + @Nonnull public final BuilderT shards(Function> fn) { - return this.shards(fn.apply(new ShardStatistics.Builder()).build()); + return shards(fn.apply(new ShardStatistics.Builder()).build()); } - - protected abstract BuilderT self(); - } // --------------------------------------------------------------------------------------------- + protected static > void setupShardsOperationResponseBaseDeserializer( ObjectDeserializer op ) { - op.add(AbstractBuilder::shards, ShardStatistics._DESERIALIZER, "_shards"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.shards.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + ShardsOperationResponseBase other = (ShardsOperationResponseBase) o; + return this.shards.equals(other.shards); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ClearCacheRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ClearCacheRequest.java similarity index 53% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/ClearCacheRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/ClearCacheRequest.java index d49e35482b..bcdb1e5454 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ClearCacheRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ClearCacheRequest.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; @@ -44,30 +51,38 @@ import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.SimpleEndpoint; import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.clear_cache.Request /** - * Clears all or specific caches for one or more indices. - * + * Clears all or specific caches for one or more indexes. */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class ClearCacheRequest extends RequestBase implements ToCopyableBuilder { -public class ClearCacheRequest extends RequestBase { @Nullable private final Boolean allowNoIndices; + @Nonnull private final List expandWildcards; @Nullable private final Boolean fielddata; + @Nonnull private final List fields; + @Nullable + private final Boolean file; + @Nullable private final Boolean ignoreUnavailable; + @Nonnull private final List index; @Nullable @@ -79,28 +94,27 @@ public class ClearCacheRequest extends RequestBase { // --------------------------------------------------------------------------------------------- private ClearCacheRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.fielddata = builder.fielddata; this.fields = ApiTypeHelper.unmodifiable(builder.fields); + this.file = builder.file; this.ignoreUnavailable = builder.ignoreUnavailable; this.index = ApiTypeHelper.unmodifiable(builder.index); this.query = builder.query; this.request = builder.request; - } - public static ClearCacheRequest of(Function> fn) { + public static ClearCacheRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Whether to ignore if a wildcard indices expression resolves into no concrete - * indices. (This includes _all string or when no indices have been - * specified) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets only + * missing or closed indexes. This behavior applies even if the request targets other open indexes. *

* API name: {@code allow_no_indices} + *

*/ @Nullable public final Boolean allowNoIndices() { @@ -108,19 +122,23 @@ public final Boolean allowNoIndices() { } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * 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; } /** - * Clear field data + * If true, clears the fields cache. Use the fields parameter to clear the cache of specific fields only. *

* API name: {@code fielddata} + *

*/ @Nullable public final Boolean fielddata() { @@ -128,20 +146,32 @@ public final Boolean fielddata() { } /** - * A comma-separated list of fields to clear when using the - * fielddata parameter (default: all) + * Comma-separated list of field names used to limit the fielddata parameter. *

* API name: {@code fields} + *

*/ + @Nonnull public final List fields() { return this.fields; } /** - * Whether specified concrete indices should be ignored when unavailable - * (missing or closed) + * If true, clears the unused entries from the file cache on nodes with the Search role. + *

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

+ */ + @Nullable + public final Boolean file() { + return this.file; + } + + /** + * 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() { @@ -149,18 +179,22 @@ public final Boolean ignoreUnavailable() { } /** - * A comma-separated list of index name to limit the operation + * Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (*). To target + * all data streams and indexes, omit this parameter or use * or _all. *

* API name: {@code index} + *

*/ + @Nonnull public final List index() { return this.index; } /** - * Clear query caches + * If true, clears the query cache. *

* API name: {@code query} + *

*/ @Nullable public final Boolean query() { @@ -168,9 +202,10 @@ public final Boolean query() { } /** - * Clear request cache + * If true, clears the request cache. *

* API name: {@code request} + *

*/ @Nullable public final Boolean request() { @@ -179,159 +214,242 @@ public final Boolean request() { // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link ClearCacheRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private Boolean allowNoIndices; - @Nullable private List expandWildcards; - @Nullable private Boolean fielddata; - @Nullable private List fields; - + @Nullable + private Boolean file; @Nullable private Boolean ignoreUnavailable; - @Nullable private List index; - @Nullable private Boolean query; - @Nullable private Boolean request; + public Builder() {} + + private Builder(ClearCacheRequest o) { + this.allowNoIndices = o.allowNoIndices; + this.expandWildcards = _listCopy(o.expandWildcards); + this.fielddata = o.fielddata; + this.fields = _listCopy(o.fields); + this.file = o.file; + this.ignoreUnavailable = o.ignoreUnavailable; + this.index = _listCopy(o.index); + this.query = o.query; + this.request = o.request; + } + + private Builder(Builder o) { + this.allowNoIndices = o.allowNoIndices; + this.expandWildcards = _listCopy(o.expandWildcards); + this.fielddata = o.fielddata; + this.fields = _listCopy(o.fields); + this.file = o.file; + this.ignoreUnavailable = o.ignoreUnavailable; + this.index = _listCopy(o.index); + this.query = o.query; + this.request = o.request; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** - * Whether to ignore if a wildcard indices expression resolves into no concrete - * indices. (This includes _all string or when no indices have been - * specified) + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets + * only missing or closed indexes. This behavior applies even if the request targets other open indexes. *

* API name: {@code allow_no_indices} + *

*/ + @Nonnull public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * 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. + *

*/ + @Nonnull public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** - * Whether to expand wildcard expression to concrete indices that are open, - * closed or both. + * 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. + *

*/ + @Nonnull public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** - * Clear field data + * If true, clears the fields cache. Use the fields parameter to clear the cache of specific fields only. *

* API name: {@code fielddata} + *

*/ + @Nonnull public final Builder fielddata(@Nullable Boolean value) { this.fielddata = value; return this; } /** - * A comma-separated list of fields to clear when using the - * fielddata parameter (default: all) + * Comma-separated list of field names used to limit the fielddata parameter. *

* API name: {@code fields} + *

+ * *

* Adds all elements of list to fields. + *

*/ + @Nonnull public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** - * A comma-separated list of fields to clear when using the - * fielddata parameter (default: all) + * Comma-separated list of field names used to limit the fielddata parameter. *

* API name: {@code fields} + *

+ * *

* Adds one or more values to fields. + *

*/ + @Nonnull public final Builder fields(String value, String... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** - * Whether specified concrete indices should be ignored when unavailable - * (missing or closed) + * If true, clears the unused entries from the file cache on nodes with the Search role. + *

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

+ */ + @Nonnull + public final Builder file(@Nullable Boolean value) { + this.file = value; + return this; + } + + /** + * If false, the request returns an error if it targets a missing or closed index. *

* API name: {@code ignore_unavailable} + *

*/ + @Nonnull public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** - * A comma-separated list of index name to limit the operation + * Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (*). To + * target all data streams and indexes, omit this parameter or use * or _all. *

* API name: {@code index} + *

+ * *

* Adds all elements of list to index. + *

*/ + @Nonnull public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** - * A comma-separated list of index name to limit the operation + * Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (*). To + * target all data streams and indexes, omit this parameter or use * or _all. *

* API name: {@code index} + *

+ * *

* Adds one or more values to index. + *

*/ + @Nonnull public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** - * Clear query caches + * If true, clears the query cache. *

* API name: {@code query} + *

*/ + @Nonnull public final Builder query(@Nullable Boolean value) { this.query = value; return this; } /** - * Clear request cache + * If true, clears the request cache. *

* API name: {@code request} + *

*/ + @Nonnull public final Builder request(@Nullable Boolean value) { this.request = value; return this; @@ -340,9 +458,10 @@ public final Builder request(@Nullable Boolean value) { /** * Builds a {@link ClearCacheRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public ClearCacheRequest build() { _checkSingleUse(); @@ -356,13 +475,8 @@ public ClearCacheRequest build() { * Endpoint "{@code indices.clear_cache}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "POST"; - - }, - + request -> "POST", // Request path request -> { final int _index = 1 << 0; @@ -372,52 +486,80 @@ public ClearCacheRequest build() { if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { - StringBuilder buf = new StringBuilder(); - buf.append("/_cache"); - buf.append("/clear"); - return buf.toString(); + return "/_cache/clear"; } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); - SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); - buf.append("/_cache"); - buf.append("/clear"); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + buf.append("/_cache/clear"); return buf.toString(); } - throw SimpleEndpoint.noPathTemplateFound("path"); + throw SimpleEndpoint.noPathTemplateFound("path"); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.request != null) { - params.put("request", String.valueOf(request.request)); + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); + } + if (ApiTypeHelper.isDefined(request.expandWildcards)) { + params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.fielddata != null) { params.put("fielddata", String.valueOf(request.fielddata)); } - if (ApiTypeHelper.isDefined(request.expandWildcards)) { - params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); + if (ApiTypeHelper.isDefined(request.fields)) { + params.put("fields", String.join(",", request.fields)); + } + if (request.file != null) { + params.put("file", String.valueOf(request.file)); } 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.query != null) { params.put("query", String.valueOf(request.query)); } - if (ApiTypeHelper.isDefined(request.fields)) { - params.put("fields", request.fields.stream().map(v -> v).collect(Collectors.joining(","))); + if (request.request != null) { + params.put("request", String.valueOf(request.request)); } return params; - }, SimpleEndpoint.emptyMap(), false, ClearCacheResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allowNoIndices); + result = 31 * result + Objects.hashCode(this.expandWildcards); + result = 31 * result + Objects.hashCode(this.fielddata); + result = 31 * result + Objects.hashCode(this.fields); + result = 31 * result + Objects.hashCode(this.file); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + Objects.hashCode(this.index); + result = 31 * result + Objects.hashCode(this.query); + result = 31 * result + Objects.hashCode(this.request); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + ClearCacheRequest other = (ClearCacheRequest) o; + return Objects.equals(this.allowNoIndices, other.allowNoIndices) + && Objects.equals(this.expandWildcards, other.expandWildcards) + && Objects.equals(this.fielddata, other.fielddata) + && Objects.equals(this.fields, other.fields) + && Objects.equals(this.file, other.file) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.index, other.index) + && Objects.equals(this.query, other.query) + && Objects.equals(this.request, other.request); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ClearCacheResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ClearCacheResponse.java similarity index 62% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/ClearCacheResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/ClearCacheResponse.java index 59c73cca02..3c9c144f0a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ClearCacheResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ClearCacheResponse.java @@ -30,39 +30,80 @@ * 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 javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.opensearch._types.ShardsOperationResponseBase; +import org.opensearch.client.util.CopyableBuilder; import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ToCopyableBuilder; // typedef: indices.clear_cache.Response @JsonpDeserializable -public class ClearCacheResponse extends ShardsOperationResponseBase { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class ClearCacheResponse extends ShardsOperationResponseBase + implements + ToCopyableBuilder { + // --------------------------------------------------------------------------------------------- private ClearCacheResponse(Builder builder) { super(builder); - } - public static ClearCacheResponse of(Function> fn) { + public static ClearCacheResponse of(Function> fn) { return fn.apply(new Builder()).build(); } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link ClearCacheResponse}. */ + public static class Builder extends ShardsOperationResponseBase.AbstractBuilder + implements + CopyableBuilder { + + public Builder() {} + + private Builder(ClearCacheResponse o) { + super(o); + } + + private Builder(Builder o) { + super(o); + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } - public static class Builder extends ShardsOperationResponseBase.AbstractBuilder implements ObjectBuilder { @Override + @Nonnull protected Builder self() { return this; } @@ -70,9 +111,10 @@ protected Builder self() { /** * Builds a {@link ClearCacheResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public ClearCacheResponse build() { _checkSingleUse(); @@ -91,8 +133,22 @@ public ClearCacheResponse build() { ); protected static void setupClearCacheResponseDeserializer(ObjectDeserializer op) { - ShardsOperationResponseBase.setupShardsOperationResponseBaseDeserializer(op); + setupShardsOperationResponseBaseDeserializer(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/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java index a4f049b6ff..6ef9e102c2 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 @@ -104,6 +104,32 @@ public final CompletableFuture analyze() throws IOException, Op return analyze(new AnalyzeRequest.Builder().build()); } + // ----- Endpoint: indices.clear_cache + + /** + * Clears all or specific caches for one or more indexes. + */ + public CompletableFuture clearCache(ClearCacheRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, ClearCacheRequest._ENDPOINT, this.transportOptions); + } + + /** + * Clears all or specific caches for one or more indexes. + * + * @param fn a function that initializes a builder to create the {@link ClearCacheRequest} + */ + public final CompletableFuture clearCache(Function> fn) + throws IOException, OpenSearchException { + return clearCache(fn.apply(new ClearCacheRequest.Builder()).build()); + } + + /** + * Clears all or specific caches for one or more indexes. + */ + public final CompletableFuture clearCache() throws IOException, OpenSearchException { + return clearCache(new ClearCacheRequest.Builder().build()); + } + // ----- Endpoint: indices.create /** 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 28b05f2466..129c1e0e6a 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 @@ -103,6 +103,32 @@ public final AnalyzeResponse analyze() throws IOException, OpenSearchException { return analyze(new AnalyzeRequest.Builder().build()); } + // ----- Endpoint: indices.clear_cache + + /** + * Clears all or specific caches for one or more indexes. + */ + public ClearCacheResponse clearCache(ClearCacheRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, ClearCacheRequest._ENDPOINT, this.transportOptions); + } + + /** + * Clears all or specific caches for one or more indexes. + * + * @param fn a function that initializes a builder to create the {@link ClearCacheRequest} + */ + public final ClearCacheResponse clearCache(Function> fn) throws IOException, + OpenSearchException { + return clearCache(fn.apply(new ClearCacheRequest.Builder()).build()); + } + + /** + * Clears all or specific caches for one or more indexes. + */ + public final ClearCacheResponse clearCache() throws IOException, OpenSearchException { + return clearCache(new ClearCacheRequest.Builder().build()); + } + // ----- Endpoint: indices.create /** 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 4ed3d69935..35aad945db 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 @@ -61,52 +61,6 @@ public OpenSearchIndicesAsyncClient withTransportOptions(@Nullable TransportOpti return new OpenSearchIndicesAsyncClient(this.transport, transportOptions); } - // ----- Endpoint: indices.clear_cache - - /** - * Clears all or specific caches for one or more indices. - * - * - */ - - public CompletableFuture clearCache(ClearCacheRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ClearCacheRequest, - ClearCacheResponse, - ErrorResponse>) ClearCacheRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Clears all or specific caches for one or more indices. - * - * @param fn - * a function that initializes a builder to create the - * {@link ClearCacheRequest} - * - */ - - public final CompletableFuture clearCache(Function> fn) - throws IOException, OpenSearchException { - return clearCache(fn.apply(new ClearCacheRequest.Builder()).build()); - } - - /** - * Clears all or specific caches for one or more indices. - * - * - */ - - public CompletableFuture clearCache() throws IOException, OpenSearchException { - return this.transport.performRequestAsync( - new ClearCacheRequest.Builder().build(), - ClearCacheRequest._ENDPOINT, - this.transportOptions - ); - } - // ----- Endpoint: indices.clone /** 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 c84ff0775f..dc545b6ab4 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 @@ -60,45 +60,6 @@ public OpenSearchIndicesClient withTransportOptions(@Nullable TransportOptions t return new OpenSearchIndicesClient(this.transport, transportOptions); } - // ----- Endpoint: indices.clear_cache - - /** - * Clears all or specific caches for one or more indices. - * - */ - - public ClearCacheResponse clearCache(ClearCacheRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ClearCacheRequest, - ClearCacheResponse, - ErrorResponse>) ClearCacheRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Clears all or specific caches for one or more indices. - * - * @param fn - * a function that initializes a builder to create the - * {@link ClearCacheRequest} - */ - - public final ClearCacheResponse clearCache(Function> fn) throws IOException, - OpenSearchException { - return clearCache(fn.apply(new ClearCacheRequest.Builder()).build()); - } - - /** - * Clears all or specific caches for one or more indices. - * - */ - - public ClearCacheResponse clearCache() throws IOException, OpenSearchException { - return this.transport.performRequest(new ClearCacheRequest.Builder().build(), ClearCacheRequest._ENDPOINT, this.transportOptions); - } - // ----- Endpoint: indices.clone /** 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 928fafbf1d..229063da67 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 @@ -53,7 +53,7 @@ public class CodeGenerator { namespace(is("indices")), name( or( - isOneOf("add_block", "analyze", "create", "delete", "exists", "get"), + isOneOf("add_block", "analyze", "clear_cache", "create", "delete", "exists", "get"), contains("alias"), contains("data_stream"), and(endsWith("mapping"), isNot("get_field_mapping")), From a1c5c09a9972aa88e08d8d3e777567f491e109df Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Wed, 18 Dec 2024 15:27:25 +1300 Subject: [PATCH 5/7] Remove deserializing of path params in request objects Signed-off-by: Thomas Farr --- .../client/opensearch/indices/AnalyzeRequest.java | 1 - .../opensearch/indices/CreateIndexRequest.java | 1 - .../client/opensearch/indices/PutAliasRequest.java | 2 -- .../indices/PutIndexTemplateRequest.java | 1 - .../opensearch/indices/PutMappingRequest.java | 1 - .../opensearch/indices/PutTemplateRequest.java | 1 - .../indices/SimulateIndexTemplateRequest.java | 1 - .../opensearch/snapshot/CloneSnapshotRequest.java | 3 --- .../snapshot/CreateRepositoryRequest.java | 1 - .../opensearch/snapshot/CreateSnapshotRequest.java | 2 -- .../snapshot/RestoreSnapshotRequest.java | 2 -- .../core/PutIndexTemplateRequestTest.java | 3 +++ .../opensearch/core/PutTemplateRequestTest.java | 3 +++ .../client/codegen/model/RequestShape.java | 14 -------------- 14 files changed, 6 insertions(+), 30 deletions(-) diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java index e94f5708e8..9a11f21ba2 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/AnalyzeRequest.java @@ -629,7 +629,6 @@ protected static void setupAnalyzeRequestDeserializer(ObjectDeserializer op) { op.add(Builder::aliases, JsonpDeserializer.stringMapDeserializer(Alias._DESERIALIZER), "aliases"); - op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); op.add(Builder::mappings, TypeMapping._DESERIALIZER, "mappings"); op.add(Builder::settings, IndexSettings._DESERIALIZER, "settings"); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java index 243a20b7b0..96d2f66a72 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutAliasRequest.java @@ -608,11 +608,9 @@ public PutAliasRequest build() { protected static void setupPutAliasRequestDeserializer(ObjectDeserializer op) { op.add(Builder::alias, JsonpDeserializer.stringDeserializer(), "alias"); op.add(Builder::filter, Query._DESERIALIZER, "filter"); - op.add(Builder::index, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "index"); 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::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "routing"); op.add(Builder::searchRouting, JsonpDeserializer.stringDeserializer(), "search_routing"); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java index 5a96e67614..1d92dc0dd8 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java @@ -651,7 +651,6 @@ protected static void setupPutIndexTemplateRequestDeserializer(ObjectDeserialize op.add(Builder::dataStream, IndexTemplateDataStreamConfiguration._DESERIALIZER, "data_stream"); op.add(Builder::indexPatterns, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "index_patterns"); op.add(Builder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_meta"); - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::priority, JsonpDeserializer.integerDeserializer(), "priority"); op.add(Builder::template, IndexTemplateMapping._DESERIALIZER, "template"); op.add(Builder::version, JsonpDeserializer.longDeserializer(), "version"); diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutMappingRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutMappingRequest.java index f5d9b4ada3..6bb2a993d1 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutMappingRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutMappingRequest.java @@ -1013,7 +1013,6 @@ protected static void setupPutMappingRequestDeserializer(ObjectDeserializer op) { op.add(Builder::indices, JsonpDeserializer.stringDeserializer(), "indices"); - op.add(Builder::repository, JsonpDeserializer.stringDeserializer(), "repository"); - op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); - op.add(Builder::targetSnapshot, JsonpDeserializer.stringDeserializer(), "target_snapshot"); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryRequest.java index 28645f58d8..e6af47caff 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateRepositoryRequest.java @@ -441,7 +441,6 @@ public CreateRepositoryRequest build() { ); protected static void setupCreateRepositoryRequestDeserializer(ObjectDeserializer op) { - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::repository, Repository._DESERIALIZER, "repository"); op.add(Builder::settings, RepositorySettings._DESERIALIZER, "settings"); op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotRequest.java index 72de16e134..bfaa7410e8 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CreateSnapshotRequest.java @@ -632,8 +632,6 @@ protected static void setupCreateSnapshotRequestDeserializer(ObjectDeserializer< op.add(Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); op.add(Builder::metadata, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "metadata"); op.add(Builder::partial, JsonpDeserializer.booleanDeserializer(), "partial"); - op.add(Builder::repository, JsonpDeserializer.stringDeserializer(), "repository"); - op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RestoreSnapshotRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RestoreSnapshotRequest.java index c781559bee..901602f755 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RestoreSnapshotRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/RestoreSnapshotRequest.java @@ -926,8 +926,6 @@ protected static void setupRestoreSnapshotRequestDeserializer(ObjectDeserializer op.add(Builder::renameAliasReplacement, JsonpDeserializer.stringDeserializer(), "rename_alias_replacement"); op.add(Builder::renamePattern, JsonpDeserializer.stringDeserializer(), "rename_pattern"); op.add(Builder::renameReplacement, JsonpDeserializer.stringDeserializer(), "rename_replacement"); - op.add(Builder::repository, JsonpDeserializer.stringDeserializer(), "repository"); - op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); op.add(Builder::sourceRemoteStoreRepository, JsonpDeserializer.stringDeserializer(), "source_remote_store_repository"); op.add(Builder::storageType, JsonpDeserializer.stringDeserializer(), "storage_type"); } diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java index f5483b1170..fa58b8474d 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java @@ -16,6 +16,7 @@ import java.util.HashMap; import java.util.Map; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.jsonb.JsonbJsonpMapper; @@ -23,6 +24,8 @@ public class PutIndexTemplateRequestTest extends Assert { + // TODO: Allow constructing requests from JSON with required path params + @Ignore @Test public void deserialize_validFieldsIncluded_RequestIsBuilt() throws JsonProcessingException { final JsonpMapper mapper = new JsonbJsonpMapper(); diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java index ab34c97984..b9f1425db4 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java @@ -16,6 +16,7 @@ import java.util.HashMap; import java.util.Map; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.jsonb.JsonbJsonpMapper; @@ -23,6 +24,8 @@ public class PutTemplateRequestTest extends Assert { + // TODO: Allow constructing requests from JSON with required path params + @Ignore @Test public void deserialize_validFieldsIncluded_RequestIsBuilt() throws JsonProcessingException { final JsonpMapper mapper = new JsonbJsonpMapper(); 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 5373632cc1..336d53bd0c 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 @@ -16,7 +16,6 @@ import java.util.Objects; import java.util.Set; import java.util.TreeMap; -import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; @@ -104,19 +103,6 @@ public boolean canBeSingleton() { return !hasRequestBody() && !hasQueryParams() && hasSinglePath() && !getFirstPath().hasParams(); } - @Override - public Collection getFieldsToDeserialize() { - var fields = new TreeMap<>(bodyFields); - var wireNameSet = bodyFields.values().stream().map(Field::getWireName).collect(Collectors.toSet()); - pathParams.forEach((k, v) -> { - if (wireNameSet.contains(v.getWireName())) { - v = v.toBuilder().withWireName(v.getName()).build(); - } - fields.put(k, v); - }); - return fields.values(); - } - @Override public boolean hasFieldsToSerialize() { return hasRequestBody(); From 4e1bb79e8de2ddfc0130bac76f7fb609244b9834 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Wed, 18 Dec 2024 16:16:41 +1300 Subject: [PATCH 6/7] Test that deserialization fails Signed-off-by: Thomas Farr --- .../core/PutIndexTemplateRequestTest.java | 15 +++++---------- .../opensearch/core/PutTemplateRequestTest.java | 12 +++++------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java index fa58b8474d..b2fa0fa0b2 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java @@ -12,22 +12,20 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.json.stream.JsonParser; import java.io.StringReader; -import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.jsonb.JsonbJsonpMapper; import org.opensearch.client.opensearch.indices.PutIndexTemplateRequest; +import org.opensearch.client.util.MissingRequiredPropertyException; public class PutIndexTemplateRequestTest extends Assert { // TODO: Allow constructing requests from JSON with required path params - @Ignore @Test - public void deserialize_validFieldsIncluded_RequestIsBuilt() throws JsonProcessingException { + public void doesNotDeserializePathParamsFromJsonBlob() throws JsonProcessingException { final JsonpMapper mapper = new JsonbJsonpMapper(); final Map indexTemplateMap = new HashMap<>(); indexTemplateMap.put("name", "test"); @@ -38,11 +36,8 @@ public void deserialize_validFieldsIncluded_RequestIsBuilt() throws JsonProcessi final String indexTemplate = new ObjectMapper().writeValueAsString(indexTemplateMap); final JsonParser parser = mapper.jsonProvider().createParser(new StringReader(indexTemplate)); - final PutIndexTemplateRequest putIndexTemplateRequest = PutIndexTemplateRequest._DESERIALIZER.deserialize(parser, mapper); - - assertEquals(putIndexTemplateRequest.name(), "test"); - assertEquals(putIndexTemplateRequest.indexPatterns(), Collections.singletonList("*")); - assertEquals((int) putIndexTemplateRequest.priority(), 1); + assertThrows("Missing required property 'PutTemplateRequest.name'", MissingRequiredPropertyException.class, () -> { + PutIndexTemplateRequest._DESERIALIZER.deserialize(parser, mapper); + }); } - } diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java index b9f1425db4..9a544b6aa9 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java @@ -21,13 +21,13 @@ import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.jsonb.JsonbJsonpMapper; import org.opensearch.client.opensearch.indices.PutTemplateRequest; +import org.opensearch.client.util.MissingRequiredPropertyException; public class PutTemplateRequestTest extends Assert { // TODO: Allow constructing requests from JSON with required path params - @Ignore @Test - public void deserialize_validFieldsIncluded_RequestIsBuilt() throws JsonProcessingException { + public void doesNotDeserializePathParamsFromJsonBlob() throws JsonProcessingException { final JsonpMapper mapper = new JsonbJsonpMapper(); final Map indexTemplateMap = new HashMap<>(); indexTemplateMap.put("name", "test"); @@ -37,10 +37,8 @@ public void deserialize_validFieldsIncluded_RequestIsBuilt() throws JsonProcessi final String indexTemplate = new ObjectMapper().writeValueAsString(indexTemplateMap); final JsonParser parser = mapper.jsonProvider().createParser(new StringReader(indexTemplate)); - final PutTemplateRequest putTemplateRequest = PutTemplateRequest._DESERIALIZER.deserialize(parser, mapper); - - assertEquals("test", putTemplateRequest.name()); - assertEquals(Collections.singletonList("*"), putTemplateRequest.indexPatterns()); - assertEquals((Integer) 1, putTemplateRequest.order()); + assertThrows("Missing required property 'PutTemplateRequest.name'", MissingRequiredPropertyException.class, () -> { + PutTemplateRequest._DESERIALIZER.deserialize(parser, mapper); + }); } } From c53f5a485bef122656262e980ebf3b37553d8380 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Wed, 18 Dec 2024 16:21:07 +1300 Subject: [PATCH 7/7] spotless Signed-off-by: Thomas Farr --- .../client/opensearch/core/PutIndexTemplateRequestTest.java | 4 +--- .../client/opensearch/core/PutTemplateRequestTest.java | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java index b2fa0fa0b2..1ebd6aa18c 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java @@ -36,8 +36,6 @@ public void doesNotDeserializePathParamsFromJsonBlob() throws JsonProcessingExce final String indexTemplate = new ObjectMapper().writeValueAsString(indexTemplateMap); final JsonParser parser = mapper.jsonProvider().createParser(new StringReader(indexTemplate)); - assertThrows("Missing required property 'PutTemplateRequest.name'", MissingRequiredPropertyException.class, () -> { - PutIndexTemplateRequest._DESERIALIZER.deserialize(parser, mapper); - }); + assertThrows(MissingRequiredPropertyException.class, () -> { PutIndexTemplateRequest._DESERIALIZER.deserialize(parser, mapper); }); } } diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java index 9a544b6aa9..436cf6fae3 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/core/PutTemplateRequestTest.java @@ -12,11 +12,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.json.stream.JsonParser; import java.io.StringReader; -import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.jsonb.JsonbJsonpMapper; @@ -37,8 +35,6 @@ public void doesNotDeserializePathParamsFromJsonBlob() throws JsonProcessingExce final String indexTemplate = new ObjectMapper().writeValueAsString(indexTemplateMap); final JsonParser parser = mapper.jsonProvider().createParser(new StringReader(indexTemplate)); - assertThrows("Missing required property 'PutTemplateRequest.name'", MissingRequiredPropertyException.class, () -> { - PutTemplateRequest._DESERIALIZER.deserialize(parser, mapper); - }); + assertThrows(MissingRequiredPropertyException.class, () -> { PutTemplateRequest._DESERIALIZER.deserialize(parser, mapper); }); } }