diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/GetAliasesResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/GetAliasesResponse.java deleted file mode 100644 index c5a1d97b7edf4..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/GetAliasesResponse.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.client; - -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.cluster.metadata.AliasMetadata; -import org.elasticsearch.common.xcontent.StatusToXContentObject; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.xcontent.ToXContent; -import org.elasticsearch.xcontent.XContentBuilder; -import org.elasticsearch.xcontent.XContentParser; -import org.elasticsearch.xcontent.XContentParser.Token; - -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; - -/** - * Response obtained from the get aliases API. - * The format is pretty horrible as it holds aliases, but at the same time errors can come back through the status and error fields. - * Such errors are mostly 404 - NOT FOUND for aliases that were specified but not found. In such case the client won't throw exception - * so it allows to retrieve the returned aliases, while at the same time checking if errors were returned. - * There's also the case where an exception is returned, like for instance an {@link org.elasticsearch.index.IndexNotFoundException}. - * We would usually throw such exception, but we configure the client to not throw for 404 to support the case above, hence we also not - * throw in case an index is not found, although it is a hard error that doesn't come back with aliases. - */ -public class GetAliasesResponse implements StatusToXContentObject { - - private final RestStatus status; - private final String error; - private final ElasticsearchException exception; - - private final Map> aliases; - - GetAliasesResponse(RestStatus status, String error, Map> aliases) { - this.status = status; - this.error = error; - this.aliases = aliases; - this.exception = null; - } - - private GetAliasesResponse(RestStatus status, ElasticsearchException exception) { - this.status = status; - this.error = null; - this.aliases = Collections.emptyMap(); - this.exception = exception; - } - - @Override - public RestStatus status() { - return status; - } - - /** - * Return the possibly returned error, null otherwise - */ - public String getError() { - return error; - } - - /** - * Return the exception that may have been returned - */ - public ElasticsearchException getException() { - return exception; - } - - /** - * Return the requested aliases - */ - public Map> getAliases() { - return aliases; - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(); - { - if (status != RestStatus.OK) { - builder.field("error", error); - builder.field("status", status.getStatus()); - } - - for (Map.Entry> entry : aliases.entrySet()) { - builder.startObject(entry.getKey()); - { - builder.startObject("aliases"); - { - for (final AliasMetadata alias : entry.getValue()) { - AliasMetadata.Builder.toXContent(alias, builder, ToXContent.EMPTY_PARAMS); - } - } - builder.endObject(); - } - builder.endObject(); - } - } - builder.endObject(); - return builder; - } - - /** - * Parse the get aliases response - */ - public static GetAliasesResponse fromXContent(XContentParser parser) throws IOException { - if (parser.currentToken() == null) { - parser.nextToken(); - } - ensureExpectedToken(Token.START_OBJECT, parser.currentToken(), parser); - Map> aliases = new HashMap<>(); - - String currentFieldName; - Token token; - String error = null; - ElasticsearchException exception = null; - RestStatus status = RestStatus.OK; - - while (parser.nextToken() != Token.END_OBJECT) { - if (parser.currentToken() == Token.FIELD_NAME) { - currentFieldName = parser.currentName(); - - if ("status".equals(currentFieldName)) { - if ((token = parser.nextToken()) != Token.FIELD_NAME) { - ensureExpectedToken(Token.VALUE_NUMBER, token, parser); - status = RestStatus.fromCode(parser.intValue()); - } - } else if ("error".equals(currentFieldName)) { - token = parser.nextToken(); - if (token == Token.VALUE_STRING) { - error = parser.text(); - } else if (token == Token.START_OBJECT) { - parser.nextToken(); - exception = ElasticsearchException.innerFromXContent(parser, true); - } else if (token == Token.START_ARRAY) { - parser.skipChildren(); - } - } else { - String indexName = parser.currentName(); - if (parser.nextToken() == Token.START_OBJECT) { - Set parseInside = parseAliases(parser); - aliases.put(indexName, parseInside); - } - } - } - } - if (exception != null) { - assert error == null; - assert aliases.isEmpty(); - return new GetAliasesResponse(status, exception); - } - return new GetAliasesResponse(status, error, aliases); - } - - private static Set parseAliases(XContentParser parser) throws IOException { - Set aliases = new HashSet<>(); - Token token; - String currentFieldName = null; - while ((token = parser.nextToken()) != Token.END_OBJECT) { - if (token == Token.FIELD_NAME) { - currentFieldName = parser.currentName(); - } else if (token == Token.START_OBJECT) { - if ("aliases".equals(currentFieldName)) { - while (parser.nextToken() != Token.END_OBJECT) { - AliasMetadata fromXContent = AliasMetadata.Builder.fromXContent(parser); - aliases.add(fromXContent); - } - } else { - parser.skipChildren(); - } - } else if (token == Token.START_ARRAY) { - parser.skipChildren(); - } - } - return aliases; - } -} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/NodesResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/NodesResponse.java deleted file mode 100644 index a0c38498591f8..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/NodesResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.client; - -import org.elasticsearch.xcontent.ConstructingObjectParser; -import org.elasticsearch.xcontent.ParseField; - -/** - * Base class for responses that are node responses. These responses always contain the cluster - * name and the {@link NodesResponseHeader}. - */ -public abstract class NodesResponse { - - private final NodesResponseHeader header; - private final String clusterName; - - protected NodesResponse(NodesResponseHeader header, String clusterName) { - this.header = header; - this.clusterName = clusterName; - } - - /** - * Get the cluster name associated with all of the nodes. - * - * @return Never {@code null}. - */ - public String getClusterName() { - return clusterName; - } - - /** - * Gets information about the number of total, successful and failed nodes the request was run on. - * Also includes exceptions if relevant. - */ - public NodesResponseHeader getHeader() { - return header; - } - - public static void declareCommonNodesResponseParsing(ConstructingObjectParser parser) { - parser.declareObject(ConstructingObjectParser.constructorArg(), NodesResponseHeader::fromXContent, new ParseField("_nodes")); - parser.declareString(ConstructingObjectParser.constructorArg(), new ParseField("cluster_name")); - } -} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/NodesResponseHeader.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/NodesResponseHeader.java deleted file mode 100644 index e22326dc88fb3..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/NodesResponseHeader.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ -package org.elasticsearch.client; - -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.support.nodes.BaseNodesResponse; -import org.elasticsearch.core.Nullable; -import org.elasticsearch.rest.action.RestActions; -import org.elasticsearch.xcontent.ConstructingObjectParser; -import org.elasticsearch.xcontent.ParseField; -import org.elasticsearch.xcontent.ToXContent; -import org.elasticsearch.xcontent.XContentBuilder; -import org.elasticsearch.xcontent.XContentParser; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -/** - * A utility class to parse the Nodes Header returned by - * {@link RestActions#buildNodesHeader(XContentBuilder, ToXContent.Params, BaseNodesResponse)}. - */ -public final class NodesResponseHeader { - - public static final ParseField TOTAL = new ParseField("total"); - public static final ParseField SUCCESSFUL = new ParseField("successful"); - public static final ParseField FAILED = new ParseField("failed"); - public static final ParseField FAILURES = new ParseField("failures"); - - @SuppressWarnings("unchecked") - public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( - "nodes_response_header", - true, - (a) -> { - int i = 0; - int total = (Integer) a[i++]; - int successful = (Integer) a[i++]; - int failed = (Integer) a[i++]; - List failures = (List) a[i++]; - return new NodesResponseHeader(total, successful, failed, failures); - } - ); - - static { - PARSER.declareInt(ConstructingObjectParser.constructorArg(), TOTAL); - PARSER.declareInt(ConstructingObjectParser.constructorArg(), SUCCESSFUL); - PARSER.declareInt(ConstructingObjectParser.constructorArg(), FAILED); - PARSER.declareObjectArray( - ConstructingObjectParser.optionalConstructorArg(), - (p, c) -> ElasticsearchException.fromXContent(p), - FAILURES - ); - } - - private final int total; - private final int successful; - private final int failed; - private final List failures; - - public NodesResponseHeader(int total, int successful, int failed, @Nullable List failures) { - this.total = total; - this.successful = successful; - this.failed = failed; - this.failures = failures == null ? Collections.emptyList() : failures; - } - - public static NodesResponseHeader fromXContent(XContentParser parser, Void context) throws IOException { - return PARSER.parse(parser, context); - } - - /** the total number of nodes that the operation was carried on */ - public int getTotal() { - return total; - } - - /** the number of nodes that the operation has failed on */ - public int getFailed() { - return failed; - } - - /** the number of nodes that the operation was successful on */ - public int getSuccessful() { - return successful; - } - - /** - * Get the failed node exceptions. - * - * @return Never {@code null}. Can be empty. - */ - public List getFailures() { - return failures; - } - - /** - * Determine if there are any node failures in {@link #failures}. - * - * @return {@code true} if {@link #failures} contains at least 1 exception. - */ - public boolean hasFailures() { - return failures.isEmpty() == false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - NodesResponseHeader that = (NodesResponseHeader) o; - return total == that.total && successful == that.successful && failed == that.failed && Objects.equals(failures, that.failures); - } - - @Override - public int hashCode() { - return Objects.hash(total, successful, failed, failures); - } - -} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java index 1cba9261ec09d..6d2b06e1d1c3c 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java @@ -18,10 +18,6 @@ import org.apache.http.nio.entity.NByteArrayEntity; import org.apache.lucene.util.BytesRef; import org.elasticsearch.action.DocWriteRequest; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; -import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest; -import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest; -import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.explain.ExplainRequest; @@ -29,10 +25,7 @@ import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.search.ClearScrollRequest; -import org.elasticsearch.action.search.ClosePointInTimeRequest; import org.elasticsearch.action.search.MultiSearchRequest; -import org.elasticsearch.action.search.OpenPointInTimeRequest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchScrollRequest; import org.elasticsearch.action.support.ActiveShardCount; @@ -41,11 +34,8 @@ import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.client.core.CountRequest; import org.elasticsearch.client.core.GetSourceRequest; -import org.elasticsearch.client.core.MultiTermVectorsRequest; import org.elasticsearch.client.core.TermVectorsRequest; import org.elasticsearch.client.internal.Requests; -import org.elasticsearch.cluster.health.ClusterHealthStatus; -import org.elasticsearch.common.Priority; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.lucene.uid.Versions; @@ -55,15 +45,10 @@ import org.elasticsearch.core.SuppressForbidden; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.VersionType; -import org.elasticsearch.index.rankeval.RankEvalRequest; import org.elasticsearch.index.reindex.AbstractBulkByScrollRequest; -import org.elasticsearch.index.reindex.DeleteByQueryRequest; import org.elasticsearch.index.reindex.ReindexRequest; -import org.elasticsearch.index.reindex.UpdateByQueryRequest; import org.elasticsearch.index.seqno.SequenceNumbers; import org.elasticsearch.rest.action.search.RestSearchAction; -import org.elasticsearch.script.mustache.MultiSearchTemplateRequest; -import org.elasticsearch.script.mustache.SearchTemplateRequest; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import org.elasticsearch.xcontent.DeprecationHandler; import org.elasticsearch.xcontent.NamedXContentRegistry; @@ -78,9 +63,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.Charset; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Locale; import java.util.Map; import java.util.StringJoiner; @@ -335,10 +318,6 @@ static Request index(IndexRequest indexRequest) { return request; } - static Request ping() { - return new Request(HttpHead.METHOD_NAME, "/"); - } - static Request update(UpdateRequest updateRequest) throws IOException { String endpoint = endpoint(updateRequest.index(), "_update", updateRequest.id()); Request request = new Request(HttpPost.METHOD_NAME, endpoint); @@ -439,31 +418,6 @@ static Request searchScroll(SearchScrollRequest searchScrollRequest) throws IOEx return request; } - static Request clearScroll(ClearScrollRequest clearScrollRequest) throws IOException { - Request request = new Request(HttpDelete.METHOD_NAME, "/_search/scroll"); - request.setEntity(createEntity(clearScrollRequest, REQUEST_BODY_CONTENT_TYPE)); - return request; - } - - static Request openPointInTime(OpenPointInTimeRequest openRequest) { - Request request = new Request(HttpPost.METHOD_NAME, endpoint(openRequest.indices(), "_pit")); - Params params = new Params(); - if (OpenPointInTimeRequest.DEFAULT_INDICES_OPTIONS.equals(openRequest.indicesOptions()) == false) { - params.withIndicesOptions(openRequest.indicesOptions()); - } - params.withRouting(openRequest.routing()); - params.withPreference(openRequest.preference()); - params.putParam("keep_alive", openRequest.keepAlive()); - request.addParameters(params.asMap()); - return request; - } - - static Request closePointInTime(ClosePointInTimeRequest closeRequest) throws IOException { - Request request = new Request(HttpDelete.METHOD_NAME, "/_pit"); - request.setEntity(createEntity(closeRequest, REQUEST_BODY_CONTENT_TYPE)); - return request; - } - static Request multiSearch(MultiSearchRequest multiSearchRequest) throws IOException { Request request = new Request(HttpPost.METHOD_NAME, "/_msearch"); @@ -480,41 +434,6 @@ static Request multiSearch(MultiSearchRequest multiSearchRequest) throws IOExcep return request; } - static Request searchTemplate(SearchTemplateRequest searchTemplateRequest) throws IOException { - Request request; - - if (searchTemplateRequest.isSimulate()) { - request = new Request(HttpGet.METHOD_NAME, "_render/template"); - } else { - SearchRequest searchRequest = searchTemplateRequest.getRequest(); - String endpoint = endpoint(searchRequest.indices(), "_search/template"); - request = new Request(HttpPost.METHOD_NAME, endpoint); - - Params params = new Params(); - addSearchRequestParams(params, searchRequest); - request.addParameters(params.asMap()); - } - - request.setEntity(createEntity(searchTemplateRequest, REQUEST_BODY_CONTENT_TYPE)); - return request; - } - - static Request multiSearchTemplate(MultiSearchTemplateRequest multiSearchTemplateRequest) throws IOException { - Request request = new Request(HttpPost.METHOD_NAME, "/_msearch/template"); - - Params params = new Params(); - params.putParam(RestSearchAction.TYPED_KEYS_PARAM, "true"); - if (multiSearchTemplateRequest.maxConcurrentSearchRequests() != MultiSearchRequest.MAX_CONCURRENT_SEARCH_REQUESTS_DEFAULT) { - params.putParam("max_concurrent_searches", Integer.toString(multiSearchTemplateRequest.maxConcurrentSearchRequests())); - } - request.addParameters(params.asMap()); - - XContent xContent = REQUEST_BODY_CONTENT_TYPE.xContent(); - byte[] source = MultiSearchTemplateRequest.writeMultiLineFormat(multiSearchTemplateRequest, xContent); - request.setEntity(new NByteArrayEntity(source, createContentType(xContent.type()))); - return request; - } - static Request count(CountRequest countRequest) throws IOException { Request request = new Request(HttpPost.METHOD_NAME, endpoint(countRequest.indices(), countRequest.types(), "_count")); Params params = new Params(); @@ -562,31 +481,10 @@ static Request fieldCaps(FieldCapabilitiesRequest fieldCapabilitiesRequest) thro return request; } - static Request rankEval(RankEvalRequest rankEvalRequest) throws IOException { - Request request = new Request(HttpGet.METHOD_NAME, endpoint(rankEvalRequest.indices(), Strings.EMPTY_ARRAY, "_rank_eval")); - - Params params = new Params(); - if (SearchRequest.DEFAULT_INDICES_OPTIONS.equals(rankEvalRequest.indicesOptions()) == false) { - params.withIndicesOptions(rankEvalRequest.indicesOptions()); - } - params.putParam("search_type", rankEvalRequest.searchType().name().toLowerCase(Locale.ROOT)); - request.addParameters(params.asMap()); - request.setEntity(createEntity(rankEvalRequest.getRankEvalSpec(), REQUEST_BODY_CONTENT_TYPE)); - return request; - } - static Request reindex(ReindexRequest reindexRequest) throws IOException { return prepareReindexRequest(reindexRequest, true); } - static Request deleteByQuery(DeleteByQueryRequest deleteByQueryRequest) throws IOException { - return prepareDeleteByQueryRequest(deleteByQueryRequest, true); - } - - static Request updateByQuery(UpdateByQueryRequest updateByQueryRequest) throws IOException { - return prepareUpdateByQueryRequest(updateByQueryRequest, true); - } - private static Request prepareReindexRequest(ReindexRequest reindexRequest, boolean waitForCompletion) throws IOException { String endpoint = new EndpointBuilder().addPathPart("_reindex").build(); Request request = new Request(HttpPost.METHOD_NAME, endpoint); @@ -607,109 +505,6 @@ private static Request prepareReindexRequest(ReindexRequest reindexRequest, bool return request; } - private static Request prepareDeleteByQueryRequest(DeleteByQueryRequest deleteByQueryRequest, boolean waitForCompletion) - throws IOException { - String endpoint = endpoint(deleteByQueryRequest.indices(), "_delete_by_query"); - Request request = new Request(HttpPost.METHOD_NAME, endpoint); - Params params = new Params().withRouting(deleteByQueryRequest.getRouting()) - .withRefresh(deleteByQueryRequest.isRefresh()) - .withTimeout(deleteByQueryRequest.getTimeout()) - .withWaitForActiveShards(deleteByQueryRequest.getWaitForActiveShards()) - .withRequestsPerSecond(deleteByQueryRequest.getRequestsPerSecond()) - .withWaitForCompletion(waitForCompletion) - .withSlices(deleteByQueryRequest.getSlices()); - - if (SearchRequest.DEFAULT_INDICES_OPTIONS.equals(deleteByQueryRequest.indicesOptions()) == false) { - params = params.withIndicesOptions(deleteByQueryRequest.indicesOptions()); - } - - if (deleteByQueryRequest.isAbortOnVersionConflict() == false) { - params.putParam("conflicts", "proceed"); - } - if (deleteByQueryRequest.getBatchSize() != AbstractBulkByScrollRequest.DEFAULT_SCROLL_SIZE) { - params.putParam("scroll_size", Integer.toString(deleteByQueryRequest.getBatchSize())); - } - if (deleteByQueryRequest.getScrollTime() != AbstractBulkByScrollRequest.DEFAULT_SCROLL_TIMEOUT) { - params.putParam("scroll", deleteByQueryRequest.getScrollTime()); - } - if (deleteByQueryRequest.getMaxDocs() > 0) { - params.putParam("max_docs", Integer.toString(deleteByQueryRequest.getMaxDocs())); - } - request.addParameters(params.asMap()); - request.setEntity(createEntity(deleteByQueryRequest, REQUEST_BODY_CONTENT_TYPE)); - return request; - } - - static Request prepareUpdateByQueryRequest(UpdateByQueryRequest updateByQueryRequest, boolean waitForCompletion) throws IOException { - String endpoint = endpoint(updateByQueryRequest.indices(), "_update_by_query"); - Request request = new Request(HttpPost.METHOD_NAME, endpoint); - Params params = new Params().withRouting(updateByQueryRequest.getRouting()) - .withPipeline(updateByQueryRequest.getPipeline()) - .withRefresh(updateByQueryRequest.isRefresh()) - .withTimeout(updateByQueryRequest.getTimeout()) - .withWaitForActiveShards(updateByQueryRequest.getWaitForActiveShards()) - .withRequestsPerSecond(updateByQueryRequest.getRequestsPerSecond()) - .withWaitForCompletion(waitForCompletion) - .withSlices(updateByQueryRequest.getSlices()); - if (SearchRequest.DEFAULT_INDICES_OPTIONS.equals(updateByQueryRequest.indicesOptions()) == false) { - params = params.withIndicesOptions(updateByQueryRequest.indicesOptions()); - } - if (updateByQueryRequest.isAbortOnVersionConflict() == false) { - params.putParam("conflicts", "proceed"); - } - if (updateByQueryRequest.getBatchSize() != AbstractBulkByScrollRequest.DEFAULT_SCROLL_SIZE) { - params.putParam("scroll_size", Integer.toString(updateByQueryRequest.getBatchSize())); - } - if (updateByQueryRequest.getScrollTime() != AbstractBulkByScrollRequest.DEFAULT_SCROLL_TIMEOUT) { - params.putParam("scroll", updateByQueryRequest.getScrollTime()); - } - if (updateByQueryRequest.getMaxDocs() > 0) { - params.putParam("max_docs", Integer.toString(updateByQueryRequest.getMaxDocs())); - } - request.addParameters(params.asMap()); - request.setEntity(createEntity(updateByQueryRequest, REQUEST_BODY_CONTENT_TYPE)); - return request; - } - - static Request rethrottleReindex(RethrottleRequest rethrottleRequest) { - return rethrottle(rethrottleRequest, "_reindex"); - } - - static Request rethrottleUpdateByQuery(RethrottleRequest rethrottleRequest) { - return rethrottle(rethrottleRequest, "_update_by_query"); - } - - static Request rethrottleDeleteByQuery(RethrottleRequest rethrottleRequest) { - return rethrottle(rethrottleRequest, "_delete_by_query"); - } - - private static Request rethrottle(RethrottleRequest rethrottleRequest, String firstPathPart) { - String endpoint = new EndpointBuilder().addPathPart(firstPathPart) - .addPathPart(rethrottleRequest.getTaskId().toString()) - .addPathPart("_rethrottle") - .build(); - Request request = new Request(HttpPost.METHOD_NAME, endpoint); - Params params = new Params().withRequestsPerSecond(rethrottleRequest.getRequestsPerSecond()); - // we set "group_by" to "none" because this is the response format we can parse back - params.putParam("group_by", "none"); - request.addParameters(params.asMap()); - return request; - } - - static Request putScript(PutStoredScriptRequest putStoredScriptRequest) throws IOException { - String endpoint = new EndpointBuilder().addPathPartAsIs("_scripts").addPathPart(putStoredScriptRequest.id()).build(); - Request request = new Request(HttpPost.METHOD_NAME, endpoint); - Params params = new Params(); - params.withTimeout(putStoredScriptRequest.timeout()); - params.withMasterTimeout(putStoredScriptRequest.masterNodeTimeout()); - if (Strings.hasText(putStoredScriptRequest.context())) { - params.putParam("context", putStoredScriptRequest.context()); - } - request.addParameters(params.asMap()); - request.setEntity(createEntity(putStoredScriptRequest, REQUEST_BODY_CONTENT_TYPE)); - return request; - } - static Request termVectors(TermVectorsRequest tvrequest) throws IOException { String endpoint; if (tvrequest.getType() != null) { @@ -733,32 +528,6 @@ static Request termVectors(TermVectorsRequest tvrequest) throws IOException { return request; } - static Request mtermVectors(MultiTermVectorsRequest mtvrequest) throws IOException { - String endpoint = "_mtermvectors"; - Request request = new Request(HttpGet.METHOD_NAME, endpoint); - request.setEntity(createEntity(mtvrequest, REQUEST_BODY_CONTENT_TYPE)); - return request; - } - - static Request getScript(GetStoredScriptRequest getStoredScriptRequest) { - String endpoint = new EndpointBuilder().addPathPartAsIs("_scripts").addPathPart(getStoredScriptRequest.id()).build(); - Request request = new Request(HttpGet.METHOD_NAME, endpoint); - Params params = new Params(); - params.withMasterTimeout(getStoredScriptRequest.masterNodeTimeout()); - request.addParameters(params.asMap()); - return request; - } - - static Request deleteScript(DeleteStoredScriptRequest deleteStoredScriptRequest) { - String endpoint = new EndpointBuilder().addPathPartAsIs("_scripts").addPathPart(deleteStoredScriptRequest.id()).build(); - Request request = new Request(HttpDelete.METHOD_NAME, endpoint); - Params params = new Params(); - params.withTimeout(deleteStoredScriptRequest.timeout()); - params.withMasterTimeout(deleteStoredScriptRequest.masterNodeTimeout()); - request.addParameters(params.asMap()); - return request; - } - static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType) throws IOException { return createEntity(toXContent, xContentType, ToXContent.EMPTY_PARAMS); } @@ -783,10 +552,6 @@ static String endpoint(String index, String type, String id, String endpoint) { return new EndpointBuilder().addPathPart(index, type, id).addPathPartAsIs(endpoint).build(); } - static String endpoint(String[] indices) { - return new EndpointBuilder().addCommaSeparatedPathParts(indices).build(); - } - static String endpoint(String[] indices, String endpoint) { return new EndpointBuilder().addCommaSeparatedPathParts(indices).addPathPartAsIs(endpoint).build(); } @@ -799,13 +564,6 @@ static String endpoint(String[] indices, String[] types, String endpoint) { .build(); } - static String endpoint(String[] indices, String endpoint, String[] suffixes) { - return new EndpointBuilder().addCommaSeparatedPathParts(indices) - .addPathPartAsIs(endpoint) - .addCommaSeparatedPathParts(suffixes) - .build(); - } - @Deprecated static String endpoint(String[] indices, String endpoint, String type) { return new EndpointBuilder().addCommaSeparatedPathParts(indices).addPathPartAsIs(endpoint).addPathPart(type).build(); @@ -878,10 +636,6 @@ Params withFields(String[] fields) { return this; } - Params withMasterTimeout(TimeValue masterTimeout) { - return putParam("master_timeout", masterTimeout); - } - Params withPipeline(String pipeline) { return putParam("pipeline", pipeline); } @@ -1050,102 +804,9 @@ Params withIgnoreUnavailable(boolean ignoreUnavailable) { return this; } - Params withHuman(boolean human) { - if (human) { - putParam("human", Boolean.toString(human)); - } - return this; - } - - Params withLocal(boolean local) { - if (local) { - putParam("local", Boolean.toString(local)); - } - return this; - } - - Params withIncludeDefaults(boolean includeDefaults) { - if (includeDefaults) { - return putParam("include_defaults", Boolean.TRUE.toString()); - } - return this; - } - - Params withPreserveExisting(boolean preserveExisting) { - if (preserveExisting) { - return putParam("preserve_existing", Boolean.TRUE.toString()); - } - return this; - } - - Params withDetailed(boolean detailed) { - if (detailed) { - return putParam("detailed", Boolean.TRUE.toString()); - } - return this; - } - Params withWaitForCompletion(Boolean waitForCompletion) { return putParam("wait_for_completion", waitForCompletion.toString()); } - - Params withNodes(String[] nodes) { - return withNodes(Arrays.asList(nodes)); - } - - Params withNodes(List nodes) { - if (nodes != null && nodes.size() > 0) { - return putParam("nodes", String.join(",", nodes)); - } - return this; - } - - Params withActions(String[] actions) { - return withActions(Arrays.asList(actions)); - } - - Params withActions(List actions) { - if (actions != null && actions.size() > 0) { - return putParam("actions", String.join(",", actions)); - } - return this; - } - - Params withWaitForStatus(ClusterHealthStatus status) { - if (status != null) { - return putParam("wait_for_status", status.name().toLowerCase(Locale.ROOT)); - } - return this; - } - - Params withWaitForNoRelocatingShards(boolean waitNoRelocatingShards) { - if (waitNoRelocatingShards) { - return putParam("wait_for_no_relocating_shards", Boolean.TRUE.toString()); - } - return this; - } - - Params withWaitForNoInitializingShards(boolean waitNoInitShards) { - if (waitNoInitShards) { - return putParam("wait_for_no_initializing_shards", Boolean.TRUE.toString()); - } - return this; - } - - Params withWaitForNodes(String waitForNodes) { - return putParam("wait_for_nodes", waitForNodes); - } - - Params withLevel(ClusterHealthRequest.Level level) { - return putParam("level", level.name().toLowerCase(Locale.ROOT)); - } - - Params withWaitForEvents(Priority waitForEvents) { - if (waitForEvents != null) { - return putParam("wait_for_events", waitForEvents.name().toLowerCase(Locale.ROOT)); - } - return this; - } } /** @@ -1199,11 +860,6 @@ EndpointBuilder addCommaSeparatedPathParts(String[] parts) { return this; } - EndpointBuilder addCommaSeparatedPathParts(List parts) { - addPathPart(String.join(",", parts)); - return this; - } - EndpointBuilder addPathPartAsIs(String... parts) { for (String part : parts) { if (Strings.hasLength(part)) { diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java index 1ccdb1ae58df8..06ff0bdd72a11 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java @@ -63,9 +63,7 @@ import org.elasticsearch.core.CheckedConsumer; import org.elasticsearch.core.CheckedFunction; import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.elasticsearch.index.reindex.DeleteByQueryRequest; import org.elasticsearch.index.reindex.ReindexRequest; -import org.elasticsearch.index.reindex.UpdateByQueryRequest; import org.elasticsearch.plugins.spi.NamedXContentProvider; import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.RestStatus; @@ -377,42 +375,6 @@ public final BulkByScrollResponse reindex(ReindexRequest reindexRequest, Request ); } - /** - * Executes a update by query request. - * See - * Update By Query API on elastic.co - * @param updateByQueryRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @return the response - */ - public final BulkByScrollResponse updateByQuery(UpdateByQueryRequest updateByQueryRequest, RequestOptions options) throws IOException { - return performRequestAndParseEntity( - updateByQueryRequest, - RequestConverters::updateByQuery, - options, - BulkByScrollResponse::fromXContent, - singleton(409) - ); - } - - /** - * Executes a delete by query request. - * See - * Delete By Query API on elastic.co - * @param deleteByQueryRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @return the response - */ - public final BulkByScrollResponse deleteByQuery(DeleteByQueryRequest deleteByQueryRequest, RequestOptions options) throws IOException { - return performRequestAndParseEntity( - deleteByQueryRequest, - RequestConverters::deleteByQuery, - options, - BulkByScrollResponse::fromXContent, - singleton(409) - ); - } - /** * Get the cluster info otherwise provided when sending an HTTP request to '/' * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -1104,37 +1066,6 @@ public void onFailure(Exception exception) { }; } - final ResponseListener wrapResponseListener404sOptional( - CheckedFunction responseConverter, - ActionListener> actionListener - ) { - return new ResponseListener() { - @Override - public void onSuccess(Response response) { - try { - actionListener.onResponse(Optional.of(responseConverter.apply(response))); - } catch (Exception e) { - IOException ioe = new IOException("Unable to parse response body for " + response, e); - onFailure(ioe); - } - } - - @Override - public void onFailure(Exception exception) { - if (exception instanceof ResponseException responseException) { - Response response = responseException.getResponse(); - if (RestStatus.NOT_FOUND.getStatus() == response.getStatusLine().getStatusCode()) { - actionListener.onResponse(Optional.empty()); - } else { - actionListener.onFailure(parseResponseException(responseException)); - } - } else { - actionListener.onFailure(exception); - } - } - }; - } - /** * Converts a {@link ResponseException} obtained from the low level REST client into an {@link ElasticsearchException}. * If a response body was returned, tries to parse it as an error returned from Elasticsearch. diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/TimedRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/TimedRequest.java deleted file mode 100644 index a3135b9725ebf..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/TimedRequest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ -package org.elasticsearch.client; - -import org.elasticsearch.core.TimeValue; - -import static org.elasticsearch.core.TimeValue.timeValueSeconds; - -/** - * A base request for any requests that supply timeouts. - * - * Please note, any requests that use a ackTimeout should set timeout as they - * represent the same backing field on the server. - */ -public abstract class TimedRequest implements Validatable { - - public static final TimeValue DEFAULT_ACK_TIMEOUT = timeValueSeconds(30); - public static final TimeValue DEFAULT_MASTER_NODE_TIMEOUT = TimeValue.timeValueSeconds(30); - - private TimeValue timeout = DEFAULT_ACK_TIMEOUT; - private TimeValue masterTimeout = DEFAULT_MASTER_NODE_TIMEOUT; - - /** - * Sets the timeout to wait for the all the nodes to acknowledge - * @param timeout timeout as a {@link TimeValue} - */ - public void setTimeout(TimeValue timeout) { - this.timeout = timeout; - } - - /** - * Sets the timeout to connect to the master node - * @param masterTimeout timeout as a {@link TimeValue} - */ - public void setMasterTimeout(TimeValue masterTimeout) { - this.masterTimeout = masterTimeout; - } - - /** - * Returns the request timeout - */ - public TimeValue timeout() { - return timeout; - } - - /** - * Returns the timeout for the request to be completed on the master node - */ - public TimeValue masterNodeTimeout() { - return masterTimeout; - } -} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/asyncsearch/DeleteAsyncSearchRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/asyncsearch/DeleteAsyncSearchRequest.java deleted file mode 100644 index 0f7e7579e0b5b..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/asyncsearch/DeleteAsyncSearchRequest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.client.asyncsearch; - -import org.elasticsearch.client.Validatable; - -import java.util.Objects; - -public class DeleteAsyncSearchRequest implements Validatable { - - private final String id; - - public DeleteAsyncSearchRequest(String id) { - this.id = id; - } - - public String getId() { - return this.id; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DeleteAsyncSearchRequest request = (DeleteAsyncSearchRequest) o; - return Objects.equals(getId(), request.getId()); - } - - @Override - public int hashCode() { - return Objects.hash(getId()); - } -} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/asyncsearch/GetAsyncSearchRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/asyncsearch/GetAsyncSearchRequest.java deleted file mode 100644 index d6c40dbe1a567..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/asyncsearch/GetAsyncSearchRequest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.client.asyncsearch; - -import org.elasticsearch.client.Validatable; -import org.elasticsearch.client.ValidationException; -import org.elasticsearch.core.TimeValue; - -import java.util.Objects; -import java.util.Optional; - -public class GetAsyncSearchRequest implements Validatable { - - private TimeValue waitForCompletion; - private TimeValue keepAlive; - - private final String id; - - public GetAsyncSearchRequest(String id) { - this.id = id; - } - - public String getId() { - return this.id; - } - - public TimeValue getWaitForCompletion() { - return waitForCompletion; - } - - public void setWaitForCompletion(TimeValue waitForCompletion) { - this.waitForCompletion = waitForCompletion; - } - - public TimeValue getKeepAlive() { - return keepAlive; - } - - public void setKeepAlive(TimeValue keepAlive) { - this.keepAlive = keepAlive; - } - - @Override - public Optional validate() { - return Optional.empty(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - GetAsyncSearchRequest request = (GetAsyncSearchRequest) o; - return Objects.equals(getId(), request.getId()) - && Objects.equals(getKeepAlive(), request.getKeepAlive()) - && Objects.equals(getWaitForCompletion(), request.getWaitForCompletion()); - } - - @Override - public int hashCode() { - return Objects.hash(getId(), getKeepAlive(), getWaitForCompletion()); - } -} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/asyncsearch/SubmitAsyncSearchRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/asyncsearch/SubmitAsyncSearchRequest.java deleted file mode 100644 index 9c381645d6ff4..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/asyncsearch/SubmitAsyncSearchRequest.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.client.asyncsearch; - -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Validatable; -import org.elasticsearch.client.ValidationException; -import org.elasticsearch.core.TimeValue; -import org.elasticsearch.search.builder.SearchSourceBuilder; - -import java.util.Objects; -import java.util.Optional; - -/** - * A request to track asynchronously the progress of a search against one or more indices. - */ -public class SubmitAsyncSearchRequest implements Validatable { - - public static long MIN_KEEP_ALIVE = TimeValue.timeValueMinutes(1).millis(); - - private TimeValue waitForCompletionTimeout; - private Boolean keepOnCompletion; - private TimeValue keepAlive; - private final SearchRequest searchRequest; - // The following is optional and will only be sent down with the request if explicitely set by the user - private Integer batchedReduceSize; - - /** - * Creates a new request - */ - public SubmitAsyncSearchRequest(SearchSourceBuilder source, String... indices) { - this.searchRequest = new SearchRequest(indices, source); - } - - /** - * Get the target indices - */ - public String[] getIndices() { - return this.searchRequest.indices(); - } - - /** - * Get the minimum time that the request should wait before returning a partial result (defaults to 1 second). - */ - public TimeValue getWaitForCompletionTimeout() { - return waitForCompletionTimeout; - } - - /** - * Sets the minimum time that the request should wait before returning a partial result (defaults to 1 second). - */ - public void setWaitForCompletionTimeout(TimeValue waitForCompletionTimeout) { - this.waitForCompletionTimeout = waitForCompletionTimeout; - } - - /** - * Returns whether the resource resource should be kept on completion or failure (defaults to false). - */ - public Boolean isKeepOnCompletion() { - return keepOnCompletion; - } - - /** - * Determines if the resource should be kept on completion or failure (defaults to false). - */ - public void setKeepOnCompletion(boolean keepOnCompletion) { - this.keepOnCompletion = keepOnCompletion; - } - - /** - * Get the amount of time after which the result will expire (defaults to 5 days). - */ - public TimeValue getKeepAlive() { - return keepAlive; - } - - /** - * Sets the amount of time after which the result will expire (defaults to 5 days). - */ - public void setKeepAlive(TimeValue keepAlive) { - this.keepAlive = keepAlive; - } - - // setters for request parameters of the wrapped SearchRequest - /** - * Set the routing value to control the shards that the search will be executed on. - * A comma separated list of routing values to control the shards the search will be executed on. - */ - public void setRouting(String routing) { - this.searchRequest.routing(routing); - } - - /** - * Set the routing values to control the shards that the search will be executed on. - */ - public void setRoutings(String... routings) { - this.searchRequest.routing(routings); - } - - /** - * Get the routing value to control the shards that the search will be executed on. - */ - public String getRouting() { - return this.searchRequest.routing(); - } - - /** - * Sets the preference to execute the search. Defaults to randomize across shards. Can be set to - * {@code _local} to prefer local shards or a custom value, which guarantees that the same order - * will be used across different requests. - */ - public void setPreference(String preference) { - this.searchRequest.preference(preference); - } - - /** - * Get the preference to execute the search. - */ - public String getPreference() { - return this.searchRequest.preference(); - } - - /** - * Specifies what type of requested indices to ignore and how to deal with indices wildcard expressions. - */ - public void setIndicesOptions(IndicesOptions indicesOptions) { - this.searchRequest.indicesOptions(indicesOptions); - } - - /** - * Get the indices Options. - */ - public IndicesOptions getIndicesOptions() { - return this.searchRequest.indicesOptions(); - } - - /** - * The search type to execute, defaults to {@link SearchType#DEFAULT}. - */ - public void setSearchType(SearchType searchType) { - this.searchRequest.searchType(searchType); - } - - /** - * Get the search type to execute, defaults to {@link SearchType#DEFAULT}. - */ - public SearchType getSearchType() { - return this.searchRequest.searchType(); - } - - /** - * Sets if this request should allow partial results. (If method is not called, - * will default to the cluster level setting). - */ - public void setAllowPartialSearchResults(boolean allowPartialSearchResults) { - this.searchRequest.allowPartialSearchResults(allowPartialSearchResults); - } - - /** - * Gets if this request should allow partial results. - */ - public Boolean getAllowPartialSearchResults() { - return this.searchRequest.allowPartialSearchResults(); - } - - /** - * Optional. Sets the number of shard results that should be reduced at once on the coordinating node. - * This value should be used as a protection mechanism to reduce the memory overhead per search - * request if the potential number of shards in the request can be large. Defaults to 5. - */ - public void setBatchedReduceSize(int batchedReduceSize) { - this.batchedReduceSize = batchedReduceSize; - } - - /** - * Gets the number of shard results that should be reduced at once on the coordinating node. - * Returns {@code null} if unset. - */ - public Integer getBatchedReduceSize() { - return this.batchedReduceSize; - } - - /** - * Sets if this request should use the request cache or not, assuming that it can (for - * example, if "now" is used, it will never be cached). - * By default (if not set) this is turned on for {@link SubmitAsyncSearchRequest}. - */ - public void setRequestCache(Boolean requestCache) { - this.searchRequest.requestCache(requestCache); - } - - /** - * Gets if this request should use the request cache or not, if set. - * This defaults to `true` on the server side if unset in the client. - */ - public Boolean getRequestCache() { - return this.searchRequest.requestCache(); - } - - /** - * Returns the number of shard requests that should be executed concurrently on a single node. - * The default is {@code 5}. - */ - public int getMaxConcurrentShardRequests() { - return this.searchRequest.getMaxConcurrentShardRequests(); - } - - /** - * Sets the number of shard requests that should be executed concurrently on a single node. - * The default is {@code 5}. - */ - public void setMaxConcurrentShardRequests(int maxConcurrentShardRequests) { - this.searchRequest.setMaxConcurrentShardRequests(maxConcurrentShardRequests); - } - - /** - * Gets if the source of the {@link SearchSourceBuilder} initially used on this request. - */ - public SearchSourceBuilder getSearchSource() { - return this.searchRequest.source(); - } - - @Override - public Optional validate() { - final ValidationException validationException = new ValidationException(); - if (searchRequest.isSuggestOnly()) { - validationException.addValidationError("suggest-only queries are not supported"); - } - if (keepAlive != null && keepAlive.getMillis() < MIN_KEEP_ALIVE) { - validationException.addValidationError("[keep_alive] must be greater than 1 minute, got: " + keepAlive.toString()); - } - if (validationException.validationErrors().isEmpty()) { - return Optional.empty(); - } - return Optional.of(validationException); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SubmitAsyncSearchRequest request = (SubmitAsyncSearchRequest) o; - return Objects.equals(searchRequest, request.searchRequest) - && Objects.equals(getKeepAlive(), request.getKeepAlive()) - && Objects.equals(getWaitForCompletionTimeout(), request.getWaitForCompletionTimeout()) - && Objects.equals(isKeepOnCompletion(), request.isKeepOnCompletion()); - } - - @Override - public int hashCode() { - return Objects.hash(searchRequest, getKeepAlive(), getWaitForCompletionTimeout(), isKeepOnCompletion()); - } -} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/RemoteInfoRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/RemoteInfoRequest.java deleted file mode 100644 index 7672c1054c045..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/RemoteInfoRequest.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ -package org.elasticsearch.client.cluster; - -import org.elasticsearch.client.Validatable; - -/** - * The request object used by the Remote cluster info API. - */ -public final class RemoteInfoRequest implements Validatable { - -} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/RemoteInfoResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/RemoteInfoResponse.java deleted file mode 100644 index 9aff43bf38719..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/RemoteInfoResponse.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ -package org.elasticsearch.client.cluster; - -import org.elasticsearch.xcontent.XContentParser; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; - -/** - * A response to _remote/info API request. - */ -public final class RemoteInfoResponse { - - private List infos; - - RemoteInfoResponse(Collection infos) { - this.infos = List.copyOf(infos); - } - - public List getInfos() { - return infos; - } - - public static RemoteInfoResponse fromXContent(XContentParser parser) throws IOException { - ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser); - - List infos = new ArrayList<>(); - - XContentParser.Token token; - while ((token = parser.nextToken()) == XContentParser.Token.FIELD_NAME) { - String clusterAlias = parser.currentName(); - RemoteConnectionInfo info = RemoteConnectionInfo.fromXContent(parser, clusterAlias); - infos.add(info); - } - ensureExpectedToken(XContentParser.Token.END_OBJECT, token, parser); - return new RemoteInfoResponse(infos); - } -} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/core/IndexerJobStats.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/core/IndexerJobStats.java deleted file mode 100644 index e404f254e17ad..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/core/IndexerJobStats.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.client.core; - -import org.elasticsearch.xcontent.ParseField; - -import java.util.Objects; - -public abstract class IndexerJobStats { - public static ParseField NUM_PAGES = new ParseField("pages_processed"); - public static ParseField NUM_INPUT_DOCUMENTS = new ParseField("documents_processed"); - public static ParseField NUM_OUTPUT_DOCUMENTS = new ParseField("documents_indexed"); - public static ParseField NUM_INVOCATIONS = new ParseField("trigger_count"); - public static ParseField INDEX_TIME_IN_MS = new ParseField("index_time_in_ms"); - public static ParseField SEARCH_TIME_IN_MS = new ParseField("search_time_in_ms"); - public static ParseField PROCESSING_TIME_IN_MS = new ParseField("processing_time_in_ms"); - public static ParseField INDEX_TOTAL = new ParseField("index_total"); - public static ParseField SEARCH_TOTAL = new ParseField("search_total"); - public static ParseField PROCESSING_TOTAL = new ParseField("processing_total"); - public static ParseField SEARCH_FAILURES = new ParseField("search_failures"); - public static ParseField INDEX_FAILURES = new ParseField("index_failures"); - - protected final long numPages; - protected final long numInputDocuments; - protected final long numOuputDocuments; - protected final long numInvocations; - protected final long indexTime; - protected final long indexTotal; - protected final long searchTime; - protected final long searchTotal; - protected final long processingTime; - protected final long processingTotal; - protected final long indexFailures; - protected final long searchFailures; - - public IndexerJobStats( - long numPages, - long numInputDocuments, - long numOutputDocuments, - long numInvocations, - long indexTime, - long searchTime, - long processingTime, - long indexTotal, - long searchTotal, - long processingTotal, - long indexFailures, - long searchFailures - ) { - this.numPages = numPages; - this.numInputDocuments = numInputDocuments; - this.numOuputDocuments = numOutputDocuments; - this.numInvocations = numInvocations; - this.indexTime = indexTime; - this.indexTotal = indexTotal; - this.searchTime = searchTime; - this.searchTotal = searchTotal; - this.processingTime = processingTime; - this.processingTotal = processingTotal; - this.indexFailures = indexFailures; - this.searchFailures = searchFailures; - } - - /** - * The number of pages read from the input indices - */ - public long getNumPages() { - return numPages; - } - - /** - * The number of documents read from the input indices - */ - public long getNumDocuments() { - return numInputDocuments; - } - - /** - * Number of times that the job woke up to write documents - */ - public long getNumInvocations() { - return numInvocations; - } - - /** - * Number of documents written - */ - public long getOutputDocuments() { - return numOuputDocuments; - } - - /** - * Number of index failures that have occurred - */ - public long getIndexFailures() { - return indexFailures; - } - - /** - * Number of failures that have occurred - */ - public long getSearchFailures() { - return searchFailures; - } - - /** - * Returns the time spent indexing (cumulative) in milliseconds - */ - public long getIndexTime() { - return indexTime; - } - - /** - * Returns the time spent searching (cumulative) in milliseconds - */ - public long getSearchTime() { - return searchTime; - } - - /** - * Returns the time spent processing (cumulative) in milliseconds - */ - public long getProcessingTime() { - return processingTime; - } - - /** - * Returns the total number of indexing requests that have been processed - * (Note: this is not the number of _documents_ that have been indexed) - */ - public long getIndexTotal() { - return indexTotal; - } - - /** - * Returns the total number of search requests that have been made - */ - public long getSearchTotal() { - return searchTotal; - } - - /** - * Returns the total number of processing runs that have been made - */ - public long getProcessingTotal() { - return processingTotal; - } - - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - - if (other instanceof IndexerJobStats == false) { - return false; - } - - IndexerJobStats that = (IndexerJobStats) other; - return Objects.equals(this.numPages, that.numPages) - && Objects.equals(this.numInputDocuments, that.numInputDocuments) - && Objects.equals(this.numOuputDocuments, that.numOuputDocuments) - && Objects.equals(this.numInvocations, that.numInvocations) - && Objects.equals(this.indexTime, that.indexTime) - && Objects.equals(this.searchTime, that.searchTime) - && Objects.equals(this.processingTime, that.processingTime) - && Objects.equals(this.indexFailures, that.indexFailures) - && Objects.equals(this.searchFailures, that.searchFailures) - && Objects.equals(this.searchTotal, that.searchTotal) - && Objects.equals(this.processingTotal, that.processingTotal) - && Objects.equals(this.indexTotal, that.indexTotal); - } - - @Override - public int hashCode() { - return Objects.hash( - numPages, - numInputDocuments, - numOuputDocuments, - numInvocations, - indexTime, - searchTime, - processingTime, - indexFailures, - searchFailures, - searchTotal, - indexTotal, - processingTotal - ); - } - - @Override - public final String toString() { - return "{pages=" - + numPages - + ", input_docs=" - + numInputDocuments - + ", output_docs=" - + numOuputDocuments - + ", invocations=" - + numInvocations - + ", index_failures=" - + indexFailures - + ", search_failures=" - + searchFailures - + ", index_time_in_ms=" - + indexTime - + ", index_total=" - + indexTotal - + ", search_time_in_ms=" - + searchTime - + ", search_total=" - + searchTotal - + ", processing_time_in_ms=" - + processingTime - + ", processing_total=" - + processingTotal - + "}"; - } -} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/license/LicenseStatus.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/license/LicenseStatus.java deleted file mode 100644 index 3038b702c84e2..0000000000000 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/license/LicenseStatus.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ -package org.elasticsearch.client.license; - -/** - * Status of an X-Pack license. - */ -public enum LicenseStatus { - - ACTIVE("active"), - INVALID("invalid"), - EXPIRED("expired"); - - private final String label; - - LicenseStatus(String label) { - this.label = label; - } - - public String label() { - return label; - } - - public static LicenseStatus fromString(String value) { - return switch (value) { - case "active" -> ACTIVE; - case "invalid" -> INVALID; - case "expired" -> EXPIRED; - default -> throw new IllegalArgumentException("unknown license status [" + value + "]"); - }; - } -}