This commit is contained in:
Andrei Stefan 2018-11-29 14:06:48 +02:00 committed by GitHub
parent 89c515175b
commit 525c3b044a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -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";
}

View File

@ -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