SQL: switch from _sql/ endpoint to _xpack/sql endpoint (elastic/x-pack-elasticsearch#3270)

As a part of xpack, SQL should use _xpack/sql endpoint instead of _sql endpoint.

relates elastic/x-pack-elasticsearch#3114

Original commit: elastic/x-pack-elasticsearch@f561b57f16
This commit is contained in:
Igor Motov 2017-12-08 12:17:26 -05:00 committed by GitHub
parent 432f10e736
commit b72a9b5674
17 changed files with 25 additions and 25 deletions

View File

@ -8,7 +8,7 @@ and returns the results. For example:
[source,js]
--------------------------------------------------
POST /_sql
POST /_xpack/sql
{
"query": "SELECT * FROM library ORDER BY page_count DESC LIMIT 5"
}
@ -43,7 +43,7 @@ All formats above are supported, the GET parameter takes precedence over the hea
[source,js]
--------------------------------------------------
POST /_sql?format=json
POST /_xpack/sql?format=json
{
"query": "SELECT * FROM library ORDER BY page_count DESC",
"fetch_size": 5
@ -81,7 +81,7 @@ case of text format the cursor is returned as `Cursor` http header.
[source,js]
--------------------------------------------------
POST /_sql?format=json
POST /_xpack/sql?format=json
{
"cursor": "sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8="
}
@ -125,7 +125,7 @@ parameter.
[source,js]
--------------------------------------------------
POST /_sql
POST /_xpack/sql
{
"query": "SELECT * FROM library ORDER BY page_count DESC",
"filter": {

View File

@ -7,7 +7,7 @@ into native Elasticsearch queries. For example:
[source,js]
--------------------------------------------------
POST /_sql/translate
POST /_xpack/sql/translate
{
"query": "SELECT * FROM library ORDER BY page_count DESC",
"fetch_size": 10

View File

@ -181,7 +181,7 @@ public class SqlLicenseIT extends AbstractLicensesIntegrationTestCase {
}
// Execute
InputStream response = getRestClient().performRequest("POST", "/_sql/jdbc", emptyMap(), entity).getEntity().getContent();
InputStream response = getRestClient().performRequest("POST", "/_xpack/sql/jdbc", emptyMap(), entity).getEntity().getContent();
// Deserialize bytes to response like JDBC does
try {

View File

@ -3,8 +3,8 @@
"documentation": "Execute SQL",
"methods": [ "POST", "GET" ],
"url": {
"path": "/_sql",
"paths": [ "/_sql" ],
"path": "/_xpack/sql",
"paths": [ "/_xpack/sql" ],
"parts": {},
"params": {
"format": {

View File

@ -3,8 +3,8 @@
"documentation": "Translate SQL into Elasticsearch queries",
"methods": [ "POST", "GET" ],
"url": {
"path": "/_sql/translate",
"paths": [ "/_sql/translate" ],
"path": "/_xpack/sql/translate",
"paths": [ "/_xpack/sql/translate" ],
"parts": {},
"params": {}
},

View File

@ -287,7 +287,7 @@ public class FullClusterRestartIT extends ESRestTestCase {
new StringEntity("{}", ContentType.APPLICATION_JSON));
return;
}
ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest("POST", "/_sql", emptyMap(),
ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest("POST", "/_xpack/sql", emptyMap(),
new StringEntity("{\"query\":\"SELECT * FROM testsqlfailsonindexwithtwotypes\"}", ContentType.APPLICATION_JSON)));
assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
assertThat(e.getMessage(), containsString("Invalid index testsqlfailsonindexwithtwotypes; contains more than one type"));

View File

@ -104,7 +104,7 @@ public class RestSqlMultinodeIT extends ESRestTestCase {
expected.put("rows", singletonList(singletonList(count)));
expected.put("size", 1);
Map<String, Object> actual = responseToMap(client.performRequest("POST", "/_sql", singletonMap("format", "json"),
Map<String, Object> actual = responseToMap(client.performRequest("POST", "/_xpack/sql", singletonMap("format", "json"),
new StringEntity("{\"query\": \"SELECT COUNT(*) FROM test\"}", ContentType.APPLICATION_JSON)));
if (false == expected.equals(actual)) {

View File

@ -135,7 +135,7 @@ public class RestSqlSecurityIT extends SqlSecurityTestCase {
private static Map<String, Object> runSql(@Nullable String asUser, HttpEntity entity) throws IOException {
Header[] headers = asUser == null ? new Header[0] : new Header[] {new BasicHeader("es-security-runas-user", asUser)};
Response response = client().performRequest("POST", "/_sql", singletonMap("format", "json"), entity, headers);
Response response = client().performRequest("POST", "/_xpack/sql", singletonMap("format", "json"), entity, headers);
return toMap(response);
}

View File

@ -12,7 +12,7 @@ import org.elasticsearch.client.Client;
*/
public class CliHttpServer extends ProtoHttpServer {
public CliHttpServer(Client client) {
super(client, new CliProtoHandler(client), "/_sql/cli");
super(client, new CliProtoHandler(client), "/_xpack/sql/cli");
}
@Override

View File

@ -13,7 +13,7 @@ import org.elasticsearch.client.Client;
public class JdbcHttpServer extends ProtoHttpServer {
public JdbcHttpServer(Client client) {
super(client, new JdbcProtoHandler(client), "/_sql/jdbc");
super(client, new JdbcProtoHandler(client), "/_xpack/sql/jdbc");
}
@Override

View File

@ -182,7 +182,7 @@ public abstract class RestSqlTestCase extends ESRestTestCase implements ErrorsTe
params.put("error_trace", "true"); // Helps with debugging in case something crazy happens on the server.
params.put("pretty", "true"); // Improves error reporting readability
params.put("format", "json"); // JSON is easier to parse then a table
Response response = client().performRequest("POST", "/_sql" + suffix, params, sql);
Response response = client().performRequest("POST", "/_xpack/sql" + suffix, params, sql);
try (InputStream content = response.getEntity().getContent()) {
return XContentHelper.convertToMap(JsonXContent.jsonXContent, content, false);
}
@ -325,7 +325,7 @@ public abstract class RestSqlTestCase extends ESRestTestCase implements ErrorsTe
}
private Tuple<String, String> runSqlAsText(String suffix, HttpEntity sql) throws IOException {
Response response = client().performRequest("POST", "/_sql" + suffix, singletonMap("error_trace", "true"), sql);
Response response = client().performRequest("POST", "/_xpack/sql" + suffix, singletonMap("error_trace", "true"), sql);
return new Tuple<>(
Streams.copyToString(new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8)),
response.getHeader("Cursor")

View File

@ -54,7 +54,7 @@ public class CliHttpClient {
private Response post(Request request) throws SQLException {
return AccessController.doPrivileged((PrivilegedAction<ResponseOrException<Response>>) () ->
JreHttpUrlConnection.http("_sql/cli", "error_trace", cfg, con ->
JreHttpUrlConnection.http("_xpack/sql/cli", "error_trace", cfg, con ->
con.post(
out -> Proto.INSTANCE.writeRequest(request, out),
in -> Proto.INSTANCE.readResponse(request, in)

View File

@ -49,7 +49,7 @@ class HttpClient {
Response post(Request request) throws SQLException {
try {
return AccessController.doPrivileged((PrivilegedAction<ResponseOrException<Response>>) () ->
JreHttpUrlConnection.http("_sql/jdbc", "error_trace", cfg, con ->
JreHttpUrlConnection.http("_xpack/sql/jdbc", "error_trace", cfg, con ->
con.post(
out -> Proto.INSTANCE.writeRequest(request, out),
in -> Proto.INSTANCE.readResponse(request, in)

View File

@ -34,7 +34,7 @@ import static org.elasticsearch.rest.RestRequest.Method.POST;
public class RestSqlCliAction extends AbstractSqlProtocolRestAction {
public RestSqlCliAction(Settings settings, RestController controller) {
super(settings, Proto.INSTANCE);
controller.registerHandler(POST, "/_sql/cli", this);
controller.registerHandler(POST, "/_xpack/sql/cli", this);
}
@Override

View File

@ -58,7 +58,7 @@ public class RestSqlJdbcAction extends AbstractSqlProtocolRestAction {
public RestSqlJdbcAction(Settings settings, RestController controller, SqlLicenseChecker sqlLicenseChecker,
IndexResolver indexResolver) {
super(settings, Proto.INSTANCE);
controller.registerHandler(POST, "/_sql/jdbc", this);
controller.registerHandler(POST, "/_xpack/sql/jdbc", this);
this.sqlLicenseChecker = sqlLicenseChecker;
this.indexResolver = indexResolver;
}

View File

@ -197,8 +197,8 @@ public class SqlTranslateAction
public static class RestAction extends BaseRestHandler {
public RestAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(GET, "/_sql/translate", this);
controller.registerHandler(POST, "/_sql/translate", this);
controller.registerHandler(GET, "/_xpack/sql/translate", this);
controller.registerHandler(POST, "/_xpack/sql/translate", this);
}
@Override

View File

@ -34,8 +34,8 @@ import static org.elasticsearch.rest.RestRequest.Method.POST;
public class RestSqlAction extends BaseRestHandler {
public RestSqlAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(GET, "/_sql", this);
controller.registerHandler(POST, "/_sql", this);
controller.registerHandler(GET, "/_xpack/sql", this);
controller.registerHandler(POST, "/_xpack/sql", this);
}
@Override