Files
elasticsearch-js/api/api/cat.recovery.js
Tomas Della Vedova 7acd2e3b07 Elasticsearch 7 support 🚀 (#760)
* API generation

* Updated typings

* Updated code generation

* Updated test

* Updated ci configuration

* Fixed test
2019-01-29 12:10:20 +01:00

138 lines
3.6 KiB
JavaScript

'use strict'
function buildCatRecovery (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, result } = opts
/**
* Perform a [cat.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html) request
*
* @param {list} index - A comma-separated list of index names to limit the returned information
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {enum} bytes - The unit in which to display byte values
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
return function catRecovery (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// promises support
if (callback == null) {
return new Promise((resolve, reject) => {
catRecovery(params, options, (err, body) => {
err ? reject(err) : resolve(body)
})
})
}
// check required parameters
if (params.body != null) {
return callback(
new ConfigurationError('This API does not require a body'),
result
)
}
// build querystring object
const querystring = {}
const keys = Object.keys(params)
const acceptedQuerystring = [
'format',
'bytes',
'master_timeout',
'h',
'help',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const acceptedQuerystringCamelCased = [
'format',
'bytes',
'masterTimeout',
'h',
'help',
's',
'v',
'pretty',
'human',
'errorTrace',
'source',
'filterPath'
]
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (acceptedQuerystring.indexOf(key) !== -1) {
querystring[key] = params[key]
} else {
var camelIndex = acceptedQuerystringCamelCased.indexOf(key)
if (camelIndex !== -1) {
querystring[acceptedQuerystring[camelIndex]] = params[key]
}
}
}
// configure http method
var method = params.method
if (method == null) {
method = 'GET'
}
// validate headers object
if (params.headers != null && typeof params.headers !== 'object') {
return callback(
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
result
)
}
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
var path = ''
if ((params['index']) != null) {
path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(params['index'])
} else {
path = '/' + '_cat' + '/' + 'recovery'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null
}
return makeRequest(request, requestOptions, callback)
}
}
module.exports = buildCatRecovery