Patch deprecated parameters (#851)

* Updated code generation

* API generation

* API generation

* Updated code generation
This commit is contained in:
Tomas Della Vedova
2019-05-16 16:52:15 -04:00
committed by delvedor
parent cc0dc10c64
commit 597dd28340
22 changed files with 132 additions and 127 deletions

View File

@ -50,7 +50,9 @@ function buildBulk (opts) {
'type',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'pipeline',
'pretty',
'human',
@ -62,7 +64,9 @@ function buildBulk (opts) {
const snakeCase = {
waitForActiveShards: 'wait_for_active_shards',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -29,7 +29,6 @@ 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)
@ -86,7 +85,9 @@ function buildDeleteByQuery (opts) {
'sort',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'terminate_after',
'stats',
'version',
@ -114,7 +115,9 @@ function buildDeleteByQuery (opts) {
searchType: 'search_type',
searchTimeout: 'search_timeout',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
terminateAfter: 'terminate_after',
requestCache: 'request_cache',
waitForActiveShards: 'wait_for_active_shards',
@ -147,12 +150,6 @@ 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}`)
@ -160,7 +157,7 @@ function buildDeleteByQuery (opts) {
}
var warnings = []
var { method, body, index, type, ...querystring } = params
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
@ -174,11 +171,7 @@ function buildDeleteByQuery (opts) {
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_delete_by_query'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query'
}
path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query'
// build request object
const request = {

View File

@ -53,7 +53,9 @@ function buildExists (opts) {
'routing',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'version',
'version_type',
'pretty',
@ -66,7 +68,9 @@ function buildExists (opts) {
const snakeCase = {
storedFields: 'stored_fields',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
versionType: 'version_type',
errorTrace: 'error_trace',
filterPath: 'filter_path'

View File

@ -51,7 +51,9 @@ function buildExistsSource (opts) {
'routing',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'version',
'version_type',
'pretty',
@ -63,7 +65,9 @@ function buildExistsSource (opts) {
const snakeCase = {
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
versionType: 'version_type',
errorTrace: 'error_trace',
filterPath: 'filter_path'

View File

@ -60,7 +60,9 @@ function buildExplain (opts) {
'routing',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'pretty',
'human',
'error_trace',
@ -73,7 +75,9 @@ function buildExplain (opts) {
defaultOperator: 'default_operator',
storedFields: 'stored_fields',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -55,8 +55,12 @@ function buildGet (opts) {
'routing',
'_source',
'_source_excludes',
'_source_includes',
'_source_exclude',
'_source_includes',
<<<<<<< HEAD
'_source_exclude',
=======
>>>>>>> 844206e... Patch deprecated parameters (#851)
'_source_include',
'version',
'version_type',
@ -70,8 +74,12 @@ function buildGet (opts) {
const snakeCase = {
storedFields: 'stored_fields',
_sourceExcludes: '_source_excludes',
_sourceIncludes: '_source_includes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
<<<<<<< HEAD
_sourceExclude: '_source_exclude',
=======
>>>>>>> 844206e... Patch deprecated parameters (#851)
_sourceInclude: '_source_include',
versionType: 'version_type',
errorTrace: 'error_trace',

View File

@ -51,7 +51,9 @@ function buildGetSource (opts) {
'routing',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'version',
'version_type',
'pretty',
@ -63,7 +65,9 @@ function buildGetSource (opts) {
const snakeCase = {
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
versionType: 'version_type',
errorTrace: 'error_trace',
filterPath: 'filter_path'

View File

@ -49,7 +49,9 @@ function buildMget (opts) {
'routing',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'pretty',
'human',
'error_trace',
@ -60,7 +62,9 @@ function buildMget (opts) {
const snakeCase = {
storedFields: 'stored_fields',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -29,7 +29,6 @@ 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
@ -85,12 +84,6 @@ 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}`)
@ -98,7 +91,7 @@ function buildMsearch (opts) {
}
var warnings = []
var { method, body, index, type, ...querystring } = params
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
@ -112,9 +105,7 @@ function buildMsearch (opts) {
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch'
} else if ((index) != null) {
if ((index) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_msearch'
} else {
path = '/' + '_msearch'

View File

@ -29,7 +29,6 @@ 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
@ -79,12 +78,6 @@ 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}`)
@ -92,7 +85,7 @@ function buildMsearchTemplate (opts) {
}
var warnings = []
var { method, body, index, type, ...querystring } = params
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
@ -106,9 +99,7 @@ function buildMsearchTemplate (opts) {
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' + '/' + 'template'
} else if ((index) != null) {
if ((index) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_msearch' + '/' + 'template'
} else {
path = '/' + '_msearch' + '/' + 'template'

View File

@ -29,7 +29,6 @@ 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".
@ -87,12 +86,6 @@ 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}`)
@ -100,7 +93,7 @@ function buildMtermvectors (opts) {
}
var warnings = []
var { method, body, index, type, ...querystring } = params
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
@ -114,9 +107,7 @@ function buildMtermvectors (opts) {
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mtermvectors'
} else if ((index) != null) {
if ((index) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_mtermvectors'
} else {
path = '/' + '_mtermvectors'

View File

@ -29,7 +29,6 @@ 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 {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
@ -99,7 +98,9 @@ function buildSearch (opts) {
'sort',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'terminate_after',
'stats',
'suggest_field',
@ -137,7 +138,9 @@ function buildSearch (opts) {
expandWildcards: 'expand_wildcards',
searchType: 'search_type',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
terminateAfter: 'terminate_after',
suggestField: 'suggest_field',
suggestMode: 'suggest_mode',
@ -169,12 +172,6 @@ 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}`)
@ -182,7 +179,7 @@ function buildSearch (opts) {
}
var warnings = []
var { method, body, index, type, ...querystring } = params
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
@ -196,9 +193,7 @@ function buildSearch (opts) {
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search'
} else if ((index) != null) {
if ((index) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_search'
} else {
path = '/' + '_search'

View File

@ -29,7 +29,6 @@ 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)
@ -98,12 +97,6 @@ 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}`)
@ -111,7 +104,7 @@ function buildSearchTemplate (opts) {
}
var warnings = []
var { method, body, index, type, ...querystring } = params
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
@ -125,9 +118,7 @@ function buildSearchTemplate (opts) {
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + '/' + 'template'
} else if ((index) != null) {
if ((index) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template'
} else {
path = '/' + '_search' + '/' + 'template'

View File

@ -29,7 +29,6 @@ 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.
@ -99,7 +98,7 @@ function buildTermvectors (opts) {
}
var warnings = []
var { method, body, index, type, id, ...querystring } = params
var { method, body, index, id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
@ -113,12 +112,8 @@ function buildTermvectors (opts) {
var path = ''
if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_termvectors'
} else if ((index) != null && (id) != null) {
if ((index) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id)
} else if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_termvectors'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_termvectors'
}

View File

@ -50,7 +50,9 @@ function buildUpdate (opts) {
'wait_for_active_shards',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'lang',
'parent',
'refresh',
@ -69,7 +71,9 @@ function buildUpdate (opts) {
const snakeCase = {
waitForActiveShards: 'wait_for_active_shards',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
retryOnConflict: 'retry_on_conflict',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',

View File

@ -29,7 +29,6 @@ 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)
@ -89,7 +88,9 @@ function buildUpdateByQuery (opts) {
'sort',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'terminate_after',
'stats',
'version',
@ -118,7 +119,9 @@ function buildUpdateByQuery (opts) {
searchType: 'search_type',
searchTimeout: 'search_timeout',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
terminateAfter: 'terminate_after',
versionType: 'version_type',
requestCache: 'request_cache',
@ -148,12 +151,6 @@ 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}`)
@ -161,7 +158,7 @@ function buildUpdateByQuery (opts) {
}
var warnings = []
var { method, body, index, type, ...querystring } = params
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
@ -175,11 +172,7 @@ function buildUpdateByQuery (opts) {
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_update_by_query'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_update_by_query'
}
path = '/' + encodeURIComponent(index) + '/' + '_update_by_query'
// build request object
const request = {

View File

@ -30,6 +30,8 @@ export interface Generic {
export interface Bulk<T = any> extends Generic {
index?: string;
type?: string;
_source_exclude?: string | string[];
_source_include?: string | string[];
wait_for_active_shards?: string;
refresh?: 'true' | 'false' | 'wait_for';
routing?: string;
@ -385,7 +387,8 @@ export interface Delete extends Generic {
export interface DeleteByQuery<T = any> extends Generic {
index: string | string[];
type?: string | string[];
_source_exclude?: string | string[];
_source_include?: string | string[];
analyzer?: string;
analyze_wildcard?: boolean;
default_operator?: 'AND' | 'OR';
@ -436,6 +439,8 @@ export interface Exists extends Generic {
id: string;
index: string;
type?: string;
_source_exclude?: string | string[];
_source_include?: string | string[];
stored_fields?: string | string[];
parent?: string;
preference?: string;
@ -453,6 +458,8 @@ export interface ExistsSource extends Generic {
id: string;
index: string;
type?: string;
_source_exclude?: string | string[];
_source_include?: string | string[];
parent?: string;
preference?: string;
realtime?: boolean;
@ -469,6 +476,8 @@ export interface Explain<T = any> extends Generic {
id: string;
index: string;
type?: string;
_source_exclude?: string | string[];
_source_include?: string | string[];
analyze_wildcard?: boolean;
analyzer?: string;
default_operator?: 'AND' | 'OR';
@ -497,6 +506,8 @@ export interface Get extends Generic {
id: string;
index: string;
type?: string;
_source_exclude?: string | string[];
_source_include?: string | string[];
stored_fields?: string | string[];
parent?: string;
preference?: string;
@ -521,6 +532,8 @@ export interface GetSource extends Generic {
id: string;
index: string;
type?: string;
_source_exclude?: string | string[];
_source_include?: string | string[];
parent?: string;
preference?: string;
realtime?: boolean;
@ -930,6 +943,8 @@ export interface IngestSimulate<T = any> extends Generic {
export interface Mget<T = any> extends Generic {
index?: string;
type?: string;
_source_exclude?: string | string[];
_source_include?: string | string[];
stored_fields?: string | string[];
preference?: string;
realtime?: boolean;
@ -943,7 +958,6 @@ export interface Mget<T = any> extends Generic {
export interface Msearch<T = any> 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;
@ -956,7 +970,6 @@ export interface Msearch<T = any> extends Generic {
export interface MsearchTemplate<T = any> 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;
@ -967,7 +980,6 @@ export interface MsearchTemplate<T = any> extends Generic {
export interface Mtermvectors<T = any> extends Generic {
index?: string;
type?: string;
ids?: string | string[];
term_statistics?: boolean;
field_statistics?: boolean;
@ -1079,7 +1091,8 @@ export interface Scroll<T = any> extends Generic {
export interface Search<T = any> extends Generic {
index?: string | string[];
type?: string | string[];
_source_exclude?: string | string[];
_source_include?: string | string[];
analyzer?: string;
analyze_wildcard?: boolean;
ccs_minimize_roundtrips?: boolean;
@ -1137,7 +1150,6 @@ export interface SearchShards extends Generic {
export interface SearchTemplate<T = any> extends Generic {
index?: string | string[];
type?: string | string[];
ignore_unavailable?: boolean;
ignore_throttled?: boolean;
allow_no_indices?: boolean;
@ -1242,7 +1254,6 @@ export interface TasksList extends Generic {
export interface Termvectors<T = any> extends Generic {
index: string;
type?: string;
id?: string;
term_statistics?: boolean;
field_statistics?: boolean;
@ -1263,6 +1274,8 @@ export interface Update<T = any> extends Generic {
id: string;
index: string;
type?: string;
_source_exclude?: string | string[];
_source_include?: string | string[];
wait_for_active_shards?: string;
_source?: string | string[];
_source_excludes?: string | string[];
@ -1280,7 +1293,8 @@ export interface Update<T = any> extends Generic {
export interface UpdateByQuery<T = any> extends Generic {
index: string | string[];
type?: string | string[];
_source_exclude?: string | string[];
_source_include?: string | string[];
analyzer?: string;
analyze_wildcard?: boolean;
default_operator?: 'AND' | 'OR';

View File

@ -1153,9 +1153,6 @@ 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
@ -2918,9 +2915,6 @@ 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
@ -2961,9 +2955,6 @@ 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
@ -2996,9 +2987,6 @@ 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
@ -3360,9 +3348,6 @@ 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
@ -3545,9 +3530,6 @@ 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)
@ -3876,9 +3858,6 @@ 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.
@ -3996,9 +3975,6 @@ 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

View File

@ -69,7 +69,7 @@ function start (opts) {
writeFileSync(
requestParamsOutputFile,
generateRequestTypes(allSpec),
generateRequestTypes(opts.branch || opts.tag, allSpec),
{ encoding: 'utf8' }
)
@ -113,7 +113,7 @@ function start (opts) {
const spec = require(join(apiFolder, file))
allSpec.push(spec)
const code = generate(spec, common)
const code = generate(opts.branch || opts.tag, spec, common)
const filePath = join(apiOutputFolder, `${file.slice(0, file.lastIndexOf('.'))}.js`)
writeFileSync(filePath, code, { encoding: 'utf8' })

View File

@ -22,11 +22,16 @@
'use strict'
const dedent = require('dedent')
const semver = require('semver')
const allowedMethods = {
noBody: ['GET', 'HEAD', 'DELETE'],
body: ['POST', 'PUT', 'DELETE']
}
// if a parameter is depracted in a minor release
// we should be able to support it until the next major
const deprecatedParameters = require('./patch.json')
// list of apis that does not need any kind of validation
// because of how the url is built or the `type` handling in ES7
const noPathValidation = [
@ -63,7 +68,8 @@ const ndjsonApi = [
'xpack.monitoring.bulk'
]
function generate (spec, common) {
function generate (version, spec, common) {
const release = semver.valid(version) ? semver.major(version) : version
const api = Object.keys(spec)[0]
const name = api
.replace(/\.([a-z])/g, k => k[1].toUpperCase())
@ -90,7 +96,11 @@ function generate (spec, common) {
if (params[key].required) {
required.push(key)
}
acceptedQuerystring.push(key)
if (deprecatedParameters[release] && deprecatedParameters[release][key]) {
acceptedQuerystring.push(deprecatedParameters[release][key])
}
}
for (const key in spec[api]) {

View File

@ -19,7 +19,11 @@
'use strict'
function generate (api) {
const semver = require('semver')
const deprecatedParameters = require('./patch.json')
function generate (version, api) {
const release = semver.valid(version) ? semver.major(version) : version
var types = `/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
@ -64,9 +68,20 @@ export interface Generic {
const partsArr = Object.keys(parts)
.map(k => ({ key: k, value: parts[k] }))
const deprecatedParametersToAdd = []
const paramsArr = Object.keys(params)
.filter(k => !Object.keys(parts).includes(k))
.map(k => ({ key: k, value: params[k] }))
.map(k => {
if (deprecatedParameters[release] && deprecatedParameters[release][k]) {
deprecatedParametersToAdd.push({
key: deprecatedParameters[release][k],
value: params[k]
})
}
return { key: k, value: params[k] }
})
deprecatedParametersToAdd.forEach(k => partsArr.push(k))
const genLine = e => {
const optional = e.value.required ? '' : '?'

14
scripts/utils/patch.json Normal file
View File

@ -0,0 +1,14 @@
{
"6": {
"_source_includes": "_source_include",
"_source_excludes": "_source_exclude"
},
"7": {
"_source_includes": "_source_include",
"_source_excludes": "_source_exclude"
},
"master": {
"_source_includes": "_source_include",
"_source_excludes": "_source_exclude"
}
}