API generation
This commit is contained in:
140
api/api/bulk.js
Normal file
140
api/api/bulk.js
Normal file
@ -0,0 +1,140 @@
|
||||
'use strict'
|
||||
|
||||
function buildBulk (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [bulk](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html) request
|
||||
*
|
||||
* @param {string} index - Default index for items which don't provide one
|
||||
* @param {string} type - Default document type for items which don't provide one
|
||||
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
|
||||
* @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
|
||||
* @param {string} routing - Specific routing value
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {string} type - Default document type for items which don't provide one
|
||||
* @param {list} fields - Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request
|
||||
* @param {list} _source - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request
|
||||
* @param {list} _source_exclude - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
|
||||
* @param {list} _source_include - Default list of fields to extract and return from the _source field, can be overridden on each sub-request
|
||||
* @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
|
||||
*/
|
||||
return function bulk (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
bulk(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'wait_for_active_shards',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'type',
|
||||
'fields',
|
||||
'_source',
|
||||
'_source_exclude',
|
||||
'_source_include',
|
||||
'pipeline',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'waitForActiveShards',
|
||||
'refresh',
|
||||
'routing',
|
||||
'timeout',
|
||||
'type',
|
||||
'fields',
|
||||
'_source',
|
||||
'_sourceExclude',
|
||||
'_sourceInclude',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], '_bulk']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
bulkBody: params.body,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildBulk
|
||||
121
api/api/cat.aliases.js
Normal file
121
api/api/cat.aliases.js
Normal file
@ -0,0 +1,121 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatAliases (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.aliases](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html) request
|
||||
*
|
||||
* @param {list} name - A comma-separated list of alias names to return
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catAliases (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catAliases(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'aliases', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatAliases
|
||||
124
api/api/cat.allocation.js
Normal file
124
api/api/cat.allocation.js
Normal file
@ -0,0 +1,124 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatAllocation (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.allocation](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html) request
|
||||
*
|
||||
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {enum} bytes - The unit in which to display byte values
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catAllocation (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catAllocation(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'allocation', params['node_id'] || params['nodeId']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatAllocation
|
||||
121
api/api/cat.count.js
Normal file
121
api/api/cat.count.js
Normal file
@ -0,0 +1,121 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatCount (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.count](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to limit the returned information
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catCount (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catCount(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'count', params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatCount
|
||||
127
api/api/cat.fielddata.js
Normal file
127
api/api/cat.fielddata.js
Normal file
@ -0,0 +1,127 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatFielddata (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.fielddata](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html) request
|
||||
*
|
||||
* @param {list} fields - A comma-separated list of fields to return the fielddata size
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {enum} bytes - The unit in which to display byte values
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
* @param {list} fields - A comma-separated list of fields to return in the output
|
||||
*/
|
||||
return function catFielddata (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catFielddata(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'fielddata', params['fields']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatFielddata
|
||||
123
api/api/cat.health.js
Normal file
123
api/api/cat.health.js
Normal file
@ -0,0 +1,123 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatHealth (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html) request
|
||||
*
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} ts - Set to false to disable timestamping
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catHealth (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catHealth(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'health']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatHealth
|
||||
105
api/api/cat.help.js
Normal file
105
api/api/cat.help.js
Normal file
@ -0,0 +1,105 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatHelp (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.help](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html) request
|
||||
*
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
*/
|
||||
return function catHelp (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catHelp(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatHelp
|
||||
130
api/api/cat.indices.js
Normal file
130
api/api/cat.indices.js
Normal file
@ -0,0 +1,130 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatIndices (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.indices](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to limit the returned information
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {enum} bytes - The unit in which to display byte values
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {enum} health - A health status ("green", "yellow", or "red" to filter only indices matching the specified health status
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {boolean} pri - Set to true to return stats only for primary shards
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catIndices (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catIndices(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'indices', params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatIndices
|
||||
120
api/api/cat.master.js
Normal file
120
api/api/cat.master.js
Normal file
@ -0,0 +1,120 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatMaster (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.master](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html) request
|
||||
*
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catMaster (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catMaster(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'master']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatMaster
|
||||
120
api/api/cat.nodeattrs.js
Normal file
120
api/api/cat.nodeattrs.js
Normal file
@ -0,0 +1,120 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatNodeattrs (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.nodeattrs](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html) request
|
||||
*
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catNodeattrs (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catNodeattrs(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'nodeattrs']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatNodeattrs
|
||||
123
api/api/cat.nodes.js
Normal file
123
api/api/cat.nodes.js
Normal file
@ -0,0 +1,123 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatNodes (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.nodes](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html) request
|
||||
*
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} full_id - Return the full node ID instead of the shortened version (default: false)
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catNodes (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catNodes(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'nodes']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatNodes
|
||||
120
api/api/cat.pending_tasks.js
Normal file
120
api/api/cat.pending_tasks.js
Normal file
@ -0,0 +1,120 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatPendingTasks (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html) request
|
||||
*
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catPendingTasks (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catPendingTasks(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'pending_tasks']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatPendingTasks
|
||||
120
api/api/cat.plugins.js
Normal file
120
api/api/cat.plugins.js
Normal file
@ -0,0 +1,120 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatPlugins (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.plugins](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html) request
|
||||
*
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catPlugins (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catPlugins(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'plugins']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatPlugins
|
||||
121
api/api/cat.recovery.js
Normal file
121
api/api/cat.recovery.js
Normal file
@ -0,0 +1,121 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatRecovery (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to limit the returned information
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {enum} bytes - The unit in which to display byte values
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catRecovery (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catRecovery(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'format',
|
||||
'bytes',
|
||||
'master_timeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'format',
|
||||
'bytes',
|
||||
'masterTimeout',
|
||||
'h',
|
||||
'help',
|
||||
's',
|
||||
'v',
|
||||
'pretty',
|
||||
'human',
|
||||
'errorTrace',
|
||||
'source',
|
||||
'filterPath'
|
||||
]
|
||||
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i]
|
||||
if (acceptedQuerystring.indexOf(key) !== -1) {
|
||||
querystring[key] = params[key]
|
||||
} else {
|
||||
var camelIndex = acceptedQuerystringCamelCased.indexOf(key)
|
||||
if (camelIndex !== -1) {
|
||||
querystring[acceptedQuerystring[camelIndex]] = params[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// configure http method
|
||||
var method = params.method
|
||||
if (method == null) {
|
||||
method = 'GET'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'recovery', params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatRecovery
|
||||
120
api/api/cat.repositories.js
Normal file
120
api/api/cat.repositories.js
Normal file
@ -0,0 +1,120 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatRepositories (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.repositories](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html) request
|
||||
*
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catRepositories (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catRepositories(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'repositories']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatRepositories
|
||||
118
api/api/cat.segments.js
Normal file
118
api/api/cat.segments.js
Normal file
@ -0,0 +1,118 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatSegments (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.segments](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to limit the returned information
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {enum} bytes - The unit in which to display byte values
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catSegments (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catSegments(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'segments', params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatSegments
|
||||
124
api/api/cat.shards.js
Normal file
124
api/api/cat.shards.js
Normal file
@ -0,0 +1,124 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatShards (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.shards](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to limit the returned information
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {enum} bytes - The unit in which to display byte values
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catShards (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catShards(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'shards', params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatShards
|
||||
121
api/api/cat.snapshots.js
Normal file
121
api/api/cat.snapshots.js
Normal file
@ -0,0 +1,121 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatSnapshots (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html) request
|
||||
*
|
||||
* @param {list} repository - Name of repository from which to fetch the snapshot information
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} ignore_unavailable - Set to true to ignore unavailable snapshots
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catSnapshots (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catSnapshots(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'snapshots', params['repository']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatSnapshots
|
||||
126
api/api/cat.tasks.js
Normal file
126
api/api/cat.tasks.js
Normal file
@ -0,0 +1,126 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatTasks (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request
|
||||
*
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
|
||||
* @param {list} actions - A comma-separated list of actions that should be returned. Leave empty to return all.
|
||||
* @param {boolean} detailed - Return detailed task information (default: false)
|
||||
* @param {number} parent_task - Return tasks with specified parent task id. Set to -1 to return all.
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catTasks (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catTasks(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'tasks']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatTasks
|
||||
121
api/api/cat.templates.js
Normal file
121
api/api/cat.templates.js
Normal file
@ -0,0 +1,121 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatTemplates (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.templates](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html) request
|
||||
*
|
||||
* @param {string} name - A pattern that returned template names must match
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catTemplates (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catTemplates(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'templates', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatTemplates
|
||||
124
api/api/cat.thread_pool.js
Normal file
124
api/api/cat.thread_pool.js
Normal file
@ -0,0 +1,124 @@
|
||||
'use strict'
|
||||
|
||||
function buildCatThreadPool (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cat.thread_pool](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html) request
|
||||
*
|
||||
* @param {list} thread_pool_patterns - A comma-separated list of regular-expressions to filter the thread pools in the output
|
||||
* @param {string} format - a short version of the Accept header, e.g. json, yaml
|
||||
* @param {enum} size - The multiplier in which to display values
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {list} h - Comma-separated list of column names to display
|
||||
* @param {boolean} help - Return help information
|
||||
* @param {list} s - Comma-separated list of column names or column aliases to sort by
|
||||
* @param {boolean} v - Verbose mode. Display column headers
|
||||
*/
|
||||
return function catThreadPool (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
catThreadPool(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cat', 'thread_pool', params['thread_pool_patterns'] || params['threadPoolPatterns']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCatThreadPool
|
||||
93
api/api/clear_scroll.js
Normal file
93
api/api/clear_scroll.js
Normal file
@ -0,0 +1,93 @@
|
||||
'use strict'
|
||||
|
||||
function buildClearScroll (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [clear_scroll](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html) request
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
return function clearScroll (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clearScroll(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_search', 'scroll', params['scroll_id'] || params['scrollId']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildClearScroll
|
||||
98
api/api/cluster.allocation_explain.js
Normal file
98
api/api/cluster.allocation_explain.js
Normal file
@ -0,0 +1,98 @@
|
||||
'use strict'
|
||||
|
||||
function buildClusterAllocationExplain (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cluster.allocation_explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html) request
|
||||
*
|
||||
* @param {boolean} include_yes_decisions - Return 'YES' decisions in explanation (default: false)
|
||||
* @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'
|
||||
*/
|
||||
return function clusterAllocationExplain (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clusterAllocationExplain(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cluster', 'allocation', 'explain']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildClusterAllocationExplain
|
||||
111
api/api/cluster.get_settings.js
Normal file
111
api/api/cluster.get_settings.js
Normal file
@ -0,0 +1,111 @@
|
||||
'use strict'
|
||||
|
||||
function buildClusterGetSettings (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cluster.get_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request
|
||||
*
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {boolean} include_defaults - Whether to return all default clusters setting.
|
||||
*/
|
||||
return function clusterGetSettings (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clusterGetSettings(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cluster', 'settings']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildClusterGetSettings
|
||||
130
api/api/cluster.health.js
Normal file
130
api/api/cluster.health.js
Normal file
@ -0,0 +1,130 @@
|
||||
'use strict'
|
||||
|
||||
function buildClusterHealth (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cluster.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html) request
|
||||
*
|
||||
* @param {list} index - Limit the information returned to a specific index
|
||||
* @param {enum} level - Specify the level of detail for returned information
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {string} wait_for_active_shards - Wait until the specified number of shards is active
|
||||
* @param {string} wait_for_nodes - Wait until the specified number of nodes is available
|
||||
* @param {enum} wait_for_events - Wait until all currently queued events with the given priority are processed
|
||||
* @param {boolean} wait_for_no_relocating_shards - Whether to wait until there are no relocating shards in the cluster
|
||||
* @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
|
||||
*/
|
||||
return function clusterHealth (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clusterHealth(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cluster', 'health', params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildClusterHealth
|
||||
105
api/api/cluster.pending_tasks.js
Normal file
105
api/api/cluster.pending_tasks.js
Normal file
@ -0,0 +1,105 @@
|
||||
'use strict'
|
||||
|
||||
function buildClusterPendingTasks (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cluster.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html) request
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
return function clusterPendingTasks (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clusterPendingTasks(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cluster', 'pending_tasks']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildClusterPendingTasks
|
||||
109
api/api/cluster.put_settings.js
Normal file
109
api/api/cluster.put_settings.js
Normal file
@ -0,0 +1,109 @@
|
||||
'use strict'
|
||||
|
||||
function buildClusterPutSettings (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cluster.put_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request
|
||||
*
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {object} body - The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart).
|
||||
*/
|
||||
return function clusterPutSettings (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clusterPutSettings(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cluster', 'settings']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildClusterPutSettings
|
||||
99
api/api/cluster.remote_info.js
Normal file
99
api/api/cluster.remote_info.js
Normal file
@ -0,0 +1,99 @@
|
||||
'use strict'
|
||||
|
||||
function buildClusterRemoteInfo (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cluster.remote_info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html) request
|
||||
*
|
||||
*/
|
||||
return function clusterRemoteInfo (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clusterRemoteInfo(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_remote', 'info']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildClusterRemoteInfo
|
||||
110
api/api/cluster.reroute.js
Normal file
110
api/api/cluster.reroute.js
Normal file
@ -0,0 +1,110 @@
|
||||
'use strict'
|
||||
|
||||
function buildClusterReroute (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cluster.reroute](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html) request
|
||||
*
|
||||
* @param {boolean} dry_run - Simulate the operation only and return the resulting state
|
||||
* @param {boolean} explain - Return an explanation of why the commands can or cannot be executed
|
||||
* @param {boolean} retry_failed - Retries allocation of shards that are blocked due to too many subsequent allocation failures
|
||||
* @param {list} metric - Limit the information returned to the specified metrics. Defaults to all but metadata
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {object} body - The definition of `commands` to perform (`move`, `cancel`, `allocate`)
|
||||
*/
|
||||
return function clusterReroute (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clusterReroute(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cluster', 'reroute']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildClusterReroute
|
||||
127
api/api/cluster.state.js
Normal file
127
api/api/cluster.state.js
Normal file
@ -0,0 +1,127 @@
|
||||
'use strict'
|
||||
|
||||
function buildClusterState (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cluster.state](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {list} metric - Limit the information returned to the specified metrics
|
||||
* @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
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
*/
|
||||
return function clusterState (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clusterState(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['index'] != null && (params['metric'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: metric'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'local',
|
||||
'master_timeout',
|
||||
'flat_settings',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'local',
|
||||
'masterTimeout',
|
||||
'flatSettings',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cluster', 'state', params['metric'], params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildClusterState
|
||||
108
api/api/cluster.stats.js
Normal file
108
api/api/cluster.stats.js
Normal file
@ -0,0 +1,108 @@
|
||||
'use strict'
|
||||
|
||||
function buildClusterStats (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [cluster.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html) request
|
||||
*
|
||||
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
*/
|
||||
return function clusterStats (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clusterStats(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cluster', 'stats', 'nodes', params['node_id'] || params['nodeId']]
|
||||
const request = {
|
||||
method,
|
||||
path: (params['node_id'] || params['nodeId']) != null
|
||||
? '/' + parts.filter(Boolean).join('/')
|
||||
: '/_cluster/stats',
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildClusterStats
|
||||
141
api/api/count.js
Normal file
141
api/api/count.js
Normal file
@ -0,0 +1,141 @@
|
||||
'use strict'
|
||||
|
||||
function buildCount (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [count](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of indices to restrict the results
|
||||
* @param {list} type - A comma-separated list of types to restrict the results
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {number} min_score - Include only documents with a specific `_score` value in the result
|
||||
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
|
||||
* @param {list} routing - A comma-separated list of specific routing values
|
||||
* @param {string} q - Query in the Lucene query string syntax
|
||||
* @param {string} analyzer - The analyzer to use for the query string
|
||||
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
|
||||
* @param {enum} default_operator - The default operator for query string query (AND or OR)
|
||||
* @param {string} df - The field to use as default where no field prefix is given in the query string
|
||||
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
|
||||
* @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)
|
||||
*/
|
||||
return function count (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
count(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'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',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], '_count']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCount
|
||||
158
api/api/create.js
Normal file
158
api/api/create.js
Normal file
@ -0,0 +1,158 @@
|
||||
'use strict'
|
||||
|
||||
function buildCreate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [create](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request
|
||||
*
|
||||
* @param {string} id - Document ID
|
||||
* @param {string} index - The name of the index
|
||||
* @param {string} type - The type of the document
|
||||
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
|
||||
* @param {string} parent - ID of the parent document
|
||||
* @param {enum} refresh - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
|
||||
* @param {string} routing - Specific routing value
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
* @param {string} pipeline - The pipeline id to preprocess incoming documents with
|
||||
* @param {object} body - The document
|
||||
*/
|
||||
return function create (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
create(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['type'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: type'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: type, index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
} else if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], params['id'], '_create']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildCreate
|
||||
154
api/api/delete.js
Normal file
154
api/api/delete.js
Normal file
@ -0,0 +1,154 @@
|
||||
'use strict'
|
||||
|
||||
function buildDelete (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html) request
|
||||
*
|
||||
* @param {string} id - The document ID
|
||||
* @param {string} index - The name of the index
|
||||
* @param {string} type - The type of the document
|
||||
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
|
||||
* @param {string} parent - ID of parent document
|
||||
* @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
|
||||
* @param {string} routing - Specific routing value
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
*/
|
||||
return function _delete (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
_delete(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['type'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: type'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: type, index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
} else if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], params['id']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildDelete
|
||||
212
api/api/delete_by_query.js
Normal file
212
api/api/delete_by_query.js
Normal file
@ -0,0 +1,212 @@
|
||||
'use strict'
|
||||
|
||||
function buildDeleteByQuery (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [delete_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
|
||||
* @param {string} analyzer - The analyzer to use for the query string
|
||||
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
|
||||
* @param {enum} default_operator - The default operator for query string query (AND or OR)
|
||||
* @param {string} df - The field to use as default where no field prefix is given in the query string
|
||||
* @param {number} from - Starting offset (default: 0)
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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} conflicts - What to do when the delete by query hits version conflicts?
|
||||
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
||||
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
|
||||
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
|
||||
* @param {string} q - Query in the Lucene query string syntax
|
||||
* @param {list} routing - A comma-separated list of specific routing values
|
||||
* @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search
|
||||
* @param {enum} search_type - Search operation type
|
||||
* @param {time} search_timeout - Explicit timeout for each search request. Defaults to no timeout.
|
||||
* @param {number} size - Number of hits to return (default: 10)
|
||||
* @param {list} sort - A comma-separated list of <field>:<direction> pairs
|
||||
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
|
||||
* @param {list} _source_exclude - A list of fields to exclude from the returned _source field
|
||||
* @param {list} _source_include - A list of fields to extract and return from the _source field
|
||||
* @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
|
||||
* @param {list} stats - Specific 'tag' of the request for logging and statistical purposes
|
||||
* @param {boolean} version - Specify whether to return document version as part of a hit
|
||||
* @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting
|
||||
* @param {boolean} refresh - Should the effected indexes be refreshed?
|
||||
* @param {time} timeout - Time each individual bulk request should wait for shards that are unavailable.
|
||||
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
|
||||
* @param {number} scroll_size - Size on the scroll request powering the delete by query
|
||||
* @param {boolean} wait_for_completion - Should the request should block until the delete by query is complete.
|
||||
* @param {number} requests_per_second - The throttle for this request in sub-requests per second. -1 means no throttle.
|
||||
* @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
|
||||
*/
|
||||
return function deleteByQuery (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
deleteByQuery(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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_exclude',
|
||||
'_source_include',
|
||||
'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',
|
||||
'_sourceExclude',
|
||||
'_sourceInclude',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], '_delete_by_query']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildDeleteByQuery
|
||||
112
api/api/delete_script.js
Normal file
112
api/api/delete_script.js
Normal file
@ -0,0 +1,112 @@
|
||||
'use strict'
|
||||
|
||||
function buildDeleteScript (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [delete_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request
|
||||
*
|
||||
* @param {string} id - Script ID
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
return function deleteScript (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
deleteScript(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_scripts', params['id']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildDeleteScript
|
||||
166
api/api/exists.js
Normal file
166
api/api/exists.js
Normal file
@ -0,0 +1,166 @@
|
||||
'use strict'
|
||||
|
||||
function buildExists (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request
|
||||
*
|
||||
* @param {string} id - The document ID
|
||||
* @param {string} index - The name of the index
|
||||
* @param {string} type - The type of the document (use `_all` to fetch the first document matching the ID across all types)
|
||||
* @param {list} stored_fields - A comma-separated list of stored fields to return in the response
|
||||
* @param {string} parent - The ID of the parent document
|
||||
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
|
||||
* @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode
|
||||
* @param {boolean} refresh - Refresh the shard containing the document before performing the operation
|
||||
* @param {string} routing - Specific routing value
|
||||
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
|
||||
* @param {list} _source_exclude - A list of fields to exclude from the returned _source field
|
||||
* @param {list} _source_include - A list of fields to extract and return from the _source field
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
*/
|
||||
return function exists (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
exists(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['type'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: type'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: type, index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
} else if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'stored_fields',
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_exclude',
|
||||
'_source_include',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'storedFields',
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_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 = 'HEAD'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], params['id']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildExists
|
||||
163
api/api/exists_source.js
Normal file
163
api/api/exists_source.js
Normal file
@ -0,0 +1,163 @@
|
||||
'use strict'
|
||||
|
||||
function buildExistsSource (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [exists_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request
|
||||
*
|
||||
* @param {string} id - The document ID
|
||||
* @param {string} index - The name of the index
|
||||
* @param {string} type - The type of the document; use `_all` to fetch the first document matching the ID across all types
|
||||
* @param {string} parent - The ID of the parent document
|
||||
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
|
||||
* @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode
|
||||
* @param {boolean} refresh - Refresh the shard containing the document before performing the operation
|
||||
* @param {string} routing - Specific routing value
|
||||
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
|
||||
* @param {list} _source_exclude - A list of fields to exclude from the returned _source field
|
||||
* @param {list} _source_include - A list of fields to extract and return from the _source field
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
*/
|
||||
return function existsSource (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
existsSource(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['type'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: type'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: type, index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
} else if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_exclude',
|
||||
'_source_include',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_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 = 'HEAD'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], params['id'], '_source']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildExistsSource
|
||||
167
api/api/explain.js
Normal file
167
api/api/explain.js
Normal file
@ -0,0 +1,167 @@
|
||||
'use strict'
|
||||
|
||||
function buildExplain (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html) request
|
||||
*
|
||||
* @param {string} id - The document ID
|
||||
* @param {string} index - The name of the index
|
||||
* @param {string} type - The type of the document
|
||||
* @param {boolean} analyze_wildcard - Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)
|
||||
* @param {string} analyzer - The analyzer for the query string query
|
||||
* @param {enum} default_operator - The default operator for query string query (AND or OR)
|
||||
* @param {string} df - The default field for query string query (default: _all)
|
||||
* @param {list} stored_fields - A comma-separated list of stored fields to return in the response
|
||||
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
|
||||
* @param {string} parent - The ID of the parent document
|
||||
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
|
||||
* @param {string} q - Query in the Lucene query string syntax
|
||||
* @param {string} routing - Specific routing value
|
||||
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
|
||||
* @param {list} _source_exclude - A list of fields to exclude from the returned _source field
|
||||
* @param {list} _source_include - A list of fields to extract and return from the _source field
|
||||
* @param {object} body - The query definition using the Query DSL
|
||||
*/
|
||||
return function explain (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
explain(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['type'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: type'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: type, index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
} else if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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_exclude',
|
||||
'_source_include',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'analyzeWildcard',
|
||||
'analyzer',
|
||||
'defaultOperator',
|
||||
'df',
|
||||
'storedFields',
|
||||
'lenient',
|
||||
'parent',
|
||||
'preference',
|
||||
'q',
|
||||
'routing',
|
||||
'_source',
|
||||
'_sourceExclude',
|
||||
'_sourceInclude',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], params['id'], '_explain']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildExplain
|
||||
105
api/api/field_caps.js
Normal file
105
api/api/field_caps.js
Normal file
@ -0,0 +1,105 @@
|
||||
'use strict'
|
||||
|
||||
function buildFieldCaps (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [field_caps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {list} fields - A comma-separated list of field names
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {object} body - Field json objects containing an array of field names
|
||||
*/
|
||||
return function fieldCaps (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fieldCaps(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_field_caps']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildFieldCaps
|
||||
166
api/api/get.js
Normal file
166
api/api/get.js
Normal file
@ -0,0 +1,166 @@
|
||||
'use strict'
|
||||
|
||||
function buildGet (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [get](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request
|
||||
*
|
||||
* @param {string} id - The document ID
|
||||
* @param {string} index - The name of the index
|
||||
* @param {string} type - The type of the document (use `_all` to fetch the first document matching the ID across all types)
|
||||
* @param {list} stored_fields - A comma-separated list of stored fields to return in the response
|
||||
* @param {string} parent - The ID of the parent document
|
||||
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
|
||||
* @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode
|
||||
* @param {boolean} refresh - Refresh the shard containing the document before performing the operation
|
||||
* @param {string} routing - Specific routing value
|
||||
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
|
||||
* @param {list} _source_exclude - A list of fields to exclude from the returned _source field
|
||||
* @param {list} _source_include - A list of fields to extract and return from the _source field
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
*/
|
||||
return function get (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
get(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['type'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: type'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: type, index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
} else if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'stored_fields',
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_exclude',
|
||||
'_source_include',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'storedFields',
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], params['id']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildGet
|
||||
109
api/api/get_script.js
Normal file
109
api/api/get_script.js
Normal file
@ -0,0 +1,109 @@
|
||||
'use strict'
|
||||
|
||||
function buildGetScript (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [get_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request
|
||||
*
|
||||
* @param {string} id - Script ID
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
return function getScript (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getScript(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_scripts', params['id']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildGetScript
|
||||
163
api/api/get_source.js
Normal file
163
api/api/get_source.js
Normal file
@ -0,0 +1,163 @@
|
||||
'use strict'
|
||||
|
||||
function buildGetSource (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [get_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request
|
||||
*
|
||||
* @param {string} id - The document ID
|
||||
* @param {string} index - The name of the index
|
||||
* @param {string} type - The type of the document; use `_all` to fetch the first document matching the ID across all types
|
||||
* @param {string} parent - The ID of the parent document
|
||||
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
|
||||
* @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode
|
||||
* @param {boolean} refresh - Refresh the shard containing the document before performing the operation
|
||||
* @param {string} routing - Specific routing value
|
||||
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
|
||||
* @param {list} _source_exclude - A list of fields to exclude from the returned _source field
|
||||
* @param {list} _source_include - A list of fields to extract and return from the _source field
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
*/
|
||||
return function getSource (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getSource(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['type'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: type'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: type, index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
} else if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_exclude',
|
||||
'_source_include',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'parent',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], params['id'], '_source']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildGetSource
|
||||
155
api/api/index.js
Normal file
155
api/api/index.js
Normal file
@ -0,0 +1,155 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndex (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [index](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request
|
||||
*
|
||||
* @param {string} id - Document ID
|
||||
* @param {string} index - The name of the index
|
||||
* @param {string} type - The type of the document
|
||||
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
|
||||
* @param {enum} op_type - Explicit operation type
|
||||
* @param {string} parent - ID of the parent document
|
||||
* @param {enum} refresh - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
|
||||
* @param {string} routing - Specific routing value
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
* @param {string} pipeline - The pipeline id to preprocess incoming documents with
|
||||
* @param {object} body - The document
|
||||
*/
|
||||
return function index (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
index(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['type'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: type'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: type, index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
} else if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], params['id']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndex
|
||||
96
api/api/indices.analyze.js
Normal file
96
api/api/indices.analyze.js
Normal file
@ -0,0 +1,96 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesAnalyze (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.analyze](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html) request
|
||||
*
|
||||
* @param {string} index - The name of the index to scope the operation
|
||||
* @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
|
||||
*/
|
||||
return function indicesAnalyze (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesAnalyze(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_analyze']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesAnalyze
|
||||
130
api/api/indices.clear_cache.js
Normal file
130
api/api/indices.clear_cache.js
Normal file
@ -0,0 +1,130 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesClearCache (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.clear_cache](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index name to limit the operation
|
||||
* @param {boolean} field_data - Clear field data. This is deprecated. Prefer `fielddata`.
|
||||
* @param {boolean} fielddata - Clear field data
|
||||
* @param {list} fields - A comma-separated list of fields to clear when using the `fielddata` parameter (default: all)
|
||||
* @param {boolean} query - Clear query caches
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {list} index - A comma-separated list of index name to limit the operation
|
||||
* @param {boolean} request_cache - Clear request cache
|
||||
* @param {boolean} request - Clear request cache
|
||||
*/
|
||||
return function indicesClearCache (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesClearCache(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'field_data',
|
||||
'fielddata',
|
||||
'fields',
|
||||
'query',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'index',
|
||||
'request_cache',
|
||||
'request',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'fieldData',
|
||||
'fielddata',
|
||||
'fields',
|
||||
'query',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'index',
|
||||
'requestCache',
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_cache', 'clear']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesClearCache
|
||||
121
api/api/indices.close.js
Normal file
121
api/api/indices.close.js
Normal file
@ -0,0 +1,121 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesClose (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.close](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html) request
|
||||
*
|
||||
* @param {list} index - A comma separated list of indices to close
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
*/
|
||||
return function indicesClose (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesClose(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_close']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesClose
|
||||
113
api/api/indices.create.js
Normal file
113
api/api/indices.create.js
Normal file
@ -0,0 +1,113 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesCreate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html) request
|
||||
*
|
||||
* @param {string} index - The name of the index
|
||||
* @param {string} wait_for_active_shards - Set the number of active shards to wait for before the operation returns.
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {boolean} update_all_types - Whether to update the mapping for all fields with the same name across all types or not
|
||||
* @param {object} body - The configuration for the index (`settings` and `mappings`)
|
||||
*/
|
||||
return function indicesCreate (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesCreate(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'wait_for_active_shards',
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'update_all_types',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'waitForActiveShards',
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'updateAllTypes',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesCreate
|
||||
121
api/api/indices.delete.js
Normal file
121
api/api/indices.delete.js
Normal file
@ -0,0 +1,121 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesDelete (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {boolean} ignore_unavailable - Ignore unavailable indexes (default: false)
|
||||
* @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)
|
||||
*/
|
||||
return function indicesDelete (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesDelete(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesDelete
|
||||
129
api/api/indices.delete_alias.js
Normal file
129
api/api/indices.delete_alias.js
Normal file
@ -0,0 +1,129 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesDeleteAlias (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.delete_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names (supports wildcards); use `_all` for all indices
|
||||
* @param {list} name - A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices.
|
||||
* @param {time} timeout - Explicit timestamp for the document
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
return function indicesDeleteAlias (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesDeleteAlias(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['name'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: name'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['name'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_aliases', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: params['index'] != null && params['name'] != null
|
||||
? '/' + parts.filter(Boolean).join('/')
|
||||
: '/{index}/_alias/{name}',
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesDeleteAlias
|
||||
112
api/api/indices.delete_template.js
Normal file
112
api/api/indices.delete_template.js
Normal file
@ -0,0 +1,112 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesDeleteTemplate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.delete_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request
|
||||
*
|
||||
* @param {string} name - The name of the template
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
return function indicesDeleteTemplate (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesDeleteTemplate(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['name'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: name'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_template', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesDeleteTemplate
|
||||
124
api/api/indices.exists.js
Normal file
124
api/api/indices.exists.js
Normal file
@ -0,0 +1,124 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesExists (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {boolean} ignore_unavailable - Ignore unavailable indexes (default: false)
|
||||
* @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)
|
||||
* @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.
|
||||
*/
|
||||
return function indicesExists (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesExists(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesExists
|
||||
119
api/api/indices.exists_alias.js
Normal file
119
api/api/indices.exists_alias.js
Normal file
@ -0,0 +1,119 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesExistsAlias (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.exists_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to filter aliases
|
||||
* @param {list} name - A comma-separated list of alias names to return
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
return function indicesExistsAlias (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesExistsAlias(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['name'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: name'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_alias', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesExistsAlias
|
||||
115
api/api/indices.exists_template.js
Normal file
115
api/api/indices.exists_template.js
Normal file
@ -0,0 +1,115 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesExistsTemplate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.exists_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request
|
||||
*
|
||||
* @param {list} name - The comma separated names of the index templates
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @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)
|
||||
*/
|
||||
return function indicesExistsTemplate (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesExistsTemplate(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['name'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: name'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_template', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesExistsTemplate
|
||||
133
api/api/indices.exists_type.js
Normal file
133
api/api/indices.exists_type.js
Normal file
@ -0,0 +1,133 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesExistsType (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.exists_type](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` to check the types across all indices
|
||||
* @param {list} type - A comma-separated list of document types to check
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
return function indicesExistsType (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesExistsType(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['type'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: type'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_mapping', params['type']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesExistsType
|
||||
115
api/api/indices.flush.js
Normal file
115
api/api/indices.flush.js
Normal file
@ -0,0 +1,115 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesFlush (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.flush](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string for all indices
|
||||
* @param {boolean} force - Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal)
|
||||
* @param {boolean} wait_if_ongoing - If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running.
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
*/
|
||||
return function indicesFlush (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesFlush(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_flush']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesFlush
|
||||
109
api/api/indices.flush_synced.js
Normal file
109
api/api/indices.flush_synced.js
Normal file
@ -0,0 +1,109 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesFlushSynced (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.flush_synced](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string for all indices
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
*/
|
||||
return function indicesFlushSynced (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesFlushSynced(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_flush', 'synced']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesFlushSynced
|
||||
118
api/api/indices.forcemerge.js
Normal file
118
api/api/indices.forcemerge.js
Normal file
@ -0,0 +1,118 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesForcemerge (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.forcemerge](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {boolean} flush - Specify whether the index should be flushed after performing the operation (default: true)
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @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
|
||||
*/
|
||||
return function indicesForcemerge (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesForcemerge(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_forcemerge']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesForcemerge
|
||||
127
api/api/indices.get.js
Normal file
127
api/api/indices.get.js
Normal file
@ -0,0 +1,127 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesGet (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
* @param {boolean} ignore_unavailable - Ignore unavailable indexes (default: false)
|
||||
* @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)
|
||||
* @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.
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
*/
|
||||
return function indicesGet (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesGet(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesGet
|
||||
113
api/api/indices.get_alias.js
Normal file
113
api/api/indices.get_alias.js
Normal file
@ -0,0 +1,113 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesGetAlias (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.get_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to filter aliases
|
||||
* @param {list} name - A comma-separated list of alias names to return
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
return function indicesGetAlias (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesGetAlias(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_alias', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesGetAlias
|
||||
123
api/api/indices.get_field_mapping.js
Normal file
123
api/api/indices.get_field_mapping.js
Normal file
@ -0,0 +1,123 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesGetFieldMapping (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.get_field_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names
|
||||
* @param {list} type - A comma-separated list of document types
|
||||
* @param {list} fields - A comma-separated list of fields
|
||||
* @param {boolean} include_defaults - Whether the default mapping values should be returned as well
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
|
||||
*/
|
||||
return function indicesGetFieldMapping (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesGetFieldMapping(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['fields'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: fields'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_mapping', params['type'], 'field', params['fields']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesGetFieldMapping
|
||||
116
api/api/indices.get_mapping.js
Normal file
116
api/api/indices.get_mapping.js
Normal file
@ -0,0 +1,116 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesGetMapping (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.get_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-mapping.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names
|
||||
* @param {list} type - A comma-separated list of document types
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @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)
|
||||
*/
|
||||
return function indicesGetMapping (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesGetMapping(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'master_timeout',
|
||||
'local',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_mapping', params['type']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesGetMapping
|
||||
122
api/api/indices.get_settings.js
Normal file
122
api/api/indices.get_settings.js
Normal file
@ -0,0 +1,122 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesGetSettings (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.get_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-settings.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {list} name - The name of the settings that should be included
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @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.
|
||||
*/
|
||||
return function indicesGetSettings (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesGetSettings(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_settings', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesGetSettings
|
||||
109
api/api/indices.get_template.js
Normal file
109
api/api/indices.get_template.js
Normal file
@ -0,0 +1,109 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesGetTemplate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.get_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request
|
||||
*
|
||||
* @param {list} name - The comma separated names of the index templates
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @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)
|
||||
*/
|
||||
return function indicesGetTemplate (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesGetTemplate(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_template', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesGetTemplate
|
||||
109
api/api/indices.get_upgrade.js
Normal file
109
api/api/indices.get_upgrade.js
Normal file
@ -0,0 +1,109 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesGetUpgrade (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.get_upgrade](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
*/
|
||||
return function indicesGetUpgrade (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesGetUpgrade(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_upgrade']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesGetUpgrade
|
||||
124
api/api/indices.open.js
Normal file
124
api/api/indices.open.js
Normal file
@ -0,0 +1,124 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesOpen (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.open](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html) request
|
||||
*
|
||||
* @param {list} index - A comma separated list of indices to open
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns.
|
||||
*/
|
||||
return function indicesOpen (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesOpen(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_open']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesOpen
|
||||
124
api/api/indices.put_alias.js
Normal file
124
api/api/indices.put_alias.js
Normal file
@ -0,0 +1,124 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesPutAlias (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.put_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices.
|
||||
* @param {string} name - The name of the alias to be created or updated
|
||||
* @param {time} timeout - Explicit timestamp for the document
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {object} body - The settings for the alias, such as `routing` or `filter`
|
||||
*/
|
||||
return function indicesPutAlias (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesPutAlias(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['name'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: name'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['name'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_aliases', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: params['index'] != null && params['name'] != null
|
||||
? '/' + parts.filter(Boolean).join('/')
|
||||
: '/{index}/_alias/{name}',
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesPutAlias
|
||||
126
api/api/indices.put_mapping.js
Normal file
126
api/api/indices.put_mapping.js
Normal file
@ -0,0 +1,126 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesPutMapping (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.put_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices.
|
||||
* @param {string} type - The name of the document type
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {boolean} update_all_types - Whether to update the mapping for all fields with the same name across all types or not
|
||||
* @param {object} body - The mapping definition
|
||||
*/
|
||||
return function indicesPutMapping (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesPutMapping(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['type'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: type'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'update_all_types',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'updateAllTypes',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_mappings', params['type']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesPutMapping
|
||||
122
api/api/indices.put_settings.js
Normal file
122
api/api/indices.put_settings.js
Normal file
@ -0,0 +1,122 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesPutSettings (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.put_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-update-settings.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {boolean} preserve_existing - Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false`
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {object} body - The index settings to be updated
|
||||
*/
|
||||
return function indicesPutSettings (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesPutSettings(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_settings']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesPutSettings
|
||||
122
api/api/indices.put_template.js
Normal file
122
api/api/indices.put_template.js
Normal file
@ -0,0 +1,122 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesPutTemplate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.put_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request
|
||||
*
|
||||
* @param {string} name - The name of the template
|
||||
* @param {number} order - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)
|
||||
* @param {boolean} create - Whether the index template should only be added if new or can also replace an existing one
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {object} body - The template definition
|
||||
*/
|
||||
return function indicesPutTemplate (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesPutTemplate(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['name'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: name'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_template', params['name']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesPutTemplate
|
||||
106
api/api/indices.recovery.js
Normal file
106
api/api/indices.recovery.js
Normal file
@ -0,0 +1,106 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesRecovery (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-recovery.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {boolean} detailed - Whether to display detailed information about shard recovery
|
||||
* @param {boolean} active_only - Display only those recoveries that are currently on-going
|
||||
*/
|
||||
return function indicesRecovery (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesRecovery(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_recovery']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesRecovery
|
||||
109
api/api/indices.refresh.js
Normal file
109
api/api/indices.refresh.js
Normal file
@ -0,0 +1,109 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesRefresh (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.refresh](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
*/
|
||||
return function indicesRefresh (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesRefresh(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_refresh']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesRefresh
|
||||
122
api/api/indices.rollover.js
Normal file
122
api/api/indices.rollover.js
Normal file
@ -0,0 +1,122 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesRollover (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.rollover](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html) request
|
||||
*
|
||||
* @param {string} alias - The name of the alias to rollover
|
||||
* @param {string} new_index - The name of the rollover index
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {boolean} dry_run - If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @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
|
||||
*/
|
||||
return function indicesRollover (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesRollover(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['alias'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: alias'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if ((params['new_index'] != null || params['newIndex'] != null) && (params['alias'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: alias'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['alias'], '_rollover', params['new_index'] || params['newIndex']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesRollover
|
||||
112
api/api/indices.segments.js
Normal file
112
api/api/indices.segments.js
Normal file
@ -0,0 +1,112 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesSegments (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.segments](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-segments.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {boolean} verbose - Includes detailed memory usage by Lucene.
|
||||
*/
|
||||
return function indicesSegments (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesSegments(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_segments']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesSegments
|
||||
112
api/api/indices.shard_stores.js
Normal file
112
api/api/indices.shard_stores.js
Normal file
@ -0,0 +1,112 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesShardStores (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.shard_stores](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {list} status - A comma-separated list of statuses used to filter on shards to get store information for
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
*/
|
||||
return function indicesShardStores (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesShardStores(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_shard_stores']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesShardStores
|
||||
128
api/api/indices.shrink.js
Normal file
128
api/api/indices.shrink.js
Normal file
@ -0,0 +1,128 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesShrink (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.shrink](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html) request
|
||||
*
|
||||
* @param {string} index - The name of the source index to shrink
|
||||
* @param {string} target - The name of the target index to shrink into
|
||||
* @param {boolean} copy_settings - whether or not to copy settings from the source index (defaults to false)
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @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`)
|
||||
*/
|
||||
return function indicesShrink (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesShrink(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['target'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: target'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['target'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_shrink', params['target']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesShrink
|
||||
128
api/api/indices.split.js
Normal file
128
api/api/indices.split.js
Normal file
@ -0,0 +1,128 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesSplit (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.split](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html) request
|
||||
*
|
||||
* @param {string} index - The name of the source index to split
|
||||
* @param {string} target - The name of the target index to split into
|
||||
* @param {boolean} copy_settings - whether or not to copy settings from the source index (defaults to false)
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @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`)
|
||||
*/
|
||||
return function indicesSplit (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesSplit(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['index'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['target'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: target'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['target'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_split', params['target']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesSplit
|
||||
122
api/api/indices.stats.js
Normal file
122
api/api/indices.stats.js
Normal file
@ -0,0 +1,122 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesStats (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-stats.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {list} metric - Limit the information returned the specific metrics.
|
||||
* @param {list} completion_fields - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards)
|
||||
* @param {list} fielddata_fields - A comma-separated list of fields for `fielddata` index metric (supports wildcards)
|
||||
* @param {list} fields - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards)
|
||||
* @param {list} groups - A comma-separated list of search groups for `search` index metric
|
||||
* @param {enum} level - Return stats aggregated at cluster, index or shard level
|
||||
* @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)
|
||||
*/
|
||||
return function indicesStats (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesStats(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_stats', params['metric']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesStats
|
||||
106
api/api/indices.update_aliases.js
Normal file
106
api/api/indices.update_aliases.js
Normal file
@ -0,0 +1,106 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesUpdateAliases (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.update_aliases](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request
|
||||
*
|
||||
* @param {time} timeout - Request timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {object} body - The definition of `actions` to perform
|
||||
*/
|
||||
return function indicesUpdateAliases (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesUpdateAliases(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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 = 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_aliases']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesUpdateAliases
|
||||
115
api/api/indices.upgrade.js
Normal file
115
api/api/indices.upgrade.js
Normal file
@ -0,0 +1,115 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesUpgrade (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.upgrade](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
||||
* @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.
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @param {boolean} wait_for_completion - Specify whether the request should block until the all segments are upgraded (default: false)
|
||||
* @param {boolean} only_ancient_segments - If true, only ancient (an older Lucene major release) segments will be upgraded
|
||||
*/
|
||||
return function indicesUpgrade (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesUpgrade(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'ignore_unavailable',
|
||||
'wait_for_completion',
|
||||
'only_ancient_segments',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'ignoreUnavailable',
|
||||
'waitForCompletion',
|
||||
'onlyAncientSegments',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_upgrade']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesUpgrade
|
||||
138
api/api/indices.validate_query.js
Normal file
138
api/api/indices.validate_query.js
Normal file
@ -0,0 +1,138 @@
|
||||
'use strict'
|
||||
|
||||
function buildIndicesValidateQuery (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [indices.validate_query](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {list} type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types
|
||||
* @param {boolean} explain - Return detailed information about the error
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {string} q - Query in the Lucene query string syntax
|
||||
* @param {string} analyzer - The analyzer to use for the query string
|
||||
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
|
||||
* @param {enum} default_operator - The default operator for query string query (AND or OR)
|
||||
* @param {string} df - The field to use as default where no field prefix is given in the query string
|
||||
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
|
||||
* @param {boolean} rewrite - Provide a more detailed explanation showing the actual Lucene query that will be executed.
|
||||
* @param {boolean} all_shards - Execute validation on all shards instead of one random shard per index
|
||||
* @param {object} body - The query definition specified with the Query DSL
|
||||
*/
|
||||
return function indicesValidateQuery (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
indicesValidateQuery(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'explain',
|
||||
'ignore_unavailable',
|
||||
'allow_no_indices',
|
||||
'expand_wildcards',
|
||||
'q',
|
||||
'analyzer',
|
||||
'analyze_wildcard',
|
||||
'default_operator',
|
||||
'df',
|
||||
'lenient',
|
||||
'rewrite',
|
||||
'all_shards',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'explain',
|
||||
'ignoreUnavailable',
|
||||
'allowNoIndices',
|
||||
'expandWildcards',
|
||||
'q',
|
||||
'analyzer',
|
||||
'analyzeWildcard',
|
||||
'defaultOperator',
|
||||
'df',
|
||||
'lenient',
|
||||
'rewrite',
|
||||
'allShards',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], '_validate', 'query']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIndicesValidateQuery
|
||||
99
api/api/info.js
Normal file
99
api/api/info.js
Normal file
@ -0,0 +1,99 @@
|
||||
'use strict'
|
||||
|
||||
function buildInfo (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [info](http://www.elastic.co/guide/) request
|
||||
*
|
||||
*/
|
||||
return function info (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
info(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = []
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildInfo
|
||||
112
api/api/ingest.delete_pipeline.js
Normal file
112
api/api/ingest.delete_pipeline.js
Normal file
@ -0,0 +1,112 @@
|
||||
'use strict'
|
||||
|
||||
function buildIngestDeletePipeline (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [ingest.delete_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request
|
||||
*
|
||||
* @param {string} id - Pipeline ID
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
*/
|
||||
return function ingestDeletePipeline (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ingestDeletePipeline(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'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 = 'DELETE'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_ingest', 'pipeline', params['id']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIngestDeletePipeline
|
||||
103
api/api/ingest.get_pipeline.js
Normal file
103
api/api/ingest.get_pipeline.js
Normal file
@ -0,0 +1,103 @@
|
||||
'use strict'
|
||||
|
||||
function buildIngestGetPipeline (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [ingest.get_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request
|
||||
*
|
||||
* @param {string} id - Comma separated list of pipeline ids. Wildcards supported
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
*/
|
||||
return function ingestGetPipeline (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ingestGetPipeline(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_ingest', 'pipeline', params['id']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIngestGetPipeline
|
||||
99
api/api/ingest.processor_grok.js
Normal file
99
api/api/ingest.processor_grok.js
Normal file
@ -0,0 +1,99 @@
|
||||
'use strict'
|
||||
|
||||
function buildIngestProcessorGrok (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [ingest.processor_grok](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request
|
||||
*
|
||||
*/
|
||||
return function ingestProcessorGrok (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ingestProcessorGrok(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_ingest', 'processor', 'grok']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIngestProcessorGrok
|
||||
113
api/api/ingest.put_pipeline.js
Normal file
113
api/api/ingest.put_pipeline.js
Normal file
@ -0,0 +1,113 @@
|
||||
'use strict'
|
||||
|
||||
function buildIngestPutPipeline (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [ingest.put_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request
|
||||
*
|
||||
* @param {string} id - Pipeline ID
|
||||
* @param {time} master_timeout - Explicit operation timeout for connection to master node
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {object} body - The ingest definition
|
||||
*/
|
||||
return function ingestPutPipeline (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ingestPutPipeline(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'master_timeout',
|
||||
'timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_ingest', 'pipeline', params['id']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIngestPutPipeline
|
||||
104
api/api/ingest.simulate.js
Normal file
104
api/api/ingest.simulate.js
Normal file
@ -0,0 +1,104 @@
|
||||
'use strict'
|
||||
|
||||
function buildIngestSimulate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [ingest.simulate](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request
|
||||
*
|
||||
* @param {string} id - Pipeline ID
|
||||
* @param {boolean} verbose - Verbose mode. Display data output for each processor in executed pipeline
|
||||
* @param {object} body - The simulate definition
|
||||
*/
|
||||
return function ingestSimulate (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ingestSimulate(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'verbose',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_ingest', 'pipeline', params['id'], '_simulate']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildIngestSimulate
|
||||
134
api/api/mget.js
Normal file
134
api/api/mget.js
Normal file
@ -0,0 +1,134 @@
|
||||
'use strict'
|
||||
|
||||
function buildMget (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [mget](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html) request
|
||||
*
|
||||
* @param {string} index - The name of the index
|
||||
* @param {string} type - The type of the document
|
||||
* @param {list} stored_fields - A comma-separated list of stored fields to return in the response
|
||||
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
|
||||
* @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode
|
||||
* @param {boolean} refresh - Refresh the shard containing the document before performing the operation
|
||||
* @param {string} routing - Specific routing value
|
||||
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
|
||||
* @param {list} _source_exclude - A list of fields to exclude from the returned _source field
|
||||
* @param {list} _source_include - A list of fields to extract and return from the _source field
|
||||
* @param {object} body - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL.
|
||||
*/
|
||||
return function mget (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
mget(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'stored_fields',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_source_exclude',
|
||||
'_source_include',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'storedFields',
|
||||
'preference',
|
||||
'realtime',
|
||||
'refresh',
|
||||
'routing',
|
||||
'_source',
|
||||
'_sourceExclude',
|
||||
'_sourceInclude',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], '_mget']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildMget
|
||||
122
api/api/msearch.js
Normal file
122
api/api/msearch.js
Normal file
@ -0,0 +1,122 @@
|
||||
'use strict'
|
||||
|
||||
function buildMsearch (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [msearch](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to use as default
|
||||
* @param {list} type - A comma-separated list of document types to use as default
|
||||
* @param {enum} search_type - Search operation type
|
||||
* @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute
|
||||
* @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response
|
||||
* @param {number} pre_filter_shard_size - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
|
||||
* @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines
|
||||
*/
|
||||
return function msearch (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
msearch(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'search_type',
|
||||
'max_concurrent_searches',
|
||||
'typed_keys',
|
||||
'pre_filter_shard_size',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'searchType',
|
||||
'maxConcurrentSearches',
|
||||
'typedKeys',
|
||||
'preFilterShardSize',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], '_msearch']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
bulkBody: params.body,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildMsearch
|
||||
119
api/api/msearch_template.js
Normal file
119
api/api/msearch_template.js
Normal file
@ -0,0 +1,119 @@
|
||||
'use strict'
|
||||
|
||||
function buildMsearchTemplate (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [msearch_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to use as default
|
||||
* @param {list} type - A comma-separated list of document types to use as default
|
||||
* @param {enum} search_type - Search operation type
|
||||
* @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response
|
||||
* @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute
|
||||
* @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines
|
||||
*/
|
||||
return function msearchTemplate (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
msearchTemplate(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'search_type',
|
||||
'typed_keys',
|
||||
'max_concurrent_searches',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'searchType',
|
||||
'typedKeys',
|
||||
'maxConcurrentSearches',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], '_msearch', 'template']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
bulkBody: params.body,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildMsearchTemplate
|
||||
141
api/api/mtermvectors.js
Normal file
141
api/api/mtermvectors.js
Normal file
@ -0,0 +1,141 @@
|
||||
'use strict'
|
||||
|
||||
function buildMtermvectors (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [mtermvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html) request
|
||||
*
|
||||
* @param {string} index - The index in which the document resides.
|
||||
* @param {string} type - The type of the document.
|
||||
* @param {list} ids - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body
|
||||
* @param {boolean} term_statistics - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
|
||||
* @param {boolean} field_statistics - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
|
||||
* @param {list} fields - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs".
|
||||
* @param {boolean} offsets - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
|
||||
* @param {boolean} positions - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
|
||||
* @param {boolean} payloads - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
|
||||
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs".
|
||||
* @param {string} routing - Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs".
|
||||
* @param {string} parent - Parent id of documents. Applies to all returned documents unless otherwise specified in body "params" or "docs".
|
||||
* @param {boolean} realtime - Specifies if requests are real-time as opposed to near-real-time (default: true).
|
||||
* @param {number} version - Explicit version number for concurrency control
|
||||
* @param {enum} version_type - Specific version type
|
||||
* @param {object} body - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.
|
||||
*/
|
||||
return function mtermvectors (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
mtermvectors(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['type'] != null && (params['index'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: index'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'ids',
|
||||
'term_statistics',
|
||||
'field_statistics',
|
||||
'fields',
|
||||
'offsets',
|
||||
'positions',
|
||||
'payloads',
|
||||
'preference',
|
||||
'routing',
|
||||
'parent',
|
||||
'realtime',
|
||||
'version',
|
||||
'version_type',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'ids',
|
||||
'termStatistics',
|
||||
'fieldStatistics',
|
||||
'fields',
|
||||
'offsets',
|
||||
'positions',
|
||||
'payloads',
|
||||
'preference',
|
||||
'routing',
|
||||
'parent',
|
||||
'realtime',
|
||||
'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 = params.body == null ? 'GET' : 'POST'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], params['type'], '_mtermvectors']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildMtermvectors
|
||||
120
api/api/nodes.hot_threads.js
Normal file
120
api/api/nodes.hot_threads.js
Normal file
@ -0,0 +1,120 @@
|
||||
'use strict'
|
||||
|
||||
function buildNodesHotThreads (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [nodes.hot_threads](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html) request
|
||||
*
|
||||
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
|
||||
* @param {time} interval - The interval for the second sampling of threads
|
||||
* @param {number} snapshots - Number of samples of thread stacktrace (default: 10)
|
||||
* @param {number} threads - Specify the number of threads to provide information for (default: 3)
|
||||
* @param {boolean} ignore_idle_threads - Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true)
|
||||
* @param {enum} type - The type to sample (default: cpu)
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
*/
|
||||
return function nodesHotThreads (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
nodesHotThreads(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'interval',
|
||||
'snapshots',
|
||||
'threads',
|
||||
'ignore_idle_threads',
|
||||
'type',
|
||||
'timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'interval',
|
||||
'snapshots',
|
||||
'threads',
|
||||
'ignoreIdleThreads',
|
||||
'type',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_cluster', 'nodes', params['node_id'] || params['nodeId'], 'hot_threads']
|
||||
const request = {
|
||||
method,
|
||||
path: (params['node_id'] || params['nodeId']) != null
|
||||
? '/' + parts.filter(Boolean).join('/')
|
||||
: '/_nodes/hot_threads',
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildNodesHotThreads
|
||||
107
api/api/nodes.info.js
Normal file
107
api/api/nodes.info.js
Normal file
@ -0,0 +1,107 @@
|
||||
'use strict'
|
||||
|
||||
function buildNodesInfo (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [nodes.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html) request
|
||||
*
|
||||
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
|
||||
* @param {list} metric - A comma-separated list of metrics you wish returned. Leave empty to return all.
|
||||
* @param {boolean} flat_settings - Return settings in flat format (default: false)
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
*/
|
||||
return function nodesInfo (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
nodesInfo(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_nodes', params['node_id'] || params['nodeId'], params['metric']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildNodesInfo
|
||||
126
api/api/nodes.stats.js
Normal file
126
api/api/nodes.stats.js
Normal file
@ -0,0 +1,126 @@
|
||||
'use strict'
|
||||
|
||||
function buildNodesStats (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [nodes.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html) request
|
||||
*
|
||||
* @param {list} metric - Limit the information returned to the specified metrics
|
||||
* @param {list} index_metric - Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified.
|
||||
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
|
||||
* @param {list} completion_fields - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards)
|
||||
* @param {list} fielddata_fields - A comma-separated list of fields for `fielddata` index metric (supports wildcards)
|
||||
* @param {list} fields - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards)
|
||||
* @param {boolean} groups - A comma-separated list of search groups for `search` index metric
|
||||
* @param {enum} level - Return indices stats aggregated at index, node or shard level
|
||||
* @param {list} types - A comma-separated list of document types for the `indexing` index metric
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @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)
|
||||
*/
|
||||
return function nodesStats (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
nodesStats(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'completion_fields',
|
||||
'fielddata_fields',
|
||||
'fields',
|
||||
'groups',
|
||||
'level',
|
||||
'types',
|
||||
'timeout',
|
||||
'include_segment_file_sizes',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'completionFields',
|
||||
'fielddataFields',
|
||||
'fields',
|
||||
'groups',
|
||||
'level',
|
||||
'types',
|
||||
'timeout',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_nodes', params['node_id'] || params['nodeId'], 'stats', params['metric'], params['index_metric'] || params['indexMetric']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildNodesStats
|
||||
104
api/api/nodes.usage.js
Normal file
104
api/api/nodes.usage.js
Normal file
@ -0,0 +1,104 @@
|
||||
'use strict'
|
||||
|
||||
function buildNodesUsage (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [nodes.usage](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html) request
|
||||
*
|
||||
* @param {list} metric - Limit the information returned to the specified metrics
|
||||
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
*/
|
||||
return function nodesUsage (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
nodesUsage(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_nodes', params['node_id'] || params['nodeId'], 'usage', params['metric']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildNodesUsage
|
||||
99
api/api/ping.js
Normal file
99
api/api/ping.js
Normal file
@ -0,0 +1,99 @@
|
||||
'use strict'
|
||||
|
||||
function buildPing (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [ping](http://www.elastic.co/guide/) request
|
||||
*
|
||||
*/
|
||||
return function ping (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ping(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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 = 'HEAD'
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (params.headers != null && typeof params.headers !== 'object') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = []
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: null,
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildPing
|
||||
125
api/api/put_script.js
Normal file
125
api/api/put_script.js
Normal file
@ -0,0 +1,125 @@
|
||||
'use strict'
|
||||
|
||||
function buildPutScript (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [put_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request
|
||||
*
|
||||
* @param {string} id - Script ID
|
||||
* @param {string} context - Script context
|
||||
* @param {time} timeout - Explicit operation timeout
|
||||
* @param {time} master_timeout - Specify timeout for connection to master
|
||||
* @param {string} context - Context name to compile script against
|
||||
* @param {object} body - The document
|
||||
*/
|
||||
return function putScript (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
putScript(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['id'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['context'] != null && (params['id'] == null)) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter of the url: id'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'timeout',
|
||||
'master_timeout',
|
||||
'context',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'timeout',
|
||||
'masterTimeout',
|
||||
'context',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_scripts', params['id'], params['context']]
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildPutScript
|
||||
110
api/api/rank_eval.js
Normal file
110
api/api/rank_eval.js
Normal file
@ -0,0 +1,110 @@
|
||||
'use strict'
|
||||
|
||||
function buildRankEval (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [rank_eval](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html) request
|
||||
*
|
||||
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
|
||||
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
||||
* @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.
|
||||
* @param {object} body - The ranking evaluation search definition, including search requests, document ratings and ranking metric definition.
|
||||
*/
|
||||
return function rankEval (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
rankEval(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = [params['index'], '_rank_eval']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildRankEval
|
||||
118
api/api/reindex.js
Normal file
118
api/api/reindex.js
Normal file
@ -0,0 +1,118 @@
|
||||
'use strict'
|
||||
|
||||
function buildReindex (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [reindex](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html) request
|
||||
*
|
||||
* @param {boolean} refresh - Should the effected indexes be refreshed?
|
||||
* @param {time} timeout - Time each individual bulk request should wait for shards that are unavailable.
|
||||
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
|
||||
* @param {boolean} wait_for_completion - Should the request should block until the reindex is complete.
|
||||
* @param {number} requests_per_second - The throttle to set on this request in sub-requests per second. -1 means no throttle.
|
||||
* @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 and the prototype for the index request.
|
||||
*/
|
||||
return function reindex (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
reindex(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// build querystring object
|
||||
const querystring = {}
|
||||
const keys = Object.keys(params)
|
||||
const acceptedQuerystring = [
|
||||
'refresh',
|
||||
'timeout',
|
||||
'wait_for_active_shards',
|
||||
'wait_for_completion',
|
||||
'requests_per_second',
|
||||
'slices',
|
||||
'pretty',
|
||||
'human',
|
||||
'error_trace',
|
||||
'source',
|
||||
'filter_path'
|
||||
]
|
||||
const acceptedQuerystringCamelCased = [
|
||||
'refresh',
|
||||
'timeout',
|
||||
'waitForActiveShards',
|
||||
'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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_reindex']
|
||||
const request = {
|
||||
method,
|
||||
path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),
|
||||
querystring,
|
||||
body: params.body || '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildReindex
|
||||
117
api/api/reindex_rethrottle.js
Normal file
117
api/api/reindex_rethrottle.js
Normal file
@ -0,0 +1,117 @@
|
||||
'use strict'
|
||||
|
||||
function buildReindexRethrottle (opts) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { makeRequest, ConfigurationError } = opts
|
||||
/**
|
||||
* Perform a [reindex_rethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html) request
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
return function reindexRethrottle (params, callback) {
|
||||
if (typeof params === 'function' || params == null) {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
reindexRethrottle(params, (err, body) => {
|
||||
err ? reject(err) : resolve(body)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check required parameters
|
||||
if (params['task_id'] == null && params['taskId'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: task_id or taskId'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) {
|
||||
return callback(
|
||||
new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
if (params.body != null) {
|
||||
return callback(
|
||||
new ConfigurationError('This API does not require a body'),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
// 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') {
|
||||
return callback(
|
||||
new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`),
|
||||
{ body: null, headers: null, statusCode: null }
|
||||
)
|
||||
}
|
||||
|
||||
var ignore = params.ignore || null
|
||||
if (typeof ignore === 'number') {
|
||||
ignore = [ignore]
|
||||
}
|
||||
|
||||
// build request object
|
||||
const parts = ['_delete_by_query', params['task_id'] || params['taskId'], '_rethrottle']
|
||||
const request = {
|
||||
method,
|
||||
path: (params['task_id'] || params['taskId']) != null
|
||||
? '/' + parts.filter(Boolean).join('/')
|
||||
: '/_reindex/{task_id}/_rethrottle',
|
||||
querystring,
|
||||
body: '',
|
||||
headers: params.headers || null,
|
||||
ignore,
|
||||
requestTimeout: params.requestTimeout || null,
|
||||
agent: null,
|
||||
url: ''
|
||||
}
|
||||
|
||||
return makeRequest(request, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = buildReindexRethrottle
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user