API generation

This commit is contained in:
delvedor
2019-05-16 16:53:38 -04:00
parent 597dd28340
commit c922661fda
11 changed files with 122 additions and 22 deletions

View File

@ -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 = {

View File

@ -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',

View File

@ -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
@ -84,6 +85,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}`)
@ -91,7 +98,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) {
@ -105,7 +112,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'

View File

@ -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
@ -78,6 +79,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}`)
@ -85,7 +92,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) {
@ -99,7 +106,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'

View File

@ -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'

View File

@ -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 {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
@ -172,6 +173,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}`)
@ -179,7 +186,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) {
@ -193,7 +200,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'

View File

@ -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)
@ -97,6 +98,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}`)
@ -104,7 +111,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) {
@ -118,7 +125,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'

View File

@ -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.
@ -98,7 +99,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) {
@ -112,8 +113,12 @@ function buildTermvectors (opts) {
var path = ''
if ((index) != null && (id) != null) {
if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_termvectors'
} else 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

@ -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 = {

View File

@ -387,6 +387,7 @@ 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;
@ -958,6 +959,7 @@ 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;
@ -970,6 +972,7 @@ 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;
@ -980,6 +983,7 @@ 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;
@ -1091,6 +1095,7 @@ 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;
@ -1150,6 +1155,7 @@ 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;
@ -1254,6 +1260,7 @@ export interface TasksList extends Generic {
export interface Termvectors<T = any> extends Generic {
index: string;
type?: string;
id?: string;
term_statistics?: boolean;
field_statistics?: boolean;
@ -1293,6 +1300,7 @@ 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;

View File

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