API generation

This commit is contained in:
delvedor
2019-05-16 16:54:53 -04:00
parent 0efa0df934
commit 30c3afe150
11 changed files with 116 additions and 53 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
@ -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'

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

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

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

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

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

@ -388,6 +388,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;
@ -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<T = any> 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<T = any> 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<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;
@ -995,6 +977,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;
@ -1004,6 +987,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;
@ -1114,6 +1098,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;
@ -1172,6 +1157,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;
@ -1275,10 +1261,7 @@ export interface TasksList extends Generic {
export interface Termvectors<T = any> 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<T = any> extends Generic {
export interface Update<T = any> 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<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

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