From 050c4d4c890699c4b84790cc5d6b78a5581843ee Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Sun, 2 Feb 2020 15:28:08 +0100 Subject: [PATCH] Fixes for the REST specification (#51791) * REST: Test: Fix the `accept_enterprise` parameter for Get License API (#51527) The Get License API specifies the `accept_enterprise` parameter as a `boolean`: https://github.com/elastic/elasticsearch/blob/0ca5cb8cb636a4be9c36b8e38e565af66abc423b/x-pack/plugin/src/test/resources/rest-api-spec/api/license.get.json#L22-L27 In the test, a `string` is passed however, which makes the test compilation fail in the Go client. (cherry picked from commit e2a2169b3d44592057c143253bb56375ed3e4268) * Fix the SQL API documentation in REST specification (#51534) This patch fixes the SQL REST API documentation to conform to the current schema. (cherry picked from commit c8b6a849852699883086a6ada42279f2f68d7e07) * Fix the "slices" parameter for the Delete By Query API in the REST specification (#51535) This patch updates the `type` parameter in the Delete By Query API: according to [the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html#docs-delete-by-query-slice), it can be set to "auto", but the type in the documentation allows only numerical values. This prevents people from setting the parameter to "auto" eg. in the Go client, which generates source from the specification, and sets the corresponding Go type as number. The patch uses the `|` notation, which we have discussed previously for encoding a "polymorphic" parameter like this. Related: https://github.com/elastic/go-elasticsearch/issues/77 * Fix the Enrich API documentation in REST specification (#51528) This patch fixes the REST API documentation for the Enrich APIs to conform to the current schema. (cherry picked from commit 59f28f4f2feeba3f6d2f0b632410577eacb28121) --- .../src/main/resources/rest-api-spec/api/delete_by_query.json | 4 ++-- .../resources/rest-api-spec/api/enrich.delete_policy.json | 4 +++- .../resources/rest-api-spec/api/enrich.execute_policy.json | 4 +++- .../test/resources/rest-api-spec/api/enrich.get_policy.json | 4 +++- .../test/resources/rest-api-spec/api/enrich.put_policy.json | 4 +++- .../src/test/resources/rest-api-spec/api/enrich.stats.json | 4 +++- .../test/resources/rest-api-spec/api/sql.clear_cursor.json | 3 ++- .../src/test/resources/rest-api-spec/api/sql.query.json | 3 ++- .../src/test/resources/rest-api-spec/api/sql.translate.json | 3 ++- .../rest-api-spec/test/license/30_enterprise_license.yml | 4 ++-- 10 files changed, 25 insertions(+), 12 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/delete_by_query.json b/rest-api-spec/src/main/resources/rest-api-spec/api/delete_by_query.json index 314f27d9a801c..07b55b83f8852 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/delete_by_query.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/delete_by_query.json @@ -178,9 +178,9 @@ "description": "The throttle for this request in sub-requests per second. -1 means no throttle." }, "slices": { - "type": "number", + "type": "number|auto", "default": 1, - "description": "The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks." + "description": "The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks." } }, "body":{ diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.delete_policy.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.delete_policy.json index a775ca28798a2..2d4fd1a7baf27 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.delete_policy.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.delete_policy.json @@ -1,6 +1,8 @@ { "enrich.delete_policy": { - "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-delete-policy.html", + "documentation": { + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-enrich-policy-api.html" + }, "stability" : "stable", "url": { "paths": [ diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.execute_policy.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.execute_policy.json index b49486a062036..90413423a9dc0 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.execute_policy.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.execute_policy.json @@ -1,6 +1,8 @@ { "enrich.execute_policy": { - "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-execute-policy.html", + "documentation": { + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/execute-enrich-policy-api.html" + }, "stability" : "stable", "url": { "paths": [ diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.get_policy.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.get_policy.json index 685c24ea228b2..dc2ab9d9e9c92 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.get_policy.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.get_policy.json @@ -1,6 +1,8 @@ { "enrich.get_policy": { - "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-get-policy.html", + "documentation": { + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/get-enrich-policy-api.html" + }, "stability" : "stable", "url": { "paths": [ diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.put_policy.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.put_policy.json index 7a1c02f92b95d..c23bec02ab0a0 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.put_policy.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.put_policy.json @@ -1,6 +1,8 @@ { "enrich.put_policy": { - "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-put-policy.html", + "documentation": { + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/put-enrich-policy-api.html" + }, "stability" : "stable", "url": { "paths": [ diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.stats.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.stats.json index 0dda96d81facf..69175d5563475 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.stats.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/enrich.stats.json @@ -1,6 +1,8 @@ { "enrich.stats": { - "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats.html", + "documentation": { + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats-api.html" + }, "stability" : "stable", "url": { "paths": [ diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.clear_cursor.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.clear_cursor.json index 392b24b218741..7cef02fb88741 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.clear_cursor.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.clear_cursor.json @@ -1,7 +1,8 @@ { "sql.clear_cursor":{ "documentation":{ - "url":"Clear SQL cursor" + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-pagination.html", + "description":"Clears the SQL cursor" }, "stability":"stable", "url":{ diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.query.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.query.json index 0fe518b520546..1c32b7b5b2852 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.query.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.query.json @@ -1,7 +1,8 @@ { "sql.query":{ "documentation":{ - "url":"Execute SQL" + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-rest-overview.html", + "description":"Executes an SQL request" }, "stability":"stable", "url":{ diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.translate.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.translate.json index 30920a3e4a326..37a66bd25c98a 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.translate.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/sql.translate.json @@ -1,7 +1,8 @@ { "sql.translate":{ "documentation":{ - "url":"Translate SQL into Elasticsearch queries" + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate.html", + "description":"Translates SQL into Elasticsearch queries" }, "stability":"stable", "url":{ diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/license/30_enterprise_license.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/license/30_enterprise_license.yml index 09a222880d2fe..1d2470b5c4bd6 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/license/30_enterprise_license.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/license/30_enterprise_license.yml @@ -29,7 +29,7 @@ teardown: - do: license.get: - accept_enterprise: "true" + accept_enterprise: true ## a v5 license object has 12 attributes - length: { license: 12 } @@ -41,7 +41,7 @@ teardown: - do: license.get: - accept_enterprise: "false" + accept_enterprise: false ## a v4 license object has 11 attributes - length: { license: 11 }