From 30c3afe150366d6d5f2166e492cc4c2422c139bf Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 16 May 2019 16:54:53 -0400 Subject: [PATCH] API generation --- api/api/delete_by_query.js | 15 +++++++++++++-- api/api/get.js | 8 ++------ api/api/msearch.js | 13 +++++++++++-- api/api/msearch_template.js | 13 +++++++++++-- api/api/mtermvectors.js | 13 +++++++++++-- api/api/search.js | 13 +++++++++++-- api/api/search_template.js | 13 +++++++++++-- api/api/termvectors.js | 8 ++------ api/api/update_by_query.js | 15 +++++++++++++-- api/requestParams.d.ts | 34 +++++++--------------------------- docs/reference.asciidoc | 24 ++++++++++++++++++++++++ 11 files changed, 116 insertions(+), 53 deletions(-) diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 8450c1eb2..b6b5fc605 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -29,6 +29,7 @@ function buildDeleteByQuery (opts) { * Perform a [delete_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html) request * * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {string} analyzer - The analyzer to use for the query string * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) * @param {enum} default_operator - The default operator for query string query (AND or OR) @@ -150,6 +151,12 @@ function buildDeleteByQuery (opts) { return handleError(err, callback) } + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: index') + return handleError(err, callback) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -157,7 +164,7 @@ function buildDeleteByQuery (opts) { } var warnings = [] - var { method, body, index, ...querystring } = params + var { method, body, index, type, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -171,7 +178,11 @@ function buildDeleteByQuery (opts) { var path = '' - path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_delete_by_query' + } else { + path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query' + } // build request object const request = { diff --git a/api/api/get.js b/api/api/get.js index d650a11f1..1021a2d35 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -57,10 +57,8 @@ function buildGet (opts) { '_source_excludes', '_source_exclude', '_source_includes', -<<<<<<< HEAD + '_source_include', '_source_exclude', -======= ->>>>>>> 844206e... Patch deprecated parameters (#851) '_source_include', 'version', 'version_type', @@ -76,10 +74,8 @@ function buildGet (opts) { _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', -<<<<<<< HEAD + _sourceInclude: '_source_include', _sourceExclude: '_source_exclude', -======= ->>>>>>> 844206e... Patch deprecated parameters (#851) _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', diff --git a/api/api/msearch.js b/api/api/msearch.js index b15da767a..5ca1ebd34 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -29,6 +29,7 @@ function buildMsearch (opts) { * Perform a [msearch](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html) request * * @param {list} index - A comma-separated list of index names to use as default + * @param {list} type - A comma-separated list of document types to use as default * @param {enum} search_type - Search operation type * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response @@ -81,6 +82,12 @@ function buildMsearch (opts) { return handleError(err, callback) } + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: index') + return handleError(err, callback) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -88,7 +95,7 @@ function buildMsearch (opts) { } var warnings = [] - var { method, body, index, ...querystring } = params + var { method, body, index, type, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -102,7 +109,9 @@ function buildMsearch (opts) { var path = '' - if ((index) != null) { + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' + } else if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_msearch' } else { path = '/' + '_msearch' diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index fdcd14daf..54a499ddb 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -29,6 +29,7 @@ function buildMsearchTemplate (opts) { * Perform a [msearch_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) request * * @param {list} index - A comma-separated list of index names to use as default + * @param {list} type - A comma-separated list of document types to use as default * @param {enum} search_type - Search operation type * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute @@ -75,6 +76,12 @@ function buildMsearchTemplate (opts) { return handleError(err, callback) } + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: index') + return handleError(err, callback) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -82,7 +89,7 @@ function buildMsearchTemplate (opts) { } var warnings = [] - var { method, body, index, ...querystring } = params + var { method, body, index, type, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -96,7 +103,9 @@ function buildMsearchTemplate (opts) { var path = '' - if ((index) != null) { + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' + '/' + 'template' + } else if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_msearch' + '/' + 'template' } else { path = '/' + '_msearch' + '/' + 'template' diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index 4fee48798..92d14c93c 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -29,6 +29,7 @@ function buildMtermvectors (opts) { * Perform a [mtermvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html) request * * @param {string} index - The index in which the document resides. + * @param {string} type - The type of the document. * @param {list} ids - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body * @param {boolean} term_statistics - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". * @param {boolean} field_statistics - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". @@ -86,6 +87,12 @@ function buildMtermvectors (opts) { options = {} } + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: index') + return handleError(err, callback) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -93,7 +100,7 @@ function buildMtermvectors (opts) { } var warnings = [] - var { method, body, index, ...querystring } = params + var { method, body, index, type, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -107,7 +114,9 @@ function buildMtermvectors (opts) { var path = '' - if ((index) != null) { + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mtermvectors' + } else if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_mtermvectors' } else { path = '/' + '_mtermvectors' diff --git a/api/api/search.js b/api/api/search.js index 709bc6b40..6dc98d239 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -29,6 +29,7 @@ function buildSearch (opts) { * Perform a [search](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html) request * * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {string} analyzer - The analyzer to use for the query string * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) * @param {enum} default_operator - The default operator for query string query (AND or OR) @@ -169,6 +170,12 @@ function buildSearch (opts) { options = {} } + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: index') + return handleError(err, callback) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -176,7 +183,7 @@ function buildSearch (opts) { } var warnings = [] - var { method, body, index, ...querystring } = params + var { method, body, index, type, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -190,7 +197,9 @@ function buildSearch (opts) { var path = '' - if ((index) != null) { + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + } else if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_search' } else { path = '/' + '_search' diff --git a/api/api/search_template.js b/api/api/search_template.js index 03003de6f..02682fbf0 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -29,6 +29,7 @@ function buildSearchTemplate (opts) { * Perform a [search_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request * * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -94,6 +95,12 @@ function buildSearchTemplate (opts) { return handleError(err, callback) } + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: index') + return handleError(err, callback) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -101,7 +108,7 @@ function buildSearchTemplate (opts) { } var warnings = [] - var { method, body, index, ...querystring } = params + var { method, body, index, type, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -115,7 +122,9 @@ function buildSearchTemplate (opts) { var path = '' - if ((index) != null) { + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + '/' + 'template' + } else if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template' } else { path = '/' + '_search' + '/' + 'template' diff --git a/api/api/termvectors.js b/api/api/termvectors.js index c2b8b6c69..5dde2e86e 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -29,6 +29,7 @@ function buildTermvectors (opts) { * Perform a [termvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html) request * * @param {string} index - The index in which the document resides. + * @param {string} type - The type of the document. * @param {string} id - The id of the document, when not specified a doc param should be supplied. * @param {boolean} term_statistics - Specifies if total term frequency and document frequency should be returned. * @param {boolean} field_statistics - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. @@ -102,7 +103,7 @@ function buildTermvectors (opts) { } var warnings = [] - var { method, body, index, id, ...querystring } = params + var { method, body, index, type, id, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -116,13 +117,8 @@ function buildTermvectors (opts) { var path = '' -<<<<<<< HEAD if ((index) != null && (type) != null && (id) != null) { path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_termvectors' -======= - if ((index) != null && (id) != null) { - path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id) ->>>>>>> 844206e... Patch deprecated parameters (#851) } else { path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_termvectors' } diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 017262d33..0185a1ed5 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -29,6 +29,7 @@ function buildUpdateByQuery (opts) { * Perform a [update_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html) request * * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {string} analyzer - The analyzer to use for the query string * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) * @param {enum} default_operator - The default operator for query string query (AND or OR) @@ -151,6 +152,12 @@ function buildUpdateByQuery (opts) { return handleError(err, callback) } + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: index') + return handleError(err, callback) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -158,7 +165,7 @@ function buildUpdateByQuery (opts) { } var warnings = [] - var { method, body, index, ...querystring } = params + var { method, body, index, type, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -172,7 +179,11 @@ function buildUpdateByQuery (opts) { var path = '' - path = '/' + encodeURIComponent(index) + '/' + '_update_by_query' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_update_by_query' + } else { + path = '/' + encodeURIComponent(index) + '/' + '_update_by_query' + } // build request object const request = { diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index db7056f25..06ee058f0 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -388,6 +388,7 @@ export interface Delete extends Generic { export interface DeleteByQuery extends Generic { index: string | string[]; + type?: string | string[]; _source_exclude?: string | string[]; _source_include?: string | string[]; analyzer?: string; @@ -439,13 +440,9 @@ export interface DeleteScript extends Generic { export interface Exists extends Generic { id: string; index: string; -<<<<<<< HEAD type: string; -======= - type?: string; _source_exclude?: string | string[]; _source_include?: string | string[]; ->>>>>>> 844206e... Patch deprecated parameters (#851) stored_fields?: string | string[]; parent?: string; preference?: string; @@ -462,13 +459,9 @@ export interface Exists extends Generic { export interface ExistsSource extends Generic { id: string; index: string; -<<<<<<< HEAD type: string; -======= - type?: string; _source_exclude?: string | string[]; _source_include?: string | string[]; ->>>>>>> 844206e... Patch deprecated parameters (#851) parent?: string; preference?: string; realtime?: boolean; @@ -484,13 +477,9 @@ export interface ExistsSource extends Generic { export interface Explain extends Generic { id: string; index: string; -<<<<<<< HEAD type: string; -======= - type?: string; _source_exclude?: string | string[]; _source_include?: string | string[]; ->>>>>>> 844206e... Patch deprecated parameters (#851) analyze_wildcard?: boolean; analyzer?: string; default_operator?: 'AND' | 'OR'; @@ -519,13 +508,9 @@ export interface FieldCaps extends Generic { export interface Get extends Generic { id: string; index: string; -<<<<<<< HEAD type: string; -======= - type?: string; _source_exclude?: string | string[]; _source_include?: string | string[]; ->>>>>>> 844206e... Patch deprecated parameters (#851) stored_fields?: string | string[]; parent?: string; preference?: string; @@ -549,13 +534,9 @@ export interface GetScript extends Generic { export interface GetSource extends Generic { id: string; index: string; -<<<<<<< HEAD type: string; -======= - type?: string; _source_exclude?: string | string[]; _source_include?: string | string[]; ->>>>>>> 844206e... Patch deprecated parameters (#851) parent?: string; preference?: string; realtime?: boolean; @@ -984,6 +965,7 @@ export interface Mget extends Generic { export interface Msearch extends Generic { index?: string | string[]; + type?: string | string[]; search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; max_concurrent_searches?: number; typed_keys?: boolean; @@ -995,6 +977,7 @@ export interface Msearch extends Generic { export interface MsearchTemplate extends Generic { index?: string | string[]; + type?: string | string[]; search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; typed_keys?: boolean; max_concurrent_searches?: number; @@ -1004,6 +987,7 @@ export interface MsearchTemplate extends Generic { export interface Mtermvectors extends Generic { index?: string; + type?: string; ids?: string | string[]; term_statistics?: boolean; field_statistics?: boolean; @@ -1114,6 +1098,7 @@ export interface Scroll extends Generic { export interface Search extends Generic { index?: string | string[]; + type?: string | string[]; _source_exclude?: string | string[]; _source_include?: string | string[]; analyzer?: string; @@ -1172,6 +1157,7 @@ export interface SearchShards extends Generic { export interface SearchTemplate extends Generic { index?: string | string[]; + type?: string | string[]; ignore_unavailable?: boolean; ignore_throttled?: boolean; allow_no_indices?: boolean; @@ -1275,10 +1261,7 @@ export interface TasksList extends Generic { export interface Termvectors extends Generic { index: string; -<<<<<<< HEAD type: string; -======= ->>>>>>> 844206e... Patch deprecated parameters (#851) id?: string; term_statistics?: boolean; field_statistics?: boolean; @@ -1298,13 +1281,9 @@ export interface Termvectors extends Generic { export interface Update extends Generic { id: string; index: string; -<<<<<<< HEAD type: string; -======= - type?: string; _source_exclude?: string | string[]; _source_include?: string | string[]; ->>>>>>> 844206e... Patch deprecated parameters (#851) wait_for_active_shards?: string; fields?: string | string[]; _source?: string | string[]; @@ -1325,6 +1304,7 @@ export interface Update extends Generic { export interface UpdateByQuery extends Generic { index: string | string[]; + type?: string | string[]; _source_exclude?: string | string[]; _source_include?: string | string[]; analyzer?: string; diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 5a5befd48..bbbd7bd44 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -1156,6 +1156,9 @@ link:{ref}/docs-delete-by-query.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +|`type` +|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + |`analyzer` |`string` - The analyzer to use for the query string @@ -2933,6 +2936,9 @@ link:{ref}/search-multi-search.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to use as default +|`type` +|`string, string[]` - A comma-separated list of document types to use as default + |`search_type` or `searchType` |`'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch', 'dfs_query_and_fetch'` - Search operation type @@ -2969,6 +2975,9 @@ link:{ref}/search-multi-search.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to use as default +|`type` +|`string, string[]` - A comma-separated list of document types to use as default + |`search_type` or `searchType` |`'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch', 'dfs_query_and_fetch'` - Search operation type @@ -2997,6 +3006,9 @@ link:{ref}/docs-multi-termvectors.html[Reference] |`index` |`string` - The index in which the document resides. +|`type` +|`string` - The type of the document. + |`ids` |`string, string[]` - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body @@ -3354,6 +3366,9 @@ link:{ref}/search-search.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +|`type` +|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + |`analyzer` |`string` - The analyzer to use for the query string @@ -3532,6 +3547,9 @@ link:{ref}/search-template.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +|`type` +|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -3856,6 +3874,9 @@ link:{ref}/docs-termvectors.html[Reference] |`index` |`string` - The index in which the document resides. +|`type` +|`string` - The type of the document. + |`id` |`string` - The id of the document, when not specified a doc param should be supplied. @@ -3982,6 +4003,9 @@ link:{ref}/docs-update-by-query.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +|`type` +|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + |`analyzer` |`string` - The analyzer to use for the query string