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 b102a14748..e59cabf2d3 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 @@ -1109,4 +1109,31 @@ public final CompletableFuture upgrade(Function upgrade() throws IOException, OpenSearchException { return upgrade(new UpgradeRequest.Builder().build()); } + + // ----- Endpoint: indices.validate_query + + /** + * Allows a user to validate a potentially expensive query without executing it. + */ + public CompletableFuture validateQuery(ValidateQueryRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, ValidateQueryRequest._ENDPOINT, this.transportOptions); + } + + /** + * Allows a user to validate a potentially expensive query without executing it. + * + * @param fn a function that initializes a builder to create the {@link ValidateQueryRequest} + */ + public final CompletableFuture validateQuery( + Function> fn + ) throws IOException, OpenSearchException { + return validateQuery(fn.apply(new ValidateQueryRequest.Builder()).build()); + } + + /** + * Allows a user to validate a potentially expensive query without executing it. + */ + public final CompletableFuture validateQuery() throws IOException, OpenSearchException { + return validateQuery(new ValidateQueryRequest.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 319d3d1521..6bce3867f1 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 @@ -1088,4 +1088,30 @@ public final UpgradeResponse upgrade(Function> fn) + throws IOException, OpenSearchException { + return validateQuery(fn.apply(new ValidateQueryRequest.Builder()).build()); + } + + /** + * Allows a user to validate a potentially expensive query without executing it. + */ + public final ValidateQueryResponse validateQuery() throws IOException, OpenSearchException { + return validateQuery(new ValidateQueryRequest.Builder().build()); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ValidateQueryRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ValidateQueryRequest.java similarity index 59% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/ValidateQueryRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/ValidateQueryRequest.java index 2446f53dd2..d6c93d2e29 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ValidateQueryRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ValidateQueryRequest.java @@ -30,14 +30,21 @@ * 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; @@ -53,17 +60,23 @@ 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.validate_query.Request /** * Allows a user to validate a potentially expensive query without executing it. - * */ @JsonpDeserializable -public class ValidateQueryRequest extends RequestBase implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class ValidateQueryRequest extends RequestBase + implements + PlainJsonSerializable, + ToCopyableBuilder { + @Nullable private final Boolean allShards; @@ -82,6 +95,7 @@ public class ValidateQueryRequest extends RequestBase implements PlainJsonSerial @Nullable private final String df; + @Nonnull private final List expandWildcards; @Nullable @@ -90,6 +104,7 @@ public class ValidateQueryRequest extends RequestBase implements PlainJsonSerial @Nullable private final Boolean ignoreUnavailable; + @Nonnull private final List index; @Nullable @@ -107,7 +122,6 @@ public class ValidateQueryRequest extends RequestBase implements PlainJsonSerial // --------------------------------------------------------------------------------------------- private ValidateQueryRequest(Builder builder) { - this.allShards = builder.allShards; this.allowNoIndices = builder.allowNoIndices; this.analyzeWildcard = builder.analyzeWildcard; @@ -122,17 +136,17 @@ private ValidateQueryRequest(Builder builder) { this.q = builder.q; this.query = builder.query; this.rewrite = builder.rewrite; - } - public static ValidateQueryRequest of(Function> fn) { + public static ValidateQueryRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Execute validation on all shards instead of one random shard per index + * If true, the validation is executed on all shards instead of one random shard per index. *

* API name: {@code all_shards} + *

*/ @Nullable public final Boolean allShards() { @@ -140,11 +154,11 @@ public final Boolean allShards() { } /** - * 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() { @@ -152,10 +166,10 @@ public final Boolean allowNoIndices() { } /** - * Specify whether wildcard and prefix queries should be analyzed (default: - * false) + * If true, wildcard and prefix queries are analyzed. *

* API name: {@code analyze_wildcard} + *

*/ @Nullable public final Boolean analyzeWildcard() { @@ -163,9 +177,10 @@ public final Boolean analyzeWildcard() { } /** - * The analyzer to use for the query string + * Analyzer to use for the query string. This parameter can only be used when the q query string parameter is specified. *

* API name: {@code analyzer} + *

*/ @Nullable public final String analyzer() { @@ -173,9 +188,10 @@ public final String analyzer() { } /** - * The default operator for query string query (AND or OR) + * The default operator for query string query: AND or OR. *

* API name: {@code default_operator} + *

*/ @Nullable public final Operator defaultOperator() { @@ -183,10 +199,11 @@ public final Operator defaultOperator() { } /** - * The field to use as default where no field prefix is given in the query - * string + * Field to use as default where no field prefix is given in the query string. This parameter can only be used when the q + * query string parameter is specified. *

* API name: {@code df} + *

*/ @Nullable public final String df() { @@ -194,19 +211,23 @@ public final String df() { } /** - * 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; } /** - * Return detailed information about the error + * If true, the response returns detailed information if an error has occurred. *

* API name: {@code explain} + *

*/ @Nullable public final Boolean explain() { @@ -214,10 +235,10 @@ public final Boolean explain() { } /** - * 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() { @@ -225,20 +246,22 @@ public final Boolean ignoreUnavailable() { } /** - * A comma-separated list of index names to restrict the operation; use - * _all or empty string to perform the operation on all indices + * Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (*). To search all data streams + * or indexes, omit this parameter or use * or _all. *

* API name: {@code index} + *

*/ + @Nonnull public final List index() { return this.index; } /** - * Specify whether format-based query failures (such as providing text to a - * numeric field) should be ignored + * If true, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. *

* API name: {@code lenient} + *

*/ @Nullable public final Boolean lenient() { @@ -246,9 +269,10 @@ public final Boolean lenient() { } /** - * Query in the Lucene query string syntax + * Query in the Lucene query string syntax. *

* API name: {@code q} + *

*/ @Nullable public final String q() { @@ -264,10 +288,10 @@ public final Query query() { } /** - * Provide a more detailed explanation showing the actual Lucene query that will - * be executed. + * If true, returns a more detailed explanation showing the actual Lucene query that will be executed. *

* API name: {@code rewrite} + *

*/ @Nullable public final Boolean rewrite() { @@ -277,6 +301,7 @@ public final Boolean rewrite() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -284,217 +309,288 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); - } + } + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link ValidateQueryRequest}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private Boolean allShards; - @Nullable private Boolean allowNoIndices; - @Nullable private Boolean analyzeWildcard; - @Nullable private String analyzer; - @Nullable private Operator defaultOperator; - @Nullable private String df; - @Nullable private List expandWildcards; - @Nullable private Boolean explain; - @Nullable private Boolean ignoreUnavailable; - @Nullable private List index; - @Nullable private Boolean lenient; - @Nullable private String q; - @Nullable private Query query; - @Nullable private Boolean rewrite; + public Builder() {} + + private Builder(ValidateQueryRequest o) { + this.allShards = o.allShards; + this.allowNoIndices = o.allowNoIndices; + this.analyzeWildcard = o.analyzeWildcard; + this.analyzer = o.analyzer; + this.defaultOperator = o.defaultOperator; + this.df = o.df; + this.expandWildcards = _listCopy(o.expandWildcards); + this.explain = o.explain; + this.ignoreUnavailable = o.ignoreUnavailable; + this.index = _listCopy(o.index); + this.lenient = o.lenient; + this.q = o.q; + this.query = o.query; + this.rewrite = o.rewrite; + } + + private Builder(Builder o) { + this.allShards = o.allShards; + this.allowNoIndices = o.allowNoIndices; + this.analyzeWildcard = o.analyzeWildcard; + this.analyzer = o.analyzer; + this.defaultOperator = o.defaultOperator; + this.df = o.df; + this.expandWildcards = _listCopy(o.expandWildcards); + this.explain = o.explain; + this.ignoreUnavailable = o.ignoreUnavailable; + this.index = _listCopy(o.index); + this.lenient = o.lenient; + this.q = o.q; + this.query = o.query; + this.rewrite = o.rewrite; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** - * Execute validation on all shards instead of one random shard per index + * If true, the validation is executed on all shards instead of one random shard per index. *

* API name: {@code all_shards} + *

*/ + @Nonnull public final Builder allShards(@Nullable Boolean value) { this.allShards = value; return 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; } /** - * Specify whether wildcard and prefix queries should be analyzed (default: - * false) + * If true, wildcard and prefix queries are analyzed. *

* API name: {@code analyze_wildcard} + *

*/ + @Nonnull public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** - * The analyzer to use for the query string + * Analyzer to use for the query string. This parameter can only be used when the q query string parameter is + * specified. *

* API name: {@code analyzer} + *

*/ + @Nonnull public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** - * The default operator for query string query (AND or OR) + * The default operator for query string query: AND or OR. *

* API name: {@code default_operator} + *

*/ + @Nonnull public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** - * The field to use as default where no field prefix is given in the query - * string + * Field to use as default where no field prefix is given in the query string. This parameter can only be used when the + * q query string parameter is specified. *

* API name: {@code df} + *

*/ + @Nonnull public final Builder df(@Nullable String value) { this.df = 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; } /** - * Return detailed information about the error + * If true, the response returns detailed information if an error has occurred. *

* API name: {@code explain} + *

*/ + @Nonnull public final Builder explain(@Nullable Boolean value) { this.explain = value; 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 restrict the operation; use - * _all or empty string to perform the operation on all indices + * Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (*). To search all data + * streams or 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 restrict the operation; use - * _all or empty string to perform the operation on all indices + * Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (*). To search all data + * streams or 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; } /** - * Specify whether format-based query failures (such as providing text to a - * numeric field) should be ignored + * If true, format-based query failures (such as providing text to a numeric field) in the query string will be + * ignored. *

* API name: {@code lenient} + *

*/ + @Nonnull public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** - * Query in the Lucene query string syntax + * Query in the Lucene query string syntax. *

* API name: {@code q} + *

*/ + @Nonnull public final Builder q(@Nullable String value) { this.q = value; return this; @@ -503,6 +599,7 @@ public final Builder q(@Nullable String value) { /** * API name: {@code query} */ + @Nonnull public final Builder query(@Nullable Query value) { this.query = value; return this; @@ -511,16 +608,18 @@ public final Builder query(@Nullable Query value) { /** * API name: {@code query} */ + @Nonnull public final Builder query(Function> fn) { - return this.query(fn.apply(new Query.Builder()).build()); + return query(fn.apply(new Query.Builder()).build()); } /** - * Provide a more detailed explanation showing the actual Lucene query that will - * be executed. + * If true, returns a more detailed explanation showing the actual Lucene query that will be executed. *

* API name: {@code rewrite} + *

*/ + @Nonnull public final Builder rewrite(@Nullable Boolean value) { this.rewrite = value; return this; @@ -529,9 +628,10 @@ public final Builder rewrite(@Nullable Boolean value) { /** * Builds a {@link ValidateQueryRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public ValidateQueryRequest build() { _checkSingleUse(); @@ -550,9 +650,7 @@ public ValidateQueryRequest build() { ); protected static void setupValidateQueryRequestDeserializer(ObjectDeserializer op) { - op.add(Builder::query, Query._DESERIALIZER, "query"); - } // --------------------------------------------------------------------------------------------- @@ -561,13 +659,8 @@ protected static void setupValidateQueryRequestDeserializer(ObjectDeserializer _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "POST"; - - }, - + request -> "POST", // Request path request -> { final int _index = 1 << 0; @@ -577,67 +670,102 @@ protected static void setupValidateQueryRequestDeserializer(ObjectDeserializer v).collect(Collectors.joining(",")), buf); - buf.append("/_validate"); - buf.append("/query"); + SimpleEndpoint.pathEncode(String.join(",", request.index), buf); + buf.append("/_validate/query"); return buf.toString(); } - throw SimpleEndpoint.noPathTemplateFound("path"); + throw SimpleEndpoint.noPathTemplateFound("path"); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.explain != null) { - params.put("explain", String.valueOf(request.explain)); + if (request.allShards != null) { + params.put("all_shards", String.valueOf(request.allShards)); } - if (request.q != null) { - params.put("q", request.q); + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } - if (request.df != null) { - params.put("df", request.df); + if (request.analyzeWildcard != null) { + params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); + } + if (request.analyzer != null) { + params.put("analyzer", request.analyzer); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } - if (request.allShards != null) { - params.put("all_shards", String.valueOf(request.allShards)); + if (request.df != null) { + params.put("df", request.df); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } + if (request.explain != null) { + params.put("explain", String.valueOf(request.explain)); + } 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.analyzer != null) { - params.put("analyzer", request.analyzer); - } - if (request.analyzeWildcard != null) { - params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); - } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } + if (request.q != null) { + params.put("q", request.q); + } if (request.rewrite != null) { params.put("rewrite", String.valueOf(request.rewrite)); } return params; - }, SimpleEndpoint.emptyMap(), true, ValidateQueryResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allShards); + result = 31 * result + Objects.hashCode(this.allowNoIndices); + result = 31 * result + Objects.hashCode(this.analyzeWildcard); + result = 31 * result + Objects.hashCode(this.analyzer); + result = 31 * result + Objects.hashCode(this.defaultOperator); + result = 31 * result + Objects.hashCode(this.df); + result = 31 * result + Objects.hashCode(this.expandWildcards); + result = 31 * result + Objects.hashCode(this.explain); + result = 31 * result + Objects.hashCode(this.ignoreUnavailable); + result = 31 * result + Objects.hashCode(this.index); + result = 31 * result + Objects.hashCode(this.lenient); + result = 31 * result + Objects.hashCode(this.q); + result = 31 * result + Objects.hashCode(this.query); + result = 31 * result + Objects.hashCode(this.rewrite); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + ValidateQueryRequest other = (ValidateQueryRequest) o; + return Objects.equals(this.allShards, other.allShards) + && Objects.equals(this.allowNoIndices, other.allowNoIndices) + && Objects.equals(this.analyzeWildcard, other.analyzeWildcard) + && Objects.equals(this.analyzer, other.analyzer) + && Objects.equals(this.defaultOperator, other.defaultOperator) + && Objects.equals(this.df, other.df) + && Objects.equals(this.expandWildcards, other.expandWildcards) + && Objects.equals(this.explain, other.explain) + && Objects.equals(this.ignoreUnavailable, other.ignoreUnavailable) + && Objects.equals(this.index, other.index) + && Objects.equals(this.lenient, other.lenient) + && Objects.equals(this.q, other.q) + && Objects.equals(this.query, other.query) + && Objects.equals(this.rewrite, other.rewrite); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ValidateQueryResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ValidateQueryResponse.java similarity index 73% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/ValidateQueryResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/ValidateQueryResponse.java index af16f7c178..090cabaa3a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ValidateQueryResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ValidateQueryResponse.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,13 +52,24 @@ import org.opensearch.client.opensearch._types.ShardStatistics; import org.opensearch.client.opensearch.indices.validate_query.IndicesValidationExplanation; 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.validate_query.Response @JsonpDeserializable -public class ValidateQueryResponse implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class ValidateQueryResponse + implements + PlainJsonSerializable, + ToCopyableBuilder { + + @Nullable + private final String error; + + @Nonnull private final List explanations; @Nullable @@ -59,27 +77,31 @@ public class ValidateQueryResponse implements PlainJsonSerializable { private final boolean valid; - @Nullable - private final String error; - // --------------------------------------------------------------------------------------------- private ValidateQueryResponse(Builder builder) { - + this.error = builder.error; this.explanations = ApiTypeHelper.unmodifiable(builder.explanations); this.shards = builder.shards; this.valid = ApiTypeHelper.requireNonNull(builder.valid, this, "valid"); - this.error = builder.error; - } - public static ValidateQueryResponse of(Function> fn) { + public static ValidateQueryResponse of(Function> fn) { return fn.apply(new Builder()).build(); } + /** + * API name: {@code error} + */ + @Nullable + public final String error() { + return this.error; + } + /** * API name: {@code explanations} */ + @Nonnull public final List explanations() { return this.explanations; } @@ -99,17 +121,10 @@ public final boolean valid() { return this.valid; } - /** - * API name: {@code error} - */ - @Nullable - public final String error() { - return this.error; - } - /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -117,56 +132,93 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.error != null) { + generator.writeKey("error"); + generator.write(this.error); + } if (ApiTypeHelper.isDefined(this.explanations)) { generator.writeKey("explanations"); generator.writeStartArray(); for (IndicesValidationExplanation item0 : this.explanations) { item0.serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.shards != null) { generator.writeKey("_shards"); this.shards.serialize(generator, mapper); - } + generator.writeKey("valid"); generator.write(this.valid); + } - if (this.error != null) { - generator.writeKey("error"); - generator.write(this.error); - - } + // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); } - // --------------------------------------------------------------------------------------------- + @Nonnull + public static Builder builder() { + return new Builder(); + } /** * Builder for {@link ValidateQueryResponse}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { + @Nullable + private String error; @Nullable private List explanations; - @Nullable private ShardStatistics shards; - private Boolean valid; - @Nullable - private String error; + public Builder() {} + + private Builder(ValidateQueryResponse o) { + this.error = o.error; + this.explanations = _listCopy(o.explanations); + this.shards = o.shards; + this.valid = o.valid; + } + + private Builder(Builder o) { + this.error = o.error; + this.explanations = _listCopy(o.explanations); + this.shards = o.shards; + this.valid = o.valid; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + + /** + * API name: {@code error} + */ + @Nonnull + public final Builder error(@Nullable String value) { + this.error = value; + return this; + } /** * API name: {@code explanations} + * *

* Adds all elements of list to explanations. + *

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

* Adds one or more values to explanations. + *

*/ + @Nonnull public final Builder explanations(IndicesValidationExplanation value, IndicesValidationExplanation... values) { this.explanations = _listAdd(this.explanations, value, values); return this; @@ -184,9 +239,12 @@ public final Builder explanations(IndicesValidationExplanation value, IndicesVal /** * API name: {@code explanations} + * *

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

*/ + @Nonnull public final Builder explanations(Function> fn) { return explanations(fn.apply(new IndicesValidationExplanation.Builder()).build()); } @@ -194,6 +252,7 @@ public final Builder explanations(Function> fn) { - return this.shards(fn.apply(new ShardStatistics.Builder()).build()); + return shards(fn.apply(new ShardStatistics.Builder()).build()); } /** * Required - API name: {@code valid} */ + @Nonnull public final Builder valid(boolean value) { this.valid = value; return this; } - /** - * API name: {@code error} - */ - public final Builder error(@Nullable String value) { - this.error = value; - return this; - } - /** * Builds a {@link ValidateQueryResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public ValidateQueryResponse build() { _checkSingleUse(); @@ -246,12 +300,30 @@ public ValidateQueryResponse build() { ); protected static void setupValidateQueryResponseDeserializer(ObjectDeserializer op) { - + op.add(Builder::error, JsonpDeserializer.stringDeserializer(), "error"); op.add(Builder::explanations, JsonpDeserializer.arrayDeserializer(IndicesValidationExplanation._DESERIALIZER), "explanations"); op.add(Builder::shards, ShardStatistics._DESERIALIZER, "_shards"); op.add(Builder::valid, JsonpDeserializer.booleanDeserializer(), "valid"); - op.add(Builder::error, JsonpDeserializer.stringDeserializer(), "error"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.error); + result = 31 * result + Objects.hashCode(this.explanations); + result = 31 * result + Objects.hashCode(this.shards); + result = 31 * result + Boolean.hashCode(this.valid); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + ValidateQueryResponse other = (ValidateQueryResponse) o; + return Objects.equals(this.error, other.error) + && Objects.equals(this.explanations, other.explanations) + && Objects.equals(this.shards, other.shards) + && this.valid == other.valid; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/validate_query/IndicesValidationExplanation.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/validate_query/IndicesValidationExplanation.java similarity index 70% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/validate_query/IndicesValidationExplanation.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/validate_query/IndicesValidationExplanation.java index 36b901525b..adeb395a55 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/validate_query/IndicesValidationExplanation.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/validate_query/IndicesValidationExplanation.java @@ -30,10 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.validate_query; 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,27 @@ 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.validate_query.IndicesValidationExplanation @JsonpDeserializable -public class IndicesValidationExplanation implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class IndicesValidationExplanation + implements + PlainJsonSerializable, + ToCopyableBuilder { + @Nullable private final String error; @Nullable private final String explanation; + @Nonnull private final String index; private final boolean valid; @@ -62,15 +77,15 @@ public class IndicesValidationExplanation implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private IndicesValidationExplanation(Builder builder) { - this.error = builder.error; this.explanation = builder.explanation; this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.valid = ApiTypeHelper.requireNonNull(builder.valid, this, "valid"); - } - public static IndicesValidationExplanation of(Function> fn) { + public static IndicesValidationExplanation of( + Function> fn + ) { return fn.apply(new Builder()).build(); } @@ -93,6 +108,7 @@ public final String explanation() { /** * Required - API name: {@code index} */ + @Nonnull public final String index() { return this.index; } @@ -107,6 +123,7 @@ public final boolean valid() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -114,45 +131,73 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.error != null) { generator.writeKey("error"); generator.write(this.error); - } + if (this.explanation != null) { generator.writeKey("explanation"); generator.write(this.explanation); - } + generator.writeKey("index"); generator.write(this.index); generator.writeKey("valid"); generator.write(this.valid); - } // --------------------------------------------------------------------------------------------- + @Override + @Nonnull + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + /** * Builder for {@link IndicesValidationExplanation}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements CopyableBuilder { @Nullable private String error; - @Nullable private String explanation; - private String index; - private Boolean valid; + public Builder() {} + + private Builder(IndicesValidationExplanation o) { + this.error = o.error; + this.explanation = o.explanation; + this.index = o.index; + this.valid = o.valid; + } + + private Builder(Builder o) { + this.error = o.error; + this.explanation = o.explanation; + this.index = o.index; + this.valid = o.valid; + } + + @Override + @Nonnull + public Builder copy() { + return new Builder(this); + } + /** * API name: {@code error} */ + @Nonnull public final Builder error(@Nullable String value) { this.error = value; return this; @@ -161,6 +206,7 @@ public final Builder error(@Nullable String value) { /** * API name: {@code explanation} */ + @Nonnull public final Builder explanation(@Nullable String value) { this.explanation = value; return this; @@ -169,6 +215,7 @@ public final Builder explanation(@Nullable String value) { /** * Required - API name: {@code index} */ + @Nonnull public final Builder index(String value) { this.index = value; return this; @@ -177,6 +224,7 @@ public final Builder index(String value) { /** * Required - API name: {@code valid} */ + @Nonnull public final Builder valid(boolean value) { this.valid = value; return this; @@ -185,9 +233,10 @@ public final Builder valid(boolean value) { /** * Builds a {@link IndicesValidationExplanation}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ + @Override + @Nonnull public IndicesValidationExplanation build() { _checkSingleUse(); @@ -206,12 +255,30 @@ public IndicesValidationExplanation build() { ); protected static void setupIndicesValidationExplanationDeserializer(ObjectDeserializer op) { - op.add(Builder::error, JsonpDeserializer.stringDeserializer(), "error"); op.add(Builder::explanation, JsonpDeserializer.stringDeserializer(), "explanation"); op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); op.add(Builder::valid, JsonpDeserializer.booleanDeserializer(), "valid"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.error); + result = 31 * result + Objects.hashCode(this.explanation); + result = 31 * result + this.index.hashCode(); + result = 31 * result + Boolean.hashCode(this.valid); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndicesValidationExplanation other = (IndicesValidationExplanation) o; + return Objects.equals(this.error, other.error) + && Objects.equals(this.explanation, other.explanation) + && this.index.equals(other.index) + && this.valid == other.valid; + } } 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 f64ac3ff9b..b89d5e36d6 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 @@ -126,52 +126,4 @@ public final CompletableFuture getFieldMapping( ) throws IOException, OpenSearchException { return getFieldMapping(fn.apply(new GetFieldMappingRequest.Builder()).build()); } - - // ----- Endpoint: indices.validate_query - - /** - * Allows a user to validate a potentially expensive query without executing it. - * - * - */ - - public CompletableFuture validateQuery(ValidateQueryRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ValidateQueryRequest, - ValidateQueryResponse, - ErrorResponse>) ValidateQueryRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows a user to validate a potentially expensive query without executing it. - * - * @param fn - * a function that initializes a builder to create the - * {@link ValidateQueryRequest} - * - */ - - public final CompletableFuture validateQuery( - Function> fn - ) throws IOException, OpenSearchException { - return validateQuery(fn.apply(new ValidateQueryRequest.Builder()).build()); - } - - /** - * Allows a user to validate a potentially expensive query without executing it. - * - * - */ - - public CompletableFuture validateQuery() throws IOException, OpenSearchException { - return this.transport.performRequestAsync( - new ValidateQueryRequest.Builder().build(), - ValidateQueryRequest._ENDPOINT, - this.transportOptions - ); - } - } 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 0195513b85..f79c977e26 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 @@ -123,51 +123,4 @@ public final GetFieldMappingResponse getFieldMapping(Function endpoint = (JsonEndpoint< - ValidateQueryRequest, - ValidateQueryResponse, - ErrorResponse>) ValidateQueryRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows a user to validate a potentially expensive query without executing it. - * - * @param fn - * a function that initializes a builder to create the - * {@link ValidateQueryRequest} - * - */ - - public final ValidateQueryResponse validateQuery(Function> fn) - throws IOException, OpenSearchException { - return validateQuery(fn.apply(new ValidateQueryRequest.Builder()).build()); - } - - /** - * Allows a user to validate a potentially expensive query without executing it. - * - * - */ - - public ValidateQueryResponse validateQuery() throws IOException, OpenSearchException { - return this.transport.performRequest( - new ValidateQueryRequest.Builder().build(), - ValidateQueryRequest._ENDPOINT, - this.transportOptions - ); - } - } 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 c38787792e..6f98e6b3f4 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 @@ -76,7 +76,8 @@ public class CodeGenerator { "shrink", "split", "stats", - "upgrade" + "upgrade", + "validate_query" ), contains("alias"), contains("data_stream"),