diff --git a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/CoreProtocol.java b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/CoreProtocol.java index e97e2ff488970..d541fd987333a 100644 --- a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/CoreProtocol.java +++ b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/CoreProtocol.java @@ -95,9 +95,13 @@ public class CoreProtocol { * SQL-related endpoints */ public static final String CLEAR_CURSOR_REST_ENDPOINT = "/_sql/close"; + 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"; // async public static final String SQL_ASYNC_REST_ENDPOINT = "/_sql/async/"; public static final String SQL_ASYNC_STATUS_REST_ENDPOINT = SQL_ASYNC_REST_ENDPOINT + "status/"; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java index d2f9ff5db695a..15c235641e9a1 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; @@ -25,7 +26,11 @@ public class RestSqlClearCursorAction extends BaseRestHandler { @Override public List routes() { - return List.of(new Route(POST, Protocol.CLEAR_CURSOR_REST_ENDPOINT)); + return List.of( + Route.builder(POST, Protocol.CLEAR_CURSOR_REST_ENDPOINT) + .replaces(POST, Protocol.CLEAR_CURSOR_DEPRECATED_REST_ENDPOINT, RestApiVersion.V_7) + .build() + ); } @Override diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlQueryAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlQueryAction.java index 561d23bf41c52..999676f72cc51 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlQueryAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlQueryAction.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestCancellableNodeClient; @@ -31,7 +32,14 @@ public class RestSqlQueryAction extends BaseRestHandler { @Override public List routes() { - return List.of(new Route(GET, Protocol.SQL_QUERY_REST_ENDPOINT), new Route(POST, Protocol.SQL_QUERY_REST_ENDPOINT)); + return List.of( + Route.builder(GET, Protocol.SQL_QUERY_REST_ENDPOINT) + .replaces(GET, Protocol.SQL_QUERY_DEPRECATED_REST_ENDPOINT, RestApiVersion.V_7) + .build(), + Route.builder(POST, Protocol.SQL_QUERY_REST_ENDPOINT) + .replaces(POST, Protocol.SQL_QUERY_DEPRECATED_REST_ENDPOINT, RestApiVersion.V_7) + .build() + ); } public MediaTypeRegistry validAcceptMediaTypes() { diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlStatsAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlStatsAction.java index 50b464150c087..00fdb51bbc25d 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlStatsAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlStatsAction.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestActions; @@ -21,7 +22,11 @@ public class RestSqlStatsAction extends BaseRestHandler { @Override public List routes() { - return List.of(new Route(GET, Protocol.SQL_STATS_REST_ENDPOINT)); + return List.of( + Route.builder(GET, Protocol.SQL_STATS_REST_ENDPOINT) + .replaces(GET, Protocol.SQL_STATS_DEPRECATED_REST_ENDPOINT, RestApiVersion.V_7) + .build() + ); } @Override 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 c0ef5de48a9c2..e48f721484987 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 @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; @@ -28,7 +29,14 @@ public class RestSqlTranslateAction extends BaseRestHandler { @Override public List routes() { - return List.of(new Route(GET, Protocol.SQL_TRANSLATE_REST_ENDPOINT), new Route(POST, Protocol.SQL_TRANSLATE_REST_ENDPOINT)); + return List.of( + Route.builder(GET, Protocol.SQL_TRANSLATE_REST_ENDPOINT) + .replaces(GET, Protocol.SQL_TRANSLATE_DEPRECATED_REST_ENDPOINT, RestApiVersion.V_7) + .build(), + Route.builder(POST, Protocol.SQL_TRANSLATE_REST_ENDPOINT) + .replaces(POST, Protocol.SQL_TRANSLATE_DEPRECATED_REST_ENDPOINT, RestApiVersion.V_7) + .build() + ); } @Override diff --git a/x-pack/qa/xpack-prefix-rest-compat/build.gradle b/x-pack/qa/xpack-prefix-rest-compat/build.gradle index 63d92014065d4..59c00e4c9c671 100644 --- a/x-pack/qa/xpack-prefix-rest-compat/build.gradle +++ b/x-pack/qa/xpack-prefix-rest-compat/build.gradle @@ -34,7 +34,7 @@ dependencies { tasks.named("copyRestCompatTestTask").configure { task -> task.dependsOn(configurations.compatXpackTests); task.setXpackConfig(configurations.compatXpackTests); - task.getIncludeXpack().set(List.of("ml", "rollup", "license", "migration", "ssl")); + task.getIncludeXpack().set(List.of("license", "migration", "ml", "rollup", "sql", "ssl")); task.getOutputResourceDir().set(project.getLayout().getBuildDirectory().dir("restResources/v${compatVersion}/yamlTests/original")); task.setXpackConfigToFileTree( config -> project.fileTree( @@ -114,15 +114,6 @@ tasks.named("yamlRestTestV7CompatTransform").configure{ task -> task.replaceKeyInDo("migration.deprecations", "xpack-migration.deprecations") task.addAllowedWarningRegex(".*_xpack/migration.* is deprecated.*") - task.replaceKeyInDo("rollup.delete_job", "xpack-rollup.delete_job") - task.replaceKeyInDo("rollup.get_jobs", "xpack-rollup.get_jobs") - task.replaceKeyInDo("rollup.get_rollup_caps", "xpack-rollup.get_rollup_caps") - task.replaceKeyInDo("rollup.get_rollup_index_caps", "xpack-rollup.get_rollup_index_caps") - task.replaceKeyInDo("rollup.put_job", "xpack-rollup.put_job") - task.replaceKeyInDo("rollup.start_job", "xpack-rollup.start_job") - task.replaceKeyInDo("rollup.stop_job", "xpack-rollup.stop_job") - task.addAllowedWarningRegex(".*_xpack/rollup.* is deprecated.*") - task.replaceKeyInDo("ml.close_job", "xpack-ml.close_job") task.replaceKeyInDo("ml.delete_calendar", "xpack-ml.delete_calendar") task.replaceKeyInDo("ml.delete_calendar_event", "xpack-ml.delete_calendar_event") @@ -170,6 +161,20 @@ tasks.named("yamlRestTestV7CompatTransform").configure{ task -> task.replaceKeyInDo("ml.validate_detector", "xpack-ml.validate_detector") task.addAllowedWarningRegex(".*_xpack/ml.* is deprecated.*") + task.replaceKeyInDo("rollup.delete_job", "xpack-rollup.delete_job") + task.replaceKeyInDo("rollup.get_jobs", "xpack-rollup.get_jobs") + task.replaceKeyInDo("rollup.get_rollup_caps", "xpack-rollup.get_rollup_caps") + task.replaceKeyInDo("rollup.get_rollup_index_caps", "xpack-rollup.get_rollup_index_caps") + task.replaceKeyInDo("rollup.put_job", "xpack-rollup.put_job") + task.replaceKeyInDo("rollup.start_job", "xpack-rollup.start_job") + task.replaceKeyInDo("rollup.stop_job", "xpack-rollup.stop_job") + task.addAllowedWarningRegex(".*_xpack/rollup.* is deprecated.*") + + task.replaceKeyInDo("sql.clear_cursor", "xpack-sql.clear_cursor") + task.replaceKeyInDo("sql.query", "xpack-sql.query") + task.replaceKeyInDo("sql.translate", "xpack-sql.translate") + task.addAllowedWarningRegex(".*_xpack/sql.* is deprecated.*") + task.replaceKeyInDo("ssl.certificates", "xpack-ssl.certificates", "Test get SSL certificates") task.addAllowedWarningRegexForTest(".*_xpack/ssl.* is deprecated.*", "Test get SSL certificates") } diff --git a/x-pack/qa/xpack-prefix-rest-compat/src/yamlRestTestV7Compat/resources/rest-api-spec/api/xpack-sql.clear_cursor.json b/x-pack/qa/xpack-prefix-rest-compat/src/yamlRestTestV7Compat/resources/rest-api-spec/api/xpack-sql.clear_cursor.json new file mode 100644 index 0000000000000..ee706fc0736cd --- /dev/null +++ b/x-pack/qa/xpack-prefix-rest-compat/src/yamlRestTestV7Compat/resources/rest-api-spec/api/xpack-sql.clear_cursor.json @@ -0,0 +1,28 @@ +{ + "xpack-sql.clear_cursor":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-sql-cursor-api.html", + "description":"Clears the SQL cursor" + }, + "stability":"stable", + "visibility":"public", + "headers":{ + "accept": [ "application/vnd.elasticsearch+json;compatible-with=7"], + "content_type": ["application/vnd.elasticsearch+json;compatible-with=7"] + }, + "url":{ + "paths":[ + { + "path":"/_xpack/sql/close", + "methods":[ + "POST" + ] + } + ] + }, + "body":{ + "description":"Specify the cursor value in the `cursor` element to clean the cursor.", + "required":true + } + } +} diff --git a/x-pack/qa/xpack-prefix-rest-compat/src/yamlRestTestV7Compat/resources/rest-api-spec/api/xpack-sql.query.json b/x-pack/qa/xpack-prefix-rest-compat/src/yamlRestTestV7Compat/resources/rest-api-spec/api/xpack-sql.query.json new file mode 100644 index 0000000000000..d153e0f3484c3 --- /dev/null +++ b/x-pack/qa/xpack-prefix-rest-compat/src/yamlRestTestV7Compat/resources/rest-api-spec/api/xpack-sql.query.json @@ -0,0 +1,35 @@ +{ + "xpack-sql.query":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-search-api.html", + "description":"Executes a SQL request" + }, + "stability":"stable", + "visibility":"public", + "headers":{ + "accept": [ "application/vnd.elasticsearch+json;compatible-with=7"], + "content_type": ["application/vnd.elasticsearch+json;compatible-with=7"] + }, + "url":{ + "paths":[ + { + "path":"/_xpack/sql", + "methods":[ + "POST", + "GET" + ] + } + ] + }, + "params":{ + "format":{ + "type":"string", + "description":"a short version of the Accept header, e.g. json, yaml" + } + }, + "body":{ + "description":"Use the `query` element to start a query. Use the `cursor` element to continue a query.", + "required":true + } + } +} diff --git a/x-pack/qa/xpack-prefix-rest-compat/src/yamlRestTestV7Compat/resources/rest-api-spec/api/xpack-sql.translate.json b/x-pack/qa/xpack-prefix-rest-compat/src/yamlRestTestV7Compat/resources/rest-api-spec/api/xpack-sql.translate.json new file mode 100644 index 0000000000000..1fad4a643dbb9 --- /dev/null +++ b/x-pack/qa/xpack-prefix-rest-compat/src/yamlRestTestV7Compat/resources/rest-api-spec/api/xpack-sql.translate.json @@ -0,0 +1,30 @@ +{ + "xpack-sql.translate":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate-api.html", + "description":"Translates SQL into Elasticsearch queries" + }, + "stability":"stable", + "visibility":"public", + "headers":{ + "accept": [ "application/vnd.elasticsearch+json;compatible-with=7"], + "content_type": ["application/vnd.elasticsearch+json;compatible-with=7"] + }, + "url":{ + "paths":[ + { + "path":"/_xpack/sql/translate", + "methods":[ + "POST", + "GET" + ] + } + ] + }, + "params":{}, + "body":{ + "description":"Specify the query in the `query` element.", + "required":true + } + } +}