Unknown parameters handling (#761)
This commit is contained in:
committed by
GitHub
parent
7acd2e3b07
commit
23cfe11e44
124
api/api/bulk.js
124
api/api/bulk.js
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildBulk (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -19,6 +22,32 @@ function buildBulk (opts) {
|
||||
* @param {string} pipeline - The pipeline id to preprocess incoming documents with
|
||||
* @param {object} body - The operation definition and data (action-data pairs), separated by newlines
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'wait_for_active_shards',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'type',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'pipeline',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
_sourceExcludes: '_source_excludes',
|
||||
_sourceIncludes: '_source_includes',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function bulk (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -55,68 +84,22 @@ function buildBulk (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'wait_for_active_shards',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'type',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'pipeline',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'waitForActiveShards',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'type',
|
||||
'_source',
|
||||
'_sourceExcludes',
|
||||
'_sourceIncludes',
|
||||
'pipeline',
|
||||
'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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -124,10 +107,10 @@ function buildBulk (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_bulk'
|
||||
} else if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_bulk'
|
||||
if ((index) != null && (type) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_bulk'
|
||||
} else if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_bulk'
|
||||
} else {
|
||||
path = '/' + '_bulk'
|
||||
}
|
||||
@ -136,7 +119,7 @@ function buildBulk (opts) {
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
bulkBody: params.body,
|
||||
bulkBody: body,
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -145,10 +128,27 @@ function buildBulk (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatAliases (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -15,6 +18,28 @@ function buildCatAliases (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catAliases (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,64 +68,22 @@ function buildCatAliases (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -108,8 +91,8 @@ function buildCatAliases (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['name']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(params['name'])
|
||||
if ((name) != null) {
|
||||
path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(name)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'aliases'
|
||||
}
|
||||
@ -127,10 +110,27 @@ function buildCatAliases (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatAllocation (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -16,6 +19,29 @@ function buildCatAllocation (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catAllocation (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,66 +70,22 @@ function buildCatAllocation (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, nodeId, node_id } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -111,8 +93,8 @@ function buildCatAllocation (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['node_id'] || params['nodeId']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(params['node_id'] || params['nodeId'])
|
||||
if ((node_id || nodeId) != null) {
|
||||
path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(node_id || nodeId)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'allocation'
|
||||
}
|
||||
@ -130,10 +112,27 @@ function buildCatAllocation (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatCount (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -15,6 +18,28 @@ function buildCatCount (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catCount (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,64 +68,22 @@ function buildCatCount (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -108,8 +91,8 @@ function buildCatCount (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(params['index'])
|
||||
if ((index) != null) {
|
||||
path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(index)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'count'
|
||||
}
|
||||
@ -127,10 +110,27 @@ function buildCatCount (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatFielddata (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -17,6 +20,30 @@ function buildCatFielddata (opts) {
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
* @param {list} fields - A comma-separated list of fields to return in the output
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'fields',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catFielddata (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -45,68 +72,22 @@ function buildCatFielddata (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'fields',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'masterTimeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'fields',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, fields } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'fields'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -114,8 +95,8 @@ function buildCatFielddata (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['fields']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(params['fields'])
|
||||
if ((fields) != null) {
|
||||
path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(fields)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'fielddata'
|
||||
}
|
||||
@ -133,10 +114,27 @@ function buildCatFielddata (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatHealth (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -15,6 +18,29 @@ function buildCatHealth (opts) {
|
||||
* @param {boolean} ts - Set to false to disable timestamping
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'ts',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catHealth (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,66 +69,22 @@ function buildCatHealth (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'ts',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'local',
|
||||
'masterTimeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'ts',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -125,10 +107,27 @@ function buildCatHealth (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatHelp (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,22 @@ function buildCatHelp (opts) {
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'help',
|
||||
's',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catHelp (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -37,54 +56,22 @@ function buildCatHelp (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'help',
|
||||
's',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'help',
|
||||
's',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -107,10 +94,27 @@ function buildCatHelp (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatIndices (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -18,6 +21,31 @@ function buildCatIndices (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'health',
|
||||
'help',
|
||||
'pri',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catIndices (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -46,70 +74,22 @@ function buildCatIndices (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'health',
|
||||
'help',
|
||||
'pri',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'masterTimeout',
|
||||
'h',
|
||||
'health',
|
||||
'help',
|
||||
'pri',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -117,8 +97,8 @@ function buildCatIndices (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(params['index'])
|
||||
if ((index) != null) {
|
||||
path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(index)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'indices'
|
||||
}
|
||||
@ -136,10 +116,27 @@ function buildCatIndices (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatMaster (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,28 @@ function buildCatMaster (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catMaster (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -42,64 +67,22 @@ function buildCatMaster (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -122,10 +105,27 @@ function buildCatMaster (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatNodeattrs (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,28 @@ function buildCatNodeattrs (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catNodeattrs (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -42,64 +67,22 @@ function buildCatNodeattrs (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -122,10 +105,27 @@ function buildCatNodeattrs (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatNodes (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -15,6 +18,30 @@ function buildCatNodes (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'full_id',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
fullId: 'full_id',
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catNodes (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,66 +70,22 @@ function buildCatNodes (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'full_id',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'fullId',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -125,10 +108,27 @@ function buildCatNodes (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatPendingTasks (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,28 @@ function buildCatPendingTasks (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catPendingTasks (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -42,64 +67,22 @@ function buildCatPendingTasks (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -122,10 +105,27 @@ function buildCatPendingTasks (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatPlugins (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,28 @@ function buildCatPlugins (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catPlugins (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -42,64 +67,22 @@ function buildCatPlugins (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -122,10 +105,27 @@ function buildCatPlugins (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatRecovery (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -15,6 +18,28 @@ function buildCatRecovery (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catRecovery (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,64 +68,22 @@ function buildCatRecovery (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -108,8 +91,8 @@ function buildCatRecovery (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(params['index'])
|
||||
if ((index) != null) {
|
||||
path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(index)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'recovery'
|
||||
}
|
||||
@ -127,10 +110,27 @@ function buildCatRecovery (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatRepositories (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,28 @@ function buildCatRepositories (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catRepositories (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -42,64 +67,22 @@ function buildCatRepositories (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -122,10 +105,27 @@ function buildCatRepositories (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatSegments (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,26 @@ function buildCatSegments (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catSegments (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -42,62 +65,22 @@ function buildCatSegments (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'bytes',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -105,8 +88,8 @@ function buildCatSegments (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(params['index'])
|
||||
if ((index) != null) {
|
||||
path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(index)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'segments'
|
||||
}
|
||||
@ -124,10 +107,27 @@ function buildCatSegments (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatShards (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -16,6 +19,29 @@ function buildCatShards (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catShards (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,66 +70,22 @@ function buildCatShards (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'bytes',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -111,8 +93,8 @@ function buildCatShards (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(params['index'])
|
||||
if ((index) != null) {
|
||||
path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(index)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'shards'
|
||||
}
|
||||
@ -130,10 +112,27 @@ function buildCatShards (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatSnapshots (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -15,6 +18,29 @@ function buildCatSnapshots (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'ignore_unavailable',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catSnapshots (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,64 +69,22 @@ function buildCatSnapshots (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'ignore_unavailable',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'ignoreUnavailable',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, repository } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'repository'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -108,8 +92,8 @@ function buildCatSnapshots (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['repository']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(params['repository'])
|
||||
if ((repository) != null) {
|
||||
path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(repository)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'snapshots'
|
||||
}
|
||||
@ -127,10 +111,27 @@ function buildCatSnapshots (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatTasks (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -16,6 +19,31 @@ function buildCatTasks (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'node_id',
|
||||
'actions',
|
||||
'detailed',
|
||||
'parent_task',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
nodeId: 'node_id',
|
||||
parentTask: 'parent_task',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catTasks (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,68 +72,22 @@ function buildCatTasks (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'node_id',
|
||||
'actions',
|
||||
'detailed',
|
||||
'parent_task',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'nodeId',
|
||||
'actions',
|
||||
'detailed',
|
||||
'parentTask',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -128,10 +110,27 @@ function buildCatTasks (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatTemplates (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -15,6 +18,28 @@ function buildCatTemplates (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catTemplates (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,64 +68,22 @@ function buildCatTemplates (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -108,8 +91,8 @@ function buildCatTemplates (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['name']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(params['name'])
|
||||
if ((name) != null) {
|
||||
path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(name)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'templates'
|
||||
}
|
||||
@ -127,10 +110,27 @@ function buildCatTemplates (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCatThreadPool (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -16,6 +19,29 @@ function buildCatThreadPool (opts) {
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'size',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function catThreadPool (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,66 +70,22 @@ function buildCatThreadPool (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'size',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'size',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, threadPoolPatterns, thread_pool_patterns } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'threadPoolPatterns', 'thread_pool_patterns'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -111,8 +93,8 @@ function buildCatThreadPool (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['thread_pool_patterns'] || params['threadPoolPatterns']) != null) {
|
||||
path = '/' + '_cat' + '/' + 'thread_pool' + '/' + encodeURIComponent(params['thread_pool_patterns'] || params['threadPoolPatterns'])
|
||||
if ((thread_pool_patterns || threadPoolPatterns) != null) {
|
||||
path = '/' + '_cat' + '/' + 'thread_pool' + '/' + encodeURIComponent(thread_pool_patterns || threadPoolPatterns)
|
||||
} else {
|
||||
path = '/' + '_cat' + '/' + 'thread_pool'
|
||||
}
|
||||
@ -130,10 +112,27 @@ function buildCatThreadPool (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCcrDeleteAutoFollowPattern (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -8,6 +11,15 @@ function buildCcrDeleteAutoFollowPattern (opts) {
|
||||
*
|
||||
* @param {string} name - The name of the auto follow pattern.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ccrDeleteAutoFollowPattern (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -36,42 +48,22 @@ function buildCcrDeleteAutoFollowPattern (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'DELETE'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'DELETE'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -79,13 +71,13 @@ function buildCcrDeleteAutoFollowPattern (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name'])
|
||||
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -94,10 +86,27 @@ function buildCcrDeleteAutoFollowPattern (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCcrFollow (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,15 @@ function buildCcrFollow (opts) {
|
||||
* @param {string} index - The name of the follower index
|
||||
* @param {object} body - The name of the leader index and other optional ccr related parameters
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ccrFollow (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,42 +55,22 @@ function buildCcrFollow (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -86,13 +78,13 @@ function buildCcrFollow (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'follow'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'follow'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -101,10 +93,27 @@ function buildCcrFollow (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCcrFollowStats (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -8,6 +11,15 @@ function buildCcrFollowStats (opts) {
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index patterns; use `_all` to perform the operation on all indices
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ccrFollowStats (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -28,42 +40,22 @@ function buildCcrFollowStats (opts) {
|
||||
})
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -71,7 +63,7 @@ function buildCcrFollowStats (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'stats'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'stats'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -86,10 +78,27 @@ function buildCcrFollowStats (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCcrGetAutoFollowPattern (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -8,6 +11,15 @@ function buildCcrGetAutoFollowPattern (opts) {
|
||||
*
|
||||
* @param {string} name - The name of the auto follow pattern.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ccrGetAutoFollowPattern (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -28,42 +40,22 @@ function buildCcrGetAutoFollowPattern (opts) {
|
||||
})
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -71,8 +63,8 @@ function buildCcrGetAutoFollowPattern (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['name']) != null) {
|
||||
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name'])
|
||||
if ((name) != null) {
|
||||
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name)
|
||||
} else {
|
||||
path = '/' + '_ccr' + '/' + 'auto_follow'
|
||||
}
|
||||
@ -90,10 +82,27 @@ function buildCcrGetAutoFollowPattern (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCcrPauseFollow (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -8,6 +11,15 @@ function buildCcrPauseFollow (opts) {
|
||||
*
|
||||
* @param {string} index - The name of the follower index that should pause following its leader index.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ccrPauseFollow (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -36,42 +48,22 @@ function buildCcrPauseFollow (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -79,13 +71,13 @@ function buildCcrPauseFollow (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'pause_follow'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'pause_follow'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -94,10 +86,27 @@ function buildCcrPauseFollow (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCcrPutAutoFollowPattern (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,15 @@ function buildCcrPutAutoFollowPattern (opts) {
|
||||
* @param {string} name - The name of the auto follow pattern.
|
||||
* @param {object} body - The specification of the auto follow pattern
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ccrPutAutoFollowPattern (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,42 +55,22 @@ function buildCcrPutAutoFollowPattern (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -86,13 +78,13 @@ function buildCcrPutAutoFollowPattern (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name'])
|
||||
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -101,10 +93,27 @@ function buildCcrPutAutoFollowPattern (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCcrResumeFollow (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,15 @@ function buildCcrResumeFollow (opts) {
|
||||
* @param {string} index - The name of the follow index to resume following.
|
||||
* @param {object} body - The name of the leader index and other optional ccr related parameters
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ccrResumeFollow (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,42 +55,22 @@ function buildCcrResumeFollow (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -86,13 +78,13 @@ function buildCcrResumeFollow (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'resume_follow'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'resume_follow'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -101,10 +93,27 @@ function buildCcrResumeFollow (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCcrStats (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -7,6 +10,15 @@ function buildCcrStats (opts) {
|
||||
* Perform a [ccr.stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html) request
|
||||
*
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ccrStats (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -27,42 +39,22 @@ function buildCcrStats (opts) {
|
||||
})
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -85,10 +77,27 @@ function buildCcrStats (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCcrUnfollow (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -8,6 +11,15 @@ function buildCcrUnfollow (opts) {
|
||||
*
|
||||
* @param {string} index - The name of the follower index that should be turned into a regular index.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ccrUnfollow (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -36,42 +48,22 @@ function buildCcrUnfollow (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -79,13 +71,13 @@ function buildCcrUnfollow (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'unfollow'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'unfollow'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -94,10 +86,27 @@ function buildCcrUnfollow (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildClearScroll (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,20 @@ function buildClearScroll (opts) {
|
||||
* @param {list} scroll_id - A comma-separated list of scroll IDs to clear
|
||||
* @param {object} body - A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function clearScroll (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -29,50 +46,22 @@ function buildClearScroll (opts) {
|
||||
})
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'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 = 'DELETE'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, scrollId, scroll_id } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'scrollId', 'scroll_id'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'DELETE'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -80,8 +69,8 @@ function buildClearScroll (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['scroll_id'] || params['scrollId']) != null) {
|
||||
path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(params['scroll_id'] || params['scrollId'])
|
||||
if ((scroll_id || scrollId) != null) {
|
||||
path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId)
|
||||
} else {
|
||||
path = '/' + '_search' + '/' + 'scroll'
|
||||
}
|
||||
@ -90,7 +79,7 @@ function buildClearScroll (opts) {
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -99,10 +88,27 @@ function buildClearScroll (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildClusterAllocationExplain (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -10,6 +13,24 @@ function buildClusterAllocationExplain (opts) {
|
||||
* @param {boolean} include_disk_info - Return information about disk usage and shard sizes (default: false)
|
||||
* @param {object} body - The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard'
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'include_yes_decisions',
|
||||
'include_disk_info',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
includeYesDecisions: 'include_yes_decisions',
|
||||
includeDiskInfo: 'include_disk_info',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function clusterAllocationExplain (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -30,54 +51,22 @@ function buildClusterAllocationExplain (opts) {
|
||||
})
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'include_yes_decisions',
|
||||
'include_disk_info',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'includeYesDecisions',
|
||||
'includeDiskInfo',
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -91,7 +80,7 @@ function buildClusterAllocationExplain (opts) {
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -100,10 +89,27 @@ function buildClusterAllocationExplain (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildClusterGetSettings (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -11,6 +14,27 @@ function buildClusterGetSettings (opts) {
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {boolean} include_defaults - Whether to return all default clusters setting.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'flat_settings',
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'include_defaults',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
flatSettings: 'flat_settings',
|
||||
masterTimeout: 'master_timeout',
|
||||
includeDefaults: 'include_defaults',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function clusterGetSettings (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -39,58 +63,22 @@ function buildClusterGetSettings (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'flat_settings',
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'include_defaults',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'flatSettings',
|
||||
'masterTimeout',
|
||||
'timeout',
|
||||
'includeDefaults',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -113,10 +101,27 @@ function buildClusterGetSettings (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildClusterHealth (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -18,6 +21,37 @@ function buildClusterHealth (opts) {
|
||||
* @param {boolean} wait_for_no_initializing_shards - Whether to wait until there are no initializing shards in the cluster
|
||||
* @param {enum} wait_for_status - Wait until cluster is in a specific state
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'level',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'wait_for_active_shards',
|
||||
'wait_for_nodes',
|
||||
'wait_for_events',
|
||||
'wait_for_no_relocating_shards',
|
||||
'wait_for_no_initializing_shards',
|
||||
'wait_for_status',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
waitForNodes: 'wait_for_nodes',
|
||||
waitForEvents: 'wait_for_events',
|
||||
waitForNoRelocatingShards: 'wait_for_no_relocating_shards',
|
||||
waitForNoInitializingShards: 'wait_for_no_initializing_shards',
|
||||
waitForStatus: 'wait_for_status',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function clusterHealth (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -46,70 +80,22 @@ function buildClusterHealth (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'level',
|
||||
'local',
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'wait_for_active_shards',
|
||||
'wait_for_nodes',
|
||||
'wait_for_events',
|
||||
'wait_for_no_relocating_shards',
|
||||
'wait_for_no_initializing_shards',
|
||||
'wait_for_status',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'level',
|
||||
'local',
|
||||
'masterTimeout',
|
||||
'timeout',
|
||||
'waitForActiveShards',
|
||||
'waitForNodes',
|
||||
'waitForEvents',
|
||||
'waitForNoRelocatingShards',
|
||||
'waitForNoInitializingShards',
|
||||
'waitForStatus',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -117,8 +103,8 @@ function buildClusterHealth (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(params['index'])
|
||||
if ((index) != null) {
|
||||
path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(index)
|
||||
} else {
|
||||
path = '/' + '_cluster' + '/' + 'health'
|
||||
}
|
||||
@ -136,10 +122,27 @@ function buildClusterHealth (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildClusterPendingTasks (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,23 @@ function buildClusterPendingTasks (opts) {
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'local',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function clusterPendingTasks (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -37,54 +57,22 @@ function buildClusterPendingTasks (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'local',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'local',
|
||||
'masterTimeout',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -107,10 +95,27 @@ function buildClusterPendingTasks (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildClusterPutSettings (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -11,6 +14,25 @@ function buildClusterPutSettings (opts) {
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {object} body - The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart).
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'flat_settings',
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
flatSettings: 'flat_settings',
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function clusterPutSettings (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -39,56 +61,22 @@ function buildClusterPutSettings (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'flat_settings',
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'flatSettings',
|
||||
'masterTimeout',
|
||||
'timeout',
|
||||
'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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -102,7 +90,7 @@ function buildClusterPutSettings (opts) {
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -111,10 +99,27 @@ function buildClusterPutSettings (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildClusterRemoteInfo (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -7,6 +10,20 @@ function buildClusterRemoteInfo (opts) {
|
||||
* Perform a [cluster.remote_info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html) request
|
||||
*
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function clusterRemoteInfo (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -35,50 +52,22 @@ function buildClusterRemoteInfo (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -101,10 +90,27 @@ function buildClusterRemoteInfo (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildClusterReroute (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,29 @@ function buildClusterReroute (opts) {
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {object} body - The definition of `commands` to perform (`move`, `cancel`, `allocate`)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'dry_run',
|
||||
'explain',
|
||||
'retry_failed',
|
||||
'metric',
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
dryRun: 'dry_run',
|
||||
retryFailed: 'retry_failed',
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function clusterReroute (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -34,62 +60,22 @@ function buildClusterReroute (opts) {
|
||||
})
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'dry_run',
|
||||
'explain',
|
||||
'retry_failed',
|
||||
'metric',
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'dryRun',
|
||||
'explain',
|
||||
'retryFailed',
|
||||
'metric',
|
||||
'masterTimeout',
|
||||
'timeout',
|
||||
'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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -103,7 +89,7 @@ function buildClusterReroute (opts) {
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -112,10 +98,27 @@ function buildClusterReroute (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildClusterState (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -17,6 +20,35 @@ function buildClusterState (opts) {
|
||||
* @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)
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'local',
|
||||
'master_timeout',
|
||||
'flat_settings',
|
||||
'wait_for_metadata_version',
|
||||
'wait_for_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
flatSettings: 'flat_settings',
|
||||
waitForMetadataVersion: 'wait_for_metadata_version',
|
||||
waitForTimeout: 'wait_for_timeout',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function clusterState (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -53,66 +85,22 @@ function buildClusterState (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'local',
|
||||
'master_timeout',
|
||||
'flat_settings',
|
||||
'wait_for_metadata_version',
|
||||
'wait_for_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'local',
|
||||
'masterTimeout',
|
||||
'flatSettings',
|
||||
'waitForMetadataVersion',
|
||||
'waitForTimeout',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, metric } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'metric'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -120,10 +108,10 @@ function buildClusterState (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['metric']) != null && (params['index']) != null) {
|
||||
path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(params['metric']) + '/' + encodeURIComponent(params['index'])
|
||||
} else if ((params['metric']) != null) {
|
||||
path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(params['metric'])
|
||||
if ((metric) != null && (index) != null) {
|
||||
path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index)
|
||||
} else if ((metric) != null) {
|
||||
path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric)
|
||||
} else {
|
||||
path = '/' + '_cluster' + '/' + 'state'
|
||||
}
|
||||
@ -141,10 +129,27 @@ function buildClusterState (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildClusterStats (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -10,6 +13,23 @@ function buildClusterStats (opts) {
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'flat_settings',
|
||||
'timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
flatSettings: 'flat_settings',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function clusterStats (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -38,54 +58,22 @@ function buildClusterStats (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'flat_settings',
|
||||
'timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'flatSettings',
|
||||
'timeout',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, nodeId, node_id } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -93,8 +81,8 @@ function buildClusterStats (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['node_id'] || params['nodeId']) != null) {
|
||||
path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId'])
|
||||
if ((node_id || nodeId) != null) {
|
||||
path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId)
|
||||
} else {
|
||||
path = '/' + '_cluster' + '/' + 'stats'
|
||||
}
|
||||
@ -112,10 +100,27 @@ function buildClusterStats (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
144
api/api/count.js
144
api/api/count.js
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCount (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -24,6 +27,42 @@ function buildCount (opts) {
|
||||
* @param {number} terminate_after - The maximum count for each shard, upon reaching which the query execution will terminate early
|
||||
* @param {object} body - A query to restrict the results specified with the Query DSL (optional)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'ignore_throttled',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'min_score',
|
||||
'preference',
|
||||
'routing',
|
||||
'q',
|
||||
'analyzer',
|
||||
'analyze_wildcard',
|
||||
'default_operator',
|
||||
'df',
|
||||
'lenient',
|
||||
'terminate_after',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
ignoreThrottled: 'ignore_throttled',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
minScore: 'min_score',
|
||||
analyzeWildcard: 'analyze_wildcard',
|
||||
defaultOperator: 'default_operator',
|
||||
terminateAfter: 'terminate_after',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function count (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -52,78 +91,22 @@ function buildCount (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'ignore_throttled',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'min_score',
|
||||
'preference',
|
||||
'routing',
|
||||
'q',
|
||||
'analyzer',
|
||||
'analyze_wildcard',
|
||||
'default_operator',
|
||||
'df',
|
||||
'lenient',
|
||||
'terminate_after',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'ignoreUnavailable',
|
||||
'ignoreThrottled',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'minScore',
|
||||
'preference',
|
||||
'routing',
|
||||
'q',
|
||||
'analyzer',
|
||||
'analyzeWildcard',
|
||||
'defaultOperator',
|
||||
'df',
|
||||
'lenient',
|
||||
'terminateAfter',
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -131,10 +114,10 @@ function buildCount (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_count'
|
||||
} else if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_count'
|
||||
if ((index) != null && (type) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_count'
|
||||
} else if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_count'
|
||||
} else {
|
||||
path = '/' + '_count'
|
||||
}
|
||||
@ -143,7 +126,7 @@ function buildCount (opts) {
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -152,10 +135,27 @@ function buildCount (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildCreate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -19,6 +22,30 @@ function buildCreate (opts) {
|
||||
* @param {string} pipeline - The pipeline id to preprocess incoming documents with
|
||||
* @param {object} body - The document
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'wait_for_active_shards',
|
||||
'parent',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'version',
|
||||
'version_type',
|
||||
'pipeline',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
versionType: 'version_type',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function create (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -78,66 +105,22 @@ function buildCreate (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'wait_for_active_shards',
|
||||
'parent',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'version',
|
||||
'version_type',
|
||||
'pipeline',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'waitForActiveShards',
|
||||
'parent',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'version',
|
||||
'versionType',
|
||||
'pipeline',
|
||||
'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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, id, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -145,13 +128,13 @@ function buildCreate (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_create'
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -160,10 +143,27 @@ function buildCreate (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildDelete (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -17,6 +20,29 @@ function buildDelete (opts) {
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'wait_for_active_shards',
|
||||
'parent',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
versionType: 'version_type',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function _delete (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -65,64 +91,22 @@ function buildDelete (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'wait_for_active_shards',
|
||||
'parent',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'waitForActiveShards',
|
||||
'parent',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'version',
|
||||
'versionType',
|
||||
'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 = 'DELETE'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, id, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'DELETE'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -130,10 +114,10 @@ function buildDelete (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null && (params['id']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id'])
|
||||
if ((index) != null && (type) != null && (id) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id'])
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
|
||||
}
|
||||
|
||||
// build request object
|
||||
@ -149,10 +133,27 @@ function buildDelete (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildDeleteByQuery (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -42,6 +45,67 @@ function buildDeleteByQuery (opts) {
|
||||
* @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.
|
||||
* @param {object} body - The search definition using the Query DSL
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'analyzer',
|
||||
'analyze_wildcard',
|
||||
'default_operator',
|
||||
'df',
|
||||
'from',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'conflicts',
|
||||
'expand_wildcards',
|
||||
'lenient',
|
||||
'preference',
|
||||
'q',
|
||||
'routing',
|
||||
'scroll',
|
||||
'search_type',
|
||||
'search_timeout',
|
||||
'size',
|
||||
'sort',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'terminate_after',
|
||||
'stats',
|
||||
'version',
|
||||
'request_cache',
|
||||
'refresh',
|
||||
'timeout',
|
||||
'wait_for_active_shards',
|
||||
'scroll_size',
|
||||
'wait_for_completion',
|
||||
'requests_per_second',
|
||||
'slices',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
analyzeWildcard: 'analyze_wildcard',
|
||||
defaultOperator: 'default_operator',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
searchType: 'search_type',
|
||||
searchTimeout: 'search_timeout',
|
||||
_sourceExcludes: '_source_excludes',
|
||||
_sourceIncludes: '_source_includes',
|
||||
terminateAfter: 'terminate_after',
|
||||
requestCache: 'request_cache',
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
scrollSize: 'scroll_size',
|
||||
waitForCompletion: 'wait_for_completion',
|
||||
requestsPerSecond: 'requests_per_second',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function deleteByQuery (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -84,114 +148,22 @@ function buildDeleteByQuery (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'analyzer',
|
||||
'analyze_wildcard',
|
||||
'default_operator',
|
||||
'df',
|
||||
'from',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'conflicts',
|
||||
'expand_wildcards',
|
||||
'lenient',
|
||||
'preference',
|
||||
'q',
|
||||
'routing',
|
||||
'scroll',
|
||||
'search_type',
|
||||
'search_timeout',
|
||||
'size',
|
||||
'sort',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'terminate_after',
|
||||
'stats',
|
||||
'version',
|
||||
'request_cache',
|
||||
'refresh',
|
||||
'timeout',
|
||||
'wait_for_active_shards',
|
||||
'scroll_size',
|
||||
'wait_for_completion',
|
||||
'requests_per_second',
|
||||
'slices',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'analyzer',
|
||||
'analyzeWildcard',
|
||||
'defaultOperator',
|
||||
'df',
|
||||
'from',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'conflicts',
|
||||
'expandWildcards',
|
||||
'lenient',
|
||||
'preference',
|
||||
'q',
|
||||
'routing',
|
||||
'scroll',
|
||||
'searchType',
|
||||
'searchTimeout',
|
||||
'size',
|
||||
'sort',
|
||||
'_source',
|
||||
'_sourceExcludes',
|
||||
'_sourceIncludes',
|
||||
'terminateAfter',
|
||||
'stats',
|
||||
'version',
|
||||
'requestCache',
|
||||
'refresh',
|
||||
'timeout',
|
||||
'waitForActiveShards',
|
||||
'scrollSize',
|
||||
'waitForCompletion',
|
||||
'requestsPerSecond',
|
||||
'slices',
|
||||
'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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -199,17 +171,17 @@ function buildDeleteByQuery (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_delete_by_query'
|
||||
if ((index) != null && (type) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_delete_by_query'
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_delete_by_query'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query'
|
||||
}
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -218,10 +190,27 @@ function buildDeleteByQuery (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildDeleteByQueryRethrottle (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,22 @@ function buildDeleteByQueryRethrottle (opts) {
|
||||
* @param {string} task_id - The task id to rethrottle
|
||||
* @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'requests_per_second',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
requestsPerSecond: 'requests_per_second',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function deleteByQueryRethrottle (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -49,52 +68,22 @@ function buildDeleteByQueryRethrottle (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'requests_per_second',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'requestsPerSecond',
|
||||
'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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, taskId, task_id } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'taskId', 'task_id'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -102,7 +91,7 @@ function buildDeleteByQueryRethrottle (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_delete_by_query' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_rethrottle'
|
||||
path = '/' + '_delete_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -117,10 +106,27 @@ function buildDeleteByQueryRethrottle (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildDeleteScript (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -10,6 +13,23 @@ function buildDeleteScript (opts) {
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function deleteScript (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,54 +64,22 @@ function buildDeleteScript (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'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 = 'DELETE'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, id } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'id'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'DELETE'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -99,7 +87,7 @@ function buildDeleteScript (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_scripts' + '/' + encodeURIComponent(params['id'])
|
||||
path = '/' + '_scripts' + '/' + encodeURIComponent(id)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -114,10 +102,27 @@ function buildDeleteScript (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildExists (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -21,6 +24,35 @@ function buildExists (opts) {
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'stored_fields',
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
storedFields: 'stored_fields',
|
||||
_sourceExcludes: '_source_excludes',
|
||||
_sourceIncludes: '_source_includes',
|
||||
versionType: 'version_type',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function exists (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -61,72 +93,22 @@ function buildExists (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'stored_fields',
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'storedFields',
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_sourceExcludes',
|
||||
'_sourceIncludes',
|
||||
'version',
|
||||
'versionType',
|
||||
'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 = 'HEAD'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, id, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'HEAD'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -134,10 +116,10 @@ function buildExists (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null && (params['id']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id'])
|
||||
if ((index) != null && (type) != null && (id) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id'])
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
|
||||
}
|
||||
|
||||
// build request object
|
||||
@ -153,10 +135,27 @@ function buildExists (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildExistsSource (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -20,6 +23,33 @@ function buildExistsSource (opts) {
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
_sourceExcludes: '_source_excludes',
|
||||
_sourceIncludes: '_source_includes',
|
||||
versionType: 'version_type',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function existsSource (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -79,70 +109,22 @@ function buildExistsSource (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_sourceExcludes',
|
||||
'_sourceIncludes',
|
||||
'version',
|
||||
'versionType',
|
||||
'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 = 'HEAD'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, id, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'HEAD'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -150,7 +132,7 @@ function buildExistsSource (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_source'
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -165,10 +147,27 @@ function buildExistsSource (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildExplain (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -24,6 +27,38 @@ function buildExplain (opts) {
|
||||
* @param {list} _source_includes - A list of fields to extract and return from the _source field
|
||||
* @param {object} body - The query definition using the Query DSL
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'analyze_wildcard',
|
||||
'analyzer',
|
||||
'default_operator',
|
||||
'df',
|
||||
'stored_fields',
|
||||
'lenient',
|
||||
'parent',
|
||||
'preference',
|
||||
'q',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
analyzeWildcard: 'analyze_wildcard',
|
||||
defaultOperator: 'default_operator',
|
||||
storedFields: 'stored_fields',
|
||||
_sourceExcludes: '_source_excludes',
|
||||
_sourceIncludes: '_source_includes',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function explain (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -58,76 +93,22 @@ function buildExplain (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'analyze_wildcard',
|
||||
'analyzer',
|
||||
'default_operator',
|
||||
'df',
|
||||
'stored_fields',
|
||||
'lenient',
|
||||
'parent',
|
||||
'preference',
|
||||
'q',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'analyzeWildcard',
|
||||
'analyzer',
|
||||
'defaultOperator',
|
||||
'df',
|
||||
'storedFields',
|
||||
'lenient',
|
||||
'parent',
|
||||
'preference',
|
||||
'q',
|
||||
'routing',
|
||||
'_source',
|
||||
'_sourceExcludes',
|
||||
'_sourceIncludes',
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, id, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -135,17 +116,17 @@ function buildExplain (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null && (params['id']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_explain'
|
||||
if ((index) != null && (type) != null && (id) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_explain'
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_explain' + '/' + encodeURIComponent(params['id'])
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_explain' + '/' + encodeURIComponent(id)
|
||||
}
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -154,10 +135,27 @@ function buildExplain (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildFieldCaps (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -12,6 +15,27 @@ function buildFieldCaps (opts) {
|
||||
* @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)
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'fields',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function fieldCaps (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -40,58 +64,22 @@ function buildFieldCaps (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'fields',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'fields',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -99,8 +87,8 @@ function buildFieldCaps (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_field_caps'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_field_caps'
|
||||
} else {
|
||||
path = '/' + '_field_caps'
|
||||
}
|
||||
@ -118,10 +106,27 @@ function buildFieldCaps (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
135
api/api/get.js
135
api/api/get.js
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildGet (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -23,6 +26,39 @@ function buildGet (opts) {
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'stored_fields',
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'_source_exclude',
|
||||
'_source_include',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
storedFields: 'stored_fields',
|
||||
_sourceExcludes: '_source_excludes',
|
||||
_sourceIncludes: '_source_includes',
|
||||
_sourceExclude: '_source_exclude',
|
||||
_sourceInclude: '_source_include',
|
||||
versionType: 'version_type',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function get (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -63,76 +99,22 @@ function buildGet (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'stored_fields',
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'_source_exclude',
|
||||
'_source_include',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'storedFields',
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_sourceExcludes',
|
||||
'_sourceIncludes',
|
||||
'_sourceExclude',
|
||||
'_sourceInclude',
|
||||
'version',
|
||||
'versionType',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, id, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -140,10 +122,10 @@ function buildGet (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null && (params['id']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id'])
|
||||
if ((index) != null && (type) != null && (id) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id'])
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
|
||||
}
|
||||
|
||||
// build request object
|
||||
@ -159,10 +141,27 @@ function buildGet (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildGetScript (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,22 @@ function buildGetScript (opts) {
|
||||
* @param {string} id - Script ID
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function getScript (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,52 +62,22 @@ function buildGetScript (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'masterTimeout',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, id } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'id'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -96,7 +85,7 @@ function buildGetScript (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_scripts' + '/' + encodeURIComponent(params['id'])
|
||||
path = '/' + '_scripts' + '/' + encodeURIComponent(id)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -111,10 +100,27 @@ function buildGetScript (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildGetSource (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -20,6 +23,33 @@ function buildGetSource (opts) {
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
_sourceExcludes: '_source_excludes',
|
||||
_sourceIncludes: '_source_includes',
|
||||
versionType: 'version_type',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function getSource (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -79,70 +109,22 @@ function buildGetSource (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_excludes',
|
||||
'_source_includes',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_sourceExcludes',
|
||||
'_sourceIncludes',
|
||||
'version',
|
||||
'versionType',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, id, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -150,7 +132,7 @@ function buildGetSource (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_source'
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -165,10 +147,27 @@ function buildGetSource (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIlmDeleteLifecycle (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -8,6 +11,15 @@ function buildIlmDeleteLifecycle (opts) {
|
||||
*
|
||||
* @param {string} policy - The name of the index lifecycle policy
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ilmDeleteLifecycle (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -36,42 +48,22 @@ function buildIlmDeleteLifecycle (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'DELETE'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, policy } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'policy'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'DELETE'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -79,7 +71,7 @@ function buildIlmDeleteLifecycle (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy'])
|
||||
path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -94,10 +86,27 @@ function buildIlmDeleteLifecycle (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIlmExplainLifecycle (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,15 @@ function buildIlmExplainLifecycle (opts) {
|
||||
* @param {string} index - The name of the index to explain
|
||||
* @param {boolean} human - Return data such as dates in a human readable format
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'human'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ilmExplainLifecycle (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -37,42 +49,22 @@ function buildIlmExplainLifecycle (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'human'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'human'
|
||||
]
|
||||
|
||||
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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -80,7 +72,7 @@ function buildIlmExplainLifecycle (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'explain'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'explain'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -95,10 +87,27 @@ function buildIlmExplainLifecycle (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIlmGetLifecycle (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -8,6 +11,15 @@ function buildIlmGetLifecycle (opts) {
|
||||
*
|
||||
* @param {string} policy - The name of the index lifecycle policy
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ilmGetLifecycle (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -36,42 +48,22 @@ function buildIlmGetLifecycle (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, policy } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'policy'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -79,8 +71,8 @@ function buildIlmGetLifecycle (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['policy']) != null) {
|
||||
path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy'])
|
||||
if ((policy) != null) {
|
||||
path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy)
|
||||
} else {
|
||||
path = '/' + '_ilm' + '/' + 'policy'
|
||||
}
|
||||
@ -98,10 +90,27 @@ function buildIlmGetLifecycle (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIlmGetStatus (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -7,6 +10,15 @@ function buildIlmGetStatus (opts) {
|
||||
* Perform a [ilm.get_status](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html) request
|
||||
*
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ilmGetStatus (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -35,42 +47,22 @@ function buildIlmGetStatus (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -93,10 +85,27 @@ function buildIlmGetStatus (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIlmMoveToStep (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,15 @@ function buildIlmMoveToStep (opts) {
|
||||
* @param {string} index - The name of the index whose lifecycle step is to change
|
||||
* @param {object} body - The new lifecycle step to move to
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ilmMoveToStep (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -29,42 +41,22 @@ function buildIlmMoveToStep (opts) {
|
||||
})
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -72,13 +64,13 @@ function buildIlmMoveToStep (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(params['index'])
|
||||
path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(index)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -87,10 +79,27 @@ function buildIlmMoveToStep (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIlmPutLifecycle (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -9,6 +12,15 @@ function buildIlmPutLifecycle (opts) {
|
||||
* @param {string} policy - The name of the index lifecycle policy
|
||||
* @param {object} body - The lifecycle policy definition to register
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ilmPutLifecycle (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -29,42 +41,22 @@ function buildIlmPutLifecycle (opts) {
|
||||
})
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, policy } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'policy'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -72,13 +64,13 @@ function buildIlmPutLifecycle (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy'])
|
||||
path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -87,10 +79,27 @@ function buildIlmPutLifecycle (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIlmRemovePolicy (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -8,6 +11,15 @@ function buildIlmRemovePolicy (opts) {
|
||||
*
|
||||
* @param {string} index - The name of the index to remove policy on
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ilmRemovePolicy (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -36,42 +48,22 @@ function buildIlmRemovePolicy (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -79,7 +71,7 @@ function buildIlmRemovePolicy (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'remove'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'remove'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -94,10 +86,27 @@ function buildIlmRemovePolicy (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIlmRetry (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -8,6 +11,15 @@ function buildIlmRetry (opts) {
|
||||
*
|
||||
* @param {string} index - The name of the indices (comma-separated) whose failed lifecycle step is to be retry
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ilmRetry (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -36,42 +48,22 @@ function buildIlmRetry (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -79,7 +71,7 @@ function buildIlmRetry (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'retry'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'retry'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -94,10 +86,27 @@ function buildIlmRetry (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIlmStart (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -7,6 +10,15 @@ function buildIlmStart (opts) {
|
||||
* Perform a [ilm.start](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html) request
|
||||
*
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ilmStart (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -35,42 +47,22 @@ function buildIlmStart (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -93,10 +85,27 @@ function buildIlmStart (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIlmStop (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -7,6 +10,15 @@ function buildIlmStop (opts) {
|
||||
* Perform a [ilm.stop](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html) request
|
||||
*
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
|
||||
}
|
||||
|
||||
return function ilmStop (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -35,42 +47,22 @@ function buildIlmStop (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
|
||||
]
|
||||
|
||||
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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body } = params
|
||||
var querystring = semicopy(params, ['method', 'body'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -93,10 +85,27 @@ function buildIlmStop (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
130
api/api/index.js
130
api/api/index.js
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndex (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -20,6 +23,32 @@ function buildIndex (opts) {
|
||||
* @param {string} pipeline - The pipeline id to preprocess incoming documents with
|
||||
* @param {object} body - The document
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'wait_for_active_shards',
|
||||
'op_type',
|
||||
'parent',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'version',
|
||||
'version_type',
|
||||
'pipeline',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
opType: 'op_type',
|
||||
versionType: 'version_type',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function index (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -62,68 +91,22 @@ function buildIndex (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'wait_for_active_shards',
|
||||
'op_type',
|
||||
'parent',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'version',
|
||||
'version_type',
|
||||
'pipeline',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'waitForActiveShards',
|
||||
'opType',
|
||||
'parent',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'version',
|
||||
'versionType',
|
||||
'pipeline',
|
||||
'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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, id, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -131,21 +114,21 @@ function buildIndex (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null && (params['id']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id'])
|
||||
} else if ((params['index']) != null && (params['id']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id'])
|
||||
} else if ((params['index']) != null && (params['type']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type'])
|
||||
if ((index) != null && (type) != null && (id) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
|
||||
} else if ((index) != null && (id) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
|
||||
} else if ((index) != null && (type) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type)
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_doc'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_doc'
|
||||
}
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -154,10 +137,27 @@ function buildIndex (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesAnalyze (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -10,6 +13,21 @@ function buildIndicesAnalyze (opts) {
|
||||
* @param {string} index - The name of the index to scope the operation
|
||||
* @param {object} body - Define analyzer/tokenizer parameters and the text on which the analysis should be performed
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'index',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesAnalyze (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -30,52 +48,22 @@ function buildIndicesAnalyze (opts) {
|
||||
})
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'index',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'index',
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -83,8 +71,8 @@ function buildIndicesAnalyze (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_analyze'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_analyze'
|
||||
} else {
|
||||
path = '/' + '_analyze'
|
||||
}
|
||||
@ -93,7 +81,7 @@ function buildIndicesAnalyze (opts) {
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -102,10 +90,27 @@ function buildIndicesAnalyze (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesClearCache (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -16,6 +19,31 @@ function buildIndicesClearCache (opts) {
|
||||
* @param {list} index - A comma-separated list of index name to limit the operation
|
||||
* @param {boolean} request - Clear request cache
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'fielddata',
|
||||
'fields',
|
||||
'query',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'index',
|
||||
'request',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesClearCache (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,66 +72,22 @@ function buildIndicesClearCache (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'fielddata',
|
||||
'fields',
|
||||
'query',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'index',
|
||||
'request',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'fielddata',
|
||||
'fields',
|
||||
'query',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'index',
|
||||
'request',
|
||||
'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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -111,8 +95,8 @@ function buildIndicesClearCache (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_cache' + '/' + 'clear'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_cache' + '/' + 'clear'
|
||||
} else {
|
||||
path = '/' + '_cache' + '/' + 'clear'
|
||||
}
|
||||
@ -130,10 +114,27 @@ function buildIndicesClearCache (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesClose (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -13,6 +16,29 @@ function buildIndicesClose (opts) {
|
||||
* @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)
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesClose (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -47,60 +73,22 @@ function buildIndicesClose (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -108,7 +96,7 @@ function buildIndicesClose (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_close'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_close'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -123,10 +111,27 @@ function buildIndicesClose (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesCreate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -13,6 +16,27 @@ function buildIndicesCreate (opts) {
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {object} body - The configuration for the index (`settings` and `mappings`)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'include_type_name',
|
||||
'wait_for_active_shards',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
includeTypeName: 'include_type_name',
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesCreate (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -41,58 +65,22 @@ function buildIndicesCreate (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'include_type_name',
|
||||
'wait_for_active_shards',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'includeTypeName',
|
||||
'waitForActiveShards',
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -100,13 +88,13 @@ function buildIndicesCreate (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index'])
|
||||
path = '/' + encodeURIComponent(index)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -115,10 +103,27 @@ function buildIndicesCreate (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesDelete (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -13,6 +16,29 @@ function buildIndicesDelete (opts) {
|
||||
* @param {boolean} allow_no_indices - Ignore if a wildcard expression resolves to no concrete indices (default: false)
|
||||
* @param {enum} expand_wildcards - Whether wildcard expressions should get expanded to open or closed indices (default: open)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesDelete (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -47,60 +73,22 @@ function buildIndicesDelete (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'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 = 'DELETE'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'DELETE'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -108,7 +96,7 @@ function buildIndicesDelete (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index'])
|
||||
path = '/' + encodeURIComponent(index)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -123,10 +111,27 @@ function buildIndicesDelete (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesDeleteAlias (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -11,6 +14,23 @@ function buildIndicesDeleteAlias (opts) {
|
||||
* @param {time} timeout - Explicit timestamp for the document
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesDeleteAlias (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -59,54 +79,22 @@ function buildIndicesDeleteAlias (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'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 = 'DELETE'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'DELETE'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -114,10 +102,10 @@ function buildIndicesDeleteAlias (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['name']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name'])
|
||||
if ((index) != null && (name) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name)
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_aliases' + '/' + encodeURIComponent(params['name'])
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name)
|
||||
}
|
||||
|
||||
// build request object
|
||||
@ -133,10 +121,27 @@ function buildIndicesDeleteAlias (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesDeleteTemplate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -10,6 +13,23 @@ function buildIndicesDeleteTemplate (opts) {
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesDeleteTemplate (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,54 +64,22 @@ function buildIndicesDeleteTemplate (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'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 = 'DELETE'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'DELETE'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -99,7 +87,7 @@ function buildIndicesDeleteTemplate (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_template' + '/' + encodeURIComponent(params['name'])
|
||||
path = '/' + '_template' + '/' + encodeURIComponent(name)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -114,10 +102,27 @@ function buildIndicesDeleteTemplate (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesExists (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,31 @@ function buildIndicesExists (opts) {
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {boolean} include_defaults - Whether to return all default setting for each of the indices.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'local',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'flat_settings',
|
||||
'include_defaults',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
flatSettings: 'flat_settings',
|
||||
includeDefaults: 'include_defaults',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesExists (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -48,62 +76,22 @@ function buildIndicesExists (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'local',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'flat_settings',
|
||||
'include_defaults',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'local',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'flatSettings',
|
||||
'includeDefaults',
|
||||
'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 = 'HEAD'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'HEAD'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -111,7 +99,7 @@ function buildIndicesExists (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index'])
|
||||
path = '/' + encodeURIComponent(index)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -126,10 +114,27 @@ function buildIndicesExists (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesExistsAlias (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -13,6 +16,27 @@ function buildIndicesExistsAlias (opts) {
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesExistsAlias (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -47,58 +71,22 @@ function buildIndicesExistsAlias (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'local',
|
||||
'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 = 'HEAD'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'HEAD'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -106,10 +94,10 @@ function buildIndicesExistsAlias (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['name']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name'])
|
||||
if ((index) != null && (name) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name)
|
||||
} else {
|
||||
path = '/' + '_alias' + '/' + encodeURIComponent(params['name'])
|
||||
path = '/' + '_alias' + '/' + encodeURIComponent(name)
|
||||
}
|
||||
|
||||
// build request object
|
||||
@ -125,10 +113,27 @@ function buildIndicesExistsAlias (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesExistsTemplate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -11,6 +14,25 @@ function buildIndicesExistsTemplate (opts) {
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'flat_settings',
|
||||
'master_timeout',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
flatSettings: 'flat_settings',
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesExistsTemplate (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -45,56 +67,22 @@ function buildIndicesExistsTemplate (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'flat_settings',
|
||||
'master_timeout',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'flatSettings',
|
||||
'masterTimeout',
|
||||
'local',
|
||||
'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 = 'HEAD'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'HEAD'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -102,7 +90,7 @@ function buildIndicesExistsTemplate (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_template' + '/' + encodeURIComponent(params['name'])
|
||||
path = '/' + '_template' + '/' + encodeURIComponent(name)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -117,10 +105,27 @@ function buildIndicesExistsTemplate (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesExistsType (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -13,6 +16,27 @@ function buildIndicesExistsType (opts) {
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesExistsType (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -61,58 +85,22 @@ function buildIndicesExistsType (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'local',
|
||||
'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 = 'HEAD'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'HEAD'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -120,7 +108,7 @@ function buildIndicesExistsType (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type'])
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -135,10 +123,27 @@ function buildIndicesExistsType (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesFlush (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -13,6 +16,29 @@ function buildIndicesFlush (opts) {
|
||||
* @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)
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'force',
|
||||
'wait_if_ongoing',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
waitIfOngoing: 'wait_if_ongoing',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesFlush (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -41,60 +67,22 @@ function buildIndicesFlush (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'force',
|
||||
'wait_if_ongoing',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'force',
|
||||
'waitIfOngoing',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -102,8 +90,8 @@ function buildIndicesFlush (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_flush'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_flush'
|
||||
} else {
|
||||
path = '/' + '_flush'
|
||||
}
|
||||
@ -121,10 +109,27 @@ function buildIndicesFlush (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesFlushSynced (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -11,6 +14,26 @@ function buildIndicesFlushSynced (opts) {
|
||||
* @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)
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesFlushSynced (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -39,56 +62,22 @@ function buildIndicesFlushSynced (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -96,8 +85,8 @@ function buildIndicesFlushSynced (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_flush' + '/' + 'synced'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_flush' + '/' + 'synced'
|
||||
} else {
|
||||
path = '/' + '_flush' + '/' + 'synced'
|
||||
}
|
||||
@ -115,10 +104,27 @@ function buildIndicesFlushSynced (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesForcemerge (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,31 @@ function buildIndicesForcemerge (opts) {
|
||||
* @param {number} max_num_segments - The number of segments the index should be merged into (default: dynamic)
|
||||
* @param {boolean} only_expunge_deletes - Specify whether the operation should only expunge deleted documents
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'flush',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'max_num_segments',
|
||||
'only_expunge_deletes',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
maxNumSegments: 'max_num_segments',
|
||||
onlyExpungeDeletes: 'only_expunge_deletes',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesForcemerge (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -42,62 +70,22 @@ function buildIndicesForcemerge (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'flush',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'max_num_segments',
|
||||
'only_expunge_deletes',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'flush',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'maxNumSegments',
|
||||
'onlyExpungeDeletes',
|
||||
'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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -105,8 +93,8 @@ function buildIndicesForcemerge (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_forcemerge'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_forcemerge'
|
||||
} else {
|
||||
path = '/' + '_forcemerge'
|
||||
}
|
||||
@ -124,10 +112,27 @@ function buildIndicesForcemerge (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesFreeze (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,24 @@ function buildIndicesFreeze (opts) {
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'wait_for_active_shards'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
waitForActiveShards: 'wait_for_active_shards'
|
||||
}
|
||||
|
||||
return function indicesFreeze (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -48,52 +69,22 @@ function buildIndicesFreeze (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'wait_for_active_shards'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'waitForActiveShards'
|
||||
]
|
||||
|
||||
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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -101,7 +92,7 @@ function buildIndicesFreeze (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_freeze'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_freeze'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -116,10 +107,27 @@ function buildIndicesFreeze (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesGet (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -15,6 +18,33 @@ 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
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'local',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'flat_settings',
|
||||
'include_defaults',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
flatSettings: 'flat_settings',
|
||||
includeDefaults: 'include_defaults',
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesGet (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -49,64 +79,22 @@ function buildIndicesGet (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'local',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'flat_settings',
|
||||
'include_defaults',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'local',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'flatSettings',
|
||||
'includeDefaults',
|
||||
'masterTimeout',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -114,7 +102,7 @@ function buildIndicesGet (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index'])
|
||||
path = '/' + encodeURIComponent(index)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -129,10 +117,27 @@ function buildIndicesGet (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesGetAlias (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -13,6 +16,27 @@ function buildIndicesGetAlias (opts) {
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesGetAlias (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -41,58 +65,22 @@ function buildIndicesGetAlias (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -100,12 +88,12 @@ function buildIndicesGetAlias (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['name']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name'])
|
||||
} else if ((params['name']) != null) {
|
||||
path = '/' + '_alias' + '/' + encodeURIComponent(params['name'])
|
||||
} else if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_alias'
|
||||
if ((index) != null && (name) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name)
|
||||
} else if ((name) != null) {
|
||||
path = '/' + '_alias' + '/' + encodeURIComponent(name)
|
||||
} else if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_alias'
|
||||
} else {
|
||||
path = '/' + '_alias'
|
||||
}
|
||||
@ -123,10 +111,27 @@ function buildIndicesGetAlias (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesGetFieldMapping (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -15,6 +18,29 @@ function buildIndicesGetFieldMapping (opts) {
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'include_defaults',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
includeDefaults: 'include_defaults',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesGetFieldMapping (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -49,60 +75,22 @@ function buildIndicesGetFieldMapping (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'include_defaults',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'includeDefaults',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, type, fields } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'type', 'fields'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -110,14 +98,14 @@ function buildIndicesGetFieldMapping (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null && (params['fields']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + '/' + 'field' + '/' + encodeURIComponent(params['fields'])
|
||||
} else if ((params['index']) != null && (params['fields']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(params['fields'])
|
||||
} else if ((params['type']) != null && (params['fields']) != null) {
|
||||
path = '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + '/' + 'field' + '/' + encodeURIComponent(params['fields'])
|
||||
if ((index) != null && (type) != null && (fields) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type) + '/' + 'field' + '/' + encodeURIComponent(fields)
|
||||
} else if ((index) != null && (fields) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields)
|
||||
} else if ((type) != null && (fields) != null) {
|
||||
path = '/' + '_mapping' + '/' + encodeURIComponent(type) + '/' + 'field' + '/' + encodeURIComponent(fields)
|
||||
} else {
|
||||
path = '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(params['fields'])
|
||||
path = '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields)
|
||||
}
|
||||
|
||||
// build request object
|
||||
@ -133,10 +121,27 @@ function buildIndicesGetFieldMapping (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesGetMapping (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -15,6 +18,31 @@ function buildIndicesGetMapping (opts) {
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'include_type_name',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'master_timeout',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
includeTypeName: 'include_type_name',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesGetMapping (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -43,62 +71,22 @@ function buildIndicesGetMapping (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'include_type_name',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'master_timeout',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'includeTypeName',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'masterTimeout',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -106,12 +94,12 @@ function buildIndicesGetMapping (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type'])
|
||||
} else if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping'
|
||||
} else if ((params['type']) != null) {
|
||||
path = '/' + '_mapping' + '/' + encodeURIComponent(params['type'])
|
||||
if ((index) != null && (type) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type)
|
||||
} else if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mapping'
|
||||
} else if ((type) != null) {
|
||||
path = '/' + '_mapping' + '/' + encodeURIComponent(type)
|
||||
} else {
|
||||
path = '/' + '_mapping'
|
||||
}
|
||||
@ -129,10 +117,27 @@ function buildIndicesGetMapping (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesGetSettings (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -16,6 +19,33 @@ function buildIndicesGetSettings (opts) {
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {boolean} include_defaults - Whether to return all default setting for each of the indices.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'flat_settings',
|
||||
'local',
|
||||
'include_defaults',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
flatSettings: 'flat_settings',
|
||||
includeDefaults: 'include_defaults',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesGetSettings (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,64 +74,22 @@ function buildIndicesGetSettings (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'flat_settings',
|
||||
'local',
|
||||
'include_defaults',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'masterTimeout',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'flatSettings',
|
||||
'local',
|
||||
'includeDefaults',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -109,12 +97,12 @@ function buildIndicesGetSettings (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['name']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_settings' + '/' + encodeURIComponent(params['name'])
|
||||
} else if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_settings'
|
||||
} else if ((params['name']) != null) {
|
||||
path = '/' + '_settings' + '/' + encodeURIComponent(params['name'])
|
||||
if ((index) != null && (name) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_settings' + '/' + encodeURIComponent(name)
|
||||
} else if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_settings'
|
||||
} else if ((name) != null) {
|
||||
path = '/' + '_settings' + '/' + encodeURIComponent(name)
|
||||
} else {
|
||||
path = '/' + '_settings'
|
||||
}
|
||||
@ -132,10 +120,27 @@ function buildIndicesGetSettings (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesGetTemplate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -11,6 +14,25 @@ function buildIndicesGetTemplate (opts) {
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'flat_settings',
|
||||
'master_timeout',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
flatSettings: 'flat_settings',
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesGetTemplate (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -39,56 +61,22 @@ function buildIndicesGetTemplate (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'flat_settings',
|
||||
'master_timeout',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'flatSettings',
|
||||
'masterTimeout',
|
||||
'local',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -96,8 +84,8 @@ function buildIndicesGetTemplate (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['name']) != null) {
|
||||
path = '/' + '_template' + '/' + encodeURIComponent(params['name'])
|
||||
if ((name) != null) {
|
||||
path = '/' + '_template' + '/' + encodeURIComponent(name)
|
||||
} else {
|
||||
path = '/' + '_template'
|
||||
}
|
||||
@ -115,10 +103,27 @@ function buildIndicesGetTemplate (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesGetUpgrade (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -11,6 +14,26 @@ function buildIndicesGetUpgrade (opts) {
|
||||
* @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)
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesGetUpgrade (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -39,56 +62,22 @@ function buildIndicesGetUpgrade (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -96,8 +85,8 @@ function buildIndicesGetUpgrade (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_upgrade'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_upgrade'
|
||||
} else {
|
||||
path = '/' + '_upgrade'
|
||||
}
|
||||
@ -115,10 +104,27 @@ function buildIndicesGetUpgrade (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesOpen (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,31 @@ function buildIndicesOpen (opts) {
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'wait_for_active_shards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesOpen (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -48,62 +76,22 @@ function buildIndicesOpen (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'wait_for_active_shards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'waitForActiveShards',
|
||||
'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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -111,7 +99,7 @@ function buildIndicesOpen (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_open'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_open'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -126,10 +114,27 @@ function buildIndicesOpen (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesPutAlias (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -12,6 +15,23 @@ function buildIndicesPutAlias (opts) {
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {object} body - The settings for the alias, such as `routing` or `filter`
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesPutAlias (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -54,54 +74,22 @@ function buildIndicesPutAlias (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -109,17 +97,17 @@ function buildIndicesPutAlias (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['name']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name'])
|
||||
if ((index) != null && (name) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name)
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_aliases' + '/' + encodeURIComponent(params['name'])
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name)
|
||||
}
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -128,10 +116,27 @@ function buildIndicesPutAlias (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesPutMapping (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -16,6 +19,31 @@ function buildIndicesPutMapping (opts) {
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {object} body - The mapping definition
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'include_type_name',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
includeTypeName: 'include_type_name',
|
||||
masterTimeout: 'master_timeout',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesPutMapping (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,62 +72,22 @@ function buildIndicesPutMapping (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'include_type_name',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'includeTypeName',
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, type } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -107,29 +95,29 @@ function buildIndicesPutMapping (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['type']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mapping'
|
||||
} else if ((params['index']) != null && (params['type']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type'])
|
||||
} else if ((params['index']) != null && (params['type']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mappings'
|
||||
} else if ((params['index']) != null && (params['type']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_mappings' + '/' + encodeURIComponent(params['type'])
|
||||
} else if ((params['type']) != null) {
|
||||
path = '/' + '_mapping' + '/' + encodeURIComponent(params['type'])
|
||||
} else if ((params['type']) != null) {
|
||||
path = '/' + '_mappings' + '/' + encodeURIComponent(params['type'])
|
||||
} else if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_mappings'
|
||||
if ((index) != null && (type) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mapping'
|
||||
} else if ((index) != null && (type) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type)
|
||||
} else if ((index) != null && (type) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mappings'
|
||||
} else if ((index) != null && (type) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mappings' + '/' + encodeURIComponent(type)
|
||||
} else if ((type) != null) {
|
||||
path = '/' + '_mapping' + '/' + encodeURIComponent(type)
|
||||
} else if ((type) != null) {
|
||||
path = '/' + '_mappings' + '/' + encodeURIComponent(type)
|
||||
} else if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mappings'
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mapping'
|
||||
}
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -138,10 +126,27 @@ function buildIndicesPutMapping (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesPutSettings (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -16,6 +19,33 @@ function buildIndicesPutSettings (opts) {
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {object} body - The index settings to be updated
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'preserve_existing',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'flat_settings',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
preserveExisting: 'preserve_existing',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
flatSettings: 'flat_settings',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesPutSettings (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,64 +74,22 @@ function buildIndicesPutSettings (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'preserve_existing',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'flat_settings',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'masterTimeout',
|
||||
'timeout',
|
||||
'preserveExisting',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'flatSettings',
|
||||
'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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -109,8 +97,8 @@ function buildIndicesPutSettings (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_settings'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_settings'
|
||||
} else {
|
||||
path = '/' + '_settings'
|
||||
}
|
||||
@ -119,7 +107,7 @@ function buildIndicesPutSettings (opts) {
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -128,10 +116,27 @@ function buildIndicesPutSettings (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesPutTemplate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,27 @@ function buildIndicesPutTemplate (opts) {
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {object} body - The template definition
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'order',
|
||||
'create',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'flat_settings',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
flatSettings: 'flat_settings',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesPutTemplate (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -48,60 +72,22 @@ function buildIndicesPutTemplate (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'order',
|
||||
'create',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'flat_settings',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'order',
|
||||
'create',
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'flatSettings',
|
||||
'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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, name } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'name'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -109,13 +95,13 @@ function buildIndicesPutTemplate (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + '_template' + '/' + encodeURIComponent(params['name'])
|
||||
path = '/' + '_template' + '/' + encodeURIComponent(name)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -124,10 +110,27 @@ function buildIndicesPutTemplate (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesRecovery (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -10,6 +13,23 @@ function buildIndicesRecovery (opts) {
|
||||
* @param {boolean} detailed - Whether to display detailed information about shard recovery
|
||||
* @param {boolean} active_only - Display only those recoveries that are currently on-going
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'detailed',
|
||||
'active_only',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
activeOnly: 'active_only',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesRecovery (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -38,54 +58,22 @@ function buildIndicesRecovery (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'detailed',
|
||||
'active_only',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'detailed',
|
||||
'activeOnly',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -93,8 +81,8 @@ function buildIndicesRecovery (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_recovery'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_recovery'
|
||||
} else {
|
||||
path = '/' + '_recovery'
|
||||
}
|
||||
@ -112,10 +100,27 @@ function buildIndicesRecovery (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesRefresh (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -11,6 +14,26 @@ function buildIndicesRefresh (opts) {
|
||||
* @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)
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesRefresh (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -39,56 +62,22 @@ function buildIndicesRefresh (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -96,8 +85,8 @@ function buildIndicesRefresh (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_refresh'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_refresh'
|
||||
} else {
|
||||
path = '/' + '_refresh'
|
||||
}
|
||||
@ -115,10 +104,27 @@ function buildIndicesRefresh (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesRollover (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,27 @@ function buildIndicesRollover (opts) {
|
||||
* @param {string} wait_for_active_shards - Set the number of active shards to wait for on the newly created rollover index before the operation returns.
|
||||
* @param {object} body - The conditions that needs to be met for executing rollover
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'dry_run',
|
||||
'master_timeout',
|
||||
'wait_for_active_shards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
dryRun: 'dry_run',
|
||||
masterTimeout: 'master_timeout',
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesRollover (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -50,58 +74,22 @@ function buildIndicesRollover (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'dry_run',
|
||||
'master_timeout',
|
||||
'wait_for_active_shards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'dryRun',
|
||||
'masterTimeout',
|
||||
'waitForActiveShards',
|
||||
'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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, alias, newIndex, new_index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'alias', 'newIndex', 'new_index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -109,17 +97,17 @@ function buildIndicesRollover (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['alias']) != null && (params['new_index'] || params['newIndex']) != null) {
|
||||
path = '/' + encodeURIComponent(params['alias']) + '/' + '_rollover' + '/' + encodeURIComponent(params['new_index'] || params['newIndex'])
|
||||
if ((alias) != null && (new_index || newIndex) != null) {
|
||||
path = '/' + encodeURIComponent(alias) + '/' + '_rollover' + '/' + encodeURIComponent(new_index || newIndex)
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(params['alias']) + '/' + '_rollover'
|
||||
path = '/' + encodeURIComponent(alias) + '/' + '_rollover'
|
||||
}
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -128,10 +116,27 @@ function buildIndicesRollover (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesSegments (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -12,6 +15,27 @@ function buildIndicesSegments (opts) {
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {boolean} verbose - Includes detailed memory usage by Lucene.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'verbose',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesSegments (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -40,58 +64,22 @@ function buildIndicesSegments (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'verbose',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'verbose',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -99,8 +87,8 @@ function buildIndicesSegments (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_segments'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_segments'
|
||||
} else {
|
||||
path = '/' + '_segments'
|
||||
}
|
||||
@ -118,10 +106,27 @@ function buildIndicesSegments (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesShardStores (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -12,6 +15,27 @@ function buildIndicesShardStores (opts) {
|
||||
* @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)
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'status',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesShardStores (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -40,58 +64,22 @@ function buildIndicesShardStores (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'status',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'status',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -99,8 +87,8 @@ function buildIndicesShardStores (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_shard_stores'
|
||||
if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_shard_stores'
|
||||
} else {
|
||||
path = '/' + '_shard_stores'
|
||||
}
|
||||
@ -118,10 +106,27 @@ function buildIndicesShardStores (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesShrink (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,27 @@ function buildIndicesShrink (opts) {
|
||||
* @param {string} wait_for_active_shards - Set the number of active shards to wait for on the shrunken index before the operation returns.
|
||||
* @param {object} body - The configuration for the target index (`settings` and `aliases`)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'copy_settings',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'wait_for_active_shards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
copySettings: 'copy_settings',
|
||||
masterTimeout: 'master_timeout',
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesShrink (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -56,58 +80,22 @@ function buildIndicesShrink (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'copy_settings',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'wait_for_active_shards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'copySettings',
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'waitForActiveShards',
|
||||
'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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, target } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'target'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -115,13 +103,13 @@ function buildIndicesShrink (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_shrink' + '/' + encodeURIComponent(params['target'])
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_shrink' + '/' + encodeURIComponent(target)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -130,10 +118,27 @@ function buildIndicesShrink (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesSplit (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,27 @@ function buildIndicesSplit (opts) {
|
||||
* @param {string} wait_for_active_shards - Set the number of active shards to wait for on the shrunken index before the operation returns.
|
||||
* @param {object} body - The configuration for the target index (`settings` and `aliases`)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'copy_settings',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'wait_for_active_shards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
copySettings: 'copy_settings',
|
||||
masterTimeout: 'master_timeout',
|
||||
waitForActiveShards: 'wait_for_active_shards',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesSplit (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -56,58 +80,22 @@ function buildIndicesSplit (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'copy_settings',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'wait_for_active_shards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'copySettings',
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'waitForActiveShards',
|
||||
'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 = 'PUT'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, target } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'target'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'PUT'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -115,13 +103,13 @@ function buildIndicesSplit (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_split' + '/' + encodeURIComponent(params['target'])
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_split' + '/' + encodeURIComponent(target)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: params.body || '',
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
@ -130,10 +118,27 @@ function buildIndicesSplit (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesStats (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -16,6 +19,30 @@ function buildIndicesStats (opts) {
|
||||
* @param {list} types - A comma-separated list of document types for the `indexing` index metric
|
||||
* @param {boolean} include_segment_file_sizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested)
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'completion_fields',
|
||||
'fielddata_fields',
|
||||
'fields',
|
||||
'groups',
|
||||
'level',
|
||||
'types',
|
||||
'include_segment_file_sizes',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
completionFields: 'completion_fields',
|
||||
fielddataFields: 'fielddata_fields',
|
||||
includeSegmentFileSizes: 'include_segment_file_sizes',
|
||||
errorTrace: 'error_trace',
|
||||
filterPath: 'filter_path'
|
||||
}
|
||||
|
||||
return function indicesStats (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -44,64 +71,22 @@ function buildIndicesStats (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'completion_fields',
|
||||
'fielddata_fields',
|
||||
'fields',
|
||||
'groups',
|
||||
'level',
|
||||
'types',
|
||||
'include_segment_file_sizes',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'completionFields',
|
||||
'fielddataFields',
|
||||
'fields',
|
||||
'groups',
|
||||
'level',
|
||||
'types',
|
||||
'includeSegmentFileSizes',
|
||||
'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') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index, metric } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index', 'metric'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -109,12 +94,12 @@ function buildIndicesStats (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
if ((params['index']) != null && (params['metric']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_stats' + '/' + encodeURIComponent(params['metric'])
|
||||
} else if ((params['metric']) != null) {
|
||||
path = '/' + '_stats' + '/' + encodeURIComponent(params['metric'])
|
||||
} else if ((params['index']) != null) {
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_stats'
|
||||
if ((index) != null && (metric) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_stats' + '/' + encodeURIComponent(metric)
|
||||
} else if ((metric) != null) {
|
||||
path = '/' + '_stats' + '/' + encodeURIComponent(metric)
|
||||
} else if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_stats'
|
||||
} else {
|
||||
path = '/' + '_stats'
|
||||
}
|
||||
@ -132,10 +117,27 @@ function buildIndicesStats (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
function buildIndicesUnfreeze (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError, result } = opts
|
||||
@ -14,6 +17,24 @@ function buildIndicesUnfreeze (opts) {
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns.
|
||||
*/
|
||||
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'wait_for_active_shards'
|
||||
]
|
||||
|
||||
const snakeCase = {
|
||||
masterTimeout: 'master_timeout',
|
||||
ignoreUnavailable: 'ignore_unavailable',
|
||||
allowNoIndices: 'allow_no_indices',
|
||||
expandWildcards: 'expand_wildcards',
|
||||
waitForActiveShards: 'wait_for_active_shards'
|
||||
}
|
||||
|
||||
return function indicesUnfreeze (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
@ -48,52 +69,22 @@ function buildIndicesUnfreeze (opts) {
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'wait_for_active_shards'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'waitForActiveShards'
|
||||
]
|
||||
|
||||
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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
var warnings = null
|
||||
var { method, body, index } = params
|
||||
var querystring = semicopy(params, ['method', 'body', 'index'])
|
||||
|
||||
if (method == null) {
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
var ignore = options.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
@ -101,7 +92,7 @@ function buildIndicesUnfreeze (opts) {
|
||||
|
||||
var path = ''
|
||||
|
||||
path = '/' + encodeURIComponent(params['index']) + '/' + '_unfreeze'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_unfreeze'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -116,10 +107,27 @@ function buildIndicesUnfreeze (opts) {
|
||||
requestTimeout: options.requestTimeout || null,
|
||||
maxRetries: options.maxRetries || null,
|
||||
asStream: options.asStream || false,
|
||||
headers: options.headers || null
|
||||
headers: options.headers || null,
|
||||
warnings
|
||||
}
|
||||
|
||||
return makeRequest(request, requestOptions, callback)
|
||||
|
||||
function semicopy (obj, exclude) {
|
||||
var target = {}
|
||||
var keys = Object.keys(obj)
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (exclude.indexOf(key) === -1) {
|
||||
target[snakeCase[key] || key] = obj[key]
|
||||
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
|
||||
warnings = warnings || []
|
||||
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user