API generation
This commit is contained in:
@ -15,15 +15,21 @@ function buildIndicesGet (opts) {
|
||||
* @param {boolean} include_defaults - Whether to return all default setting for each of the indices.
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
return function indicesGet (params, callback) {
|
||||
return function indicesGet (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) => {
|
||||
indicesGet(params, (err, body) => {
|
||||
indicesGet(params, options, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
@ -101,7 +107,7 @@ function buildIndicesGet (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
@ -113,12 +119,17 @@ function buildIndicesGet (opts) {
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null
|
||||
headers: params.headers || null
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
const requestOptions = {
|
||||
ignore,
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user