API generation
This commit is contained in:
@ -13,15 +13,21 @@ function buildFieldCaps (opts) {
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {object} body - Field json objects containing an array of field names
|
||||
*/
|
||||
return function fieldCaps (params, callback) {
|
||||
return function fieldCaps (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) => {
|
||||
fieldCaps(params, (err, body) => {
|
||||
fieldCaps(params, options, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
@ -79,7 +85,7 @@ function buildFieldCaps (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
@ -91,12 +97,17 @@ function buildFieldCaps (opts) {
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
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