From 525c3b044aa948742c0752365bb62f26d0c9eb20 Mon Sep 17 00:00:00 2001 From: Andrei Stefan Date: Thu, 29 Nov 2018 14:06:48 +0200 Subject: [PATCH] Leftover from https://github.com/elastic/elasticsearch/pull/35964 (#36030) --- .../elasticsearch/xpack/sql/proto/Protocol.java | 2 ++ .../xpack/sql/plugin/RestSqlTranslateAction.java | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/Protocol.java b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/Protocol.java index 52aa6eed6cf..8080959e3c6 100644 --- a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/Protocol.java +++ b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/Protocol.java @@ -30,6 +30,8 @@ public final class Protocol { public static final String CLEAR_CURSOR_DEPRECATED_REST_ENDPOINT = "/_xpack/sql/close"; public static final String SQL_QUERY_REST_ENDPOINT = "/_sql"; public static final String SQL_QUERY_DEPRECATED_REST_ENDPOINT = "/_xpack/sql"; + public static final String SQL_TRANSLATE_REST_ENDPOINT = "/_sql/translate"; + public static final String SQL_TRANSLATE_DEPRECATED_REST_ENDPOINT = "/_xpack/sql/translate"; public static final String SQL_STATS_REST_ENDPOINT = "/_sql/stats"; public static final String SQL_STATS_DEPRECATED_REST_ENDPOINT = "/_xpack/sql/stats"; } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlTranslateAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlTranslateAction.java index b35a2a13ad8..5929ca5aadd 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlTranslateAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlTranslateAction.java @@ -5,7 +5,9 @@ */ package org.elasticsearch.xpack.sql.plugin; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.rest.BaseRestHandler; @@ -15,6 +17,7 @@ import org.elasticsearch.rest.action.RestToXContentListener; import org.elasticsearch.xpack.sql.action.SqlTranslateAction; import org.elasticsearch.xpack.sql.action.SqlTranslateRequest; import org.elasticsearch.xpack.sql.proto.Mode; +import org.elasticsearch.xpack.sql.proto.Protocol; import java.io.IOException; @@ -25,10 +28,19 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; * REST action for translating SQL queries into ES requests */ public class RestSqlTranslateAction extends BaseRestHandler { + + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestSqlTranslateAction.class)); + public RestSqlTranslateAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(GET, "/_sql/translate", this); - controller.registerHandler(POST, "/_sql/translate", this); + // TODO: remove deprecated endpoint in 8.0.0 + controller.registerWithDeprecatedHandler( + GET, Protocol.SQL_TRANSLATE_REST_ENDPOINT, this, + GET, Protocol.SQL_TRANSLATE_DEPRECATED_REST_ENDPOINT, deprecationLogger); + // TODO: remove deprecated endpoint in 8.0.0 + controller.registerWithDeprecatedHandler( + POST, Protocol.SQL_TRANSLATE_REST_ENDPOINT, this, + POST, Protocol.SQL_TRANSLATE_DEPRECATED_REST_ENDPOINT, deprecationLogger); } @Override