API generation

This commit is contained in:
delvedor
2019-02-15 10:29:48 +01:00
parent f704d4fcf3
commit 96fe644eb2
29 changed files with 712 additions and 50 deletions

View File

@ -10,15 +10,16 @@ function buildCcrFollow (opts) {
* Perform a [ccr.follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html) request
*
* @param {string} index - The name of the follower index
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before returning. Defaults to 0. 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 {object} body - The name of the leader index and other optional ccr related parameters
*/
const acceptedQuerystring = [
'wait_for_active_shards'
]
const snakeCase = {
waitForActiveShards: 'wait_for_active_shards'
}
return function ccrFollow (params, options, callback) {

106
api/api/ccr.follow_info.js Normal file
View File

@ -0,0 +1,106 @@
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildCcrFollowInfo (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, result } = opts
/**
* Perform a [ccr.follow_info](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html) request
*
* @param {list} index - A comma-separated list of index patterns; use `_all` to perform the operation on all indices
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ccrFollowInfo (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// promises support
if (callback == null) {
return new Promise((resolve, reject) => {
ccrFollowInfo(params, options, (err, body) => {
err ? reject(err) : resolve(body)
})
})
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
return callback(
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
result
)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'info'
// build request object
const request = {
method,
path,
body: null,
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
}
}
module.exports = buildCcrFollowInfo

View File

@ -48,12 +48,6 @@ function buildCcrResumeFollow (opts) {
result
)
}
if (params['body'] == null) {
return callback(
new ConfigurationError('Missing required parameter: body'),
result
)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {

View File

@ -79,12 +79,6 @@ function buildCreate (opts) {
result
)
}
if (params['type'] == null) {
return callback(
new ConfigurationError('Missing required parameter: type'),
result
)
}
if (params['body'] == null) {
return callback(
new ConfigurationError('Missing required parameter: body'),
@ -128,7 +122,11 @@ function buildCreate (opts) {
var path = ''
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create'
if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id)
}
// build request object
const request = {

View File

@ -17,6 +17,8 @@ function buildDelete (opts) {
* @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} if_seq_no - only perform the delete operation if the last operation that has changed the document has the specified sequence number
* @param {number} if_primary_term - only perform the delete operation if the last operation that has changed the document has the specified primary term
* @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type
*/
@ -27,6 +29,8 @@ function buildDelete (opts) {
'refresh',
'routing',
'timeout',
'if_seq_no',
'if_primary_term',
'version',
'version_type',
'pretty',
@ -38,6 +42,8 @@ function buildDelete (opts) {
const snakeCase = {
waitForActiveShards: 'wait_for_active_shards',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
versionType: 'version_type',
errorTrace: 'error_trace',
filterPath: 'filter_path'

View File

@ -11,7 +11,7 @@ function buildExistsSource (opts) {
*
* @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} type - The type of the document; deprecated and optional starting with 7.0
* @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
@ -83,12 +83,6 @@ function buildExistsSource (opts) {
result
)
}
if (params['type'] == null) {
return callback(
new ConfigurationError('Missing required parameter: type'),
result
)
}
if (params.body != null) {
return callback(
new ConfigurationError('This API does not require a body'),
@ -132,7 +126,11 @@ function buildExistsSource (opts) {
var path = ''
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id)
}
// build request object
const request = {

View File

@ -11,7 +11,7 @@ function buildGetSource (opts) {
*
* @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} type - The type of the document; deprecated and optional starting with 7.0
* @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
@ -83,12 +83,6 @@ function buildGetSource (opts) {
result
)
}
if (params['type'] == null) {
return callback(
new ConfigurationError('Missing required parameter: type'),
result
)
}
if (params.body != null) {
return callback(
new ConfigurationError('This API does not require a body'),
@ -132,7 +126,11 @@ function buildGetSource (opts) {
var path = ''
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id)
}
// build request object
const request = {

View File

@ -20,6 +20,8 @@ function buildIndex (opts) {
* @param {time} timeout - Explicit operation timeout
* @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type
* @param {number} if_seq_no - only perform the index operation if the last operation that has changed the document has the specified sequence number
* @param {number} if_primary_term - only perform the index operation if the last operation that has changed the document has the specified primary term
* @param {string} pipeline - The pipeline id to preprocess incoming documents with
* @param {object} body - The document
*/
@ -33,6 +35,8 @@ function buildIndex (opts) {
'timeout',
'version',
'version_type',
'if_seq_no',
'if_primary_term',
'pipeline',
'pretty',
'human',
@ -45,6 +49,8 @@ function buildIndex (opts) {
waitForActiveShards: 'wait_for_active_shards',
opType: 'op_type',
versionType: 'version_type',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -10,7 +10,7 @@ function buildIndicesCreate (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} include_type_name - Whether a type should be expected in the body of the mappings.
* @param {boolean} include_type_name - Whether a type should be expected in the body of the mappings.
* @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

View File

@ -10,6 +10,7 @@ function buildIndicesGet (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} include_type_name - Whether to add the type name to the response (default: false)
* @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)
@ -20,6 +21,7 @@ function buildIndicesGet (opts) {
*/
const acceptedQuerystring = [
'include_type_name',
'local',
'ignore_unavailable',
'allow_no_indices',
@ -35,6 +37,7 @@ function buildIndicesGet (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',

View File

@ -12,6 +12,7 @@ function buildIndicesGetFieldMapping (opts) {
* @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_type_name - Whether a type should be returned in the body of the mappings.
* @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)
@ -20,6 +21,7 @@ function buildIndicesGetFieldMapping (opts) {
*/
const acceptedQuerystring = [
'include_type_name',
'include_defaults',
'ignore_unavailable',
'allow_no_indices',
@ -33,6 +35,7 @@ function buildIndicesGetFieldMapping (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
includeDefaults: 'include_defaults',
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',

View File

@ -11,7 +11,7 @@ function buildIndicesGetMapping (opts) {
*
* @param {list} index - A comma-separated list of index names
* @param {list} type - A comma-separated list of document types
* @param {string} include_type_name - Whether to add the type name to the response
* @param {boolean} include_type_name - Whether to add the type name to the response (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.

View File

@ -10,12 +10,14 @@ function buildIndicesGetTemplate (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} include_type_name - Whether a type should be returned in the body of the mappings.
* @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)
*/
const acceptedQuerystring = [
'include_type_name',
'flat_settings',
'master_timeout',
'local',
@ -27,6 +29,7 @@ function buildIndicesGetTemplate (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
flatSettings: 'flat_settings',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',

View File

@ -11,7 +11,7 @@ function buildIndicesPutMapping (opts) {
*
* @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 {string} include_type_name - Whether a type should be expected in the body of the mappings.
* @param {boolean} include_type_name - Whether a type should be expected in the body of the mappings.
* @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)

View File

@ -10,6 +10,7 @@ function buildIndicesPutTemplate (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 {boolean} include_type_name - Whether a type should be returned in the body of the mappings.
* @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
@ -19,6 +20,7 @@ function buildIndicesPutTemplate (opts) {
*/
const acceptedQuerystring = [
'include_type_name',
'order',
'create',
'timeout',
@ -32,6 +34,7 @@ function buildIndicesPutTemplate (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
masterTimeout: 'master_timeout',
flatSettings: 'flat_settings',
errorTrace: 'error_trace',

View File

@ -11,6 +11,7 @@ function buildIndicesRollover (opts) {
*
* @param {string} alias - The name of the alias to rollover
* @param {string} new_index - The name of the rollover index
* @param {boolean} include_type_name - Whether a type should be included in the body of the mappings.
* @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
@ -19,6 +20,7 @@ function buildIndicesRollover (opts) {
*/
const acceptedQuerystring = [
'include_type_name',
'timeout',
'dry_run',
'master_timeout',
@ -31,6 +33,7 @@ function buildIndicesRollover (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
dryRun: 'dry_run',
masterTimeout: 'master_timeout',
waitForActiveShards: 'wait_for_active_shards',

View File

@ -13,6 +13,7 @@ function buildMlCloseJob (opts) {
* @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified)
* @param {boolean} force - True if the job should be forcefully closed
* @param {time} timeout - Controls the time to wait until a job has closed. Default to 30 minutes
* @param {object} body - The URL params optionally sent in the body
*/
const acceptedQuerystring = [

View File

@ -0,0 +1,116 @@
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildMlSetUpgradeMode (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, result } = opts
/**
* Perform a [ml.set_upgrade_mode](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html) request
*
* @param {boolean} enabled - Whether to enable upgrade_mode ML setting or not. Defaults to false.
* @param {time} timeout - Controls the time to wait before action times out. Defaults to 30 seconds
*/
const acceptedQuerystring = [
'enabled',
'timeout'
]
const snakeCase = {
}
return function mlSetUpgradeMode (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// promises support
if (callback == null) {
return new Promise((resolve, reject) => {
mlSetUpgradeMode(params, options, (err, body) => {
err ? reject(err) : resolve(body)
})
})
}
// check required parameters
if (params.body != null) {
return callback(
new ConfigurationError('This API does not require a body'),
result
)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
return callback(
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
result
)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
if (method == null) {
method = 'POST'
}
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
var path = ''
path = '/' + '_ml' + '/' + 'set_upgrade_mode'
// build request object
const request = {
method,
path,
body: '',
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
}
}
module.exports = buildMlSetUpgradeMode

View File

@ -17,6 +17,7 @@ function buildMsearch (opts) {
* @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 {number} max_concurrent_shard_requests - The number of concurrent shard requests each sub search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests
* @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response
* @param {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
* @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines
*/
@ -27,6 +28,7 @@ function buildMsearch (opts) {
'pre_filter_shard_size',
'max_concurrent_shard_requests',
'rest_total_hits_as_int',
'ccs_minimize_roundtrips',
'pretty',
'human',
'error_trace',
@ -41,6 +43,7 @@ function buildMsearch (opts) {
preFilterShardSize: 'pre_filter_shard_size',
maxConcurrentShardRequests: 'max_concurrent_shard_requests',
restTotalHitsAsInt: 'rest_total_hits_as_int',
ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -15,6 +15,7 @@ function buildMsearchTemplate (opts) {
* @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 {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response
* @param {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
* @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines
*/
@ -23,6 +24,7 @@ function buildMsearchTemplate (opts) {
'typed_keys',
'max_concurrent_searches',
'rest_total_hits_as_int',
'ccs_minimize_roundtrips',
'pretty',
'human',
'error_trace',
@ -35,6 +37,7 @@ function buildMsearchTemplate (opts) {
typedKeys: 'typed_keys',
maxConcurrentSearches: 'max_concurrent_searches',
restTotalHitsAsInt: 'rest_total_hits_as_int',
ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -13,6 +13,7 @@ function buildSearch (opts) {
* @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 {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
* @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} explain - Specify whether to return detailed information about score computation as part of a hit
@ -46,6 +47,7 @@ function buildSearch (opts) {
* @param {boolean} allow_partial_search_results - Indicate if an error should be returned if there is a partial search failure or timeout
* @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response
* @param {boolean} version - Specify whether to return document version as part of a hit
* @param {boolean} seq_no_primary_term - Specify whether to return sequence number and primary term of the last modification of each hit
* @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting
* @param {number} batched_reduce_size - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.
* @param {number} max_concurrent_shard_requests - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests
@ -57,6 +59,7 @@ function buildSearch (opts) {
const acceptedQuerystring = [
'analyzer',
'analyze_wildcard',
'ccs_minimize_roundtrips',
'default_operator',
'df',
'explain',
@ -90,6 +93,7 @@ function buildSearch (opts) {
'allow_partial_search_results',
'typed_keys',
'version',
'seq_no_primary_term',
'request_cache',
'batched_reduce_size',
'max_concurrent_shard_requests',
@ -104,6 +108,7 @@ function buildSearch (opts) {
const snakeCase = {
analyzeWildcard: 'analyze_wildcard',
ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips',
defaultOperator: 'default_operator',
storedFields: 'stored_fields',
docvalueFields: 'docvalue_fields',
@ -123,6 +128,7 @@ function buildSearch (opts) {
trackTotalHits: 'track_total_hits',
allowPartialSearchResults: 'allow_partial_search_results',
typedKeys: 'typed_keys',
seqNoPrimaryTerm: 'seq_no_primary_term',
requestCache: 'request_cache',
batchedReduceSize: 'batched_reduce_size',
maxConcurrentShardRequests: 'max_concurrent_shard_requests',

View File

@ -23,6 +23,7 @@ function buildSearchTemplate (opts) {
* @param {boolean} profile - Specify whether to profile the query execution
* @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response
* @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response
* @param {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
* @param {object} body - The search definition template and its params
*/
@ -39,6 +40,7 @@ function buildSearchTemplate (opts) {
'profile',
'typed_keys',
'rest_total_hits_as_int',
'ccs_minimize_roundtrips',
'pretty',
'human',
'error_trace',
@ -54,6 +56,7 @@ function buildSearchTemplate (opts) {
searchType: 'search_type',
typedKeys: 'typed_keys',
restTotalHitsAsInt: 'rest_total_hits_as_int',
ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -0,0 +1,115 @@
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildSecurityCreateApiKey (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, result } = opts
/**
* Perform a [security.create_api_key](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html) request
*
* @param {enum} refresh - If `true` (the default) 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` then do nothing with refreshes.
* @param {object} body - The api key request to create an API key
*/
const acceptedQuerystring = [
'refresh'
]
const snakeCase = {
}
return function securityCreateApiKey (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// promises support
if (callback == null) {
return new Promise((resolve, reject) => {
securityCreateApiKey(params, options, (err, body) => {
err ? reject(err) : resolve(body)
})
})
}
// check required parameters
if (params['body'] == null) {
return callback(
new ConfigurationError('Missing required parameter: body'),
result
)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
return callback(
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
result
)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
if (method == null) {
method = 'PUT'
}
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
var path = ''
path = '/' + '_security' + '/' + 'api_key'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
}
}
module.exports = buildSecurityCreateApiKey

View File

@ -0,0 +1,120 @@
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildSecurityGetApiKey (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, result } = opts
/**
* Perform a [security.get_api_key](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html) request
*
* @param {string} id - API key id of the API key to be retrieved
* @param {string} name - API key name of the API key to be retrieved
* @param {string} username - user name of the user who created this API key to be retrieved
* @param {string} realm_name - realm name of the user who created this API key to be retrieved
*/
const acceptedQuerystring = [
'id',
'name',
'username',
'realm_name'
]
const snakeCase = {
realmName: 'realm_name'
}
return function securityGetApiKey (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// promises support
if (callback == null) {
return new Promise((resolve, reject) => {
securityGetApiKey(params, options, (err, body) => {
err ? reject(err) : resolve(body)
})
})
}
// check required parameters
if (params.body != null) {
return callback(
new ConfigurationError('This API does not require a body'),
result
)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
return callback(
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
result
)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
var path = ''
path = '/' + '_security' + '/' + 'api_key'
// build request object
const request = {
method,
path,
body: null,
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
}
}
module.exports = buildSecurityGetApiKey

View File

@ -0,0 +1,114 @@
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildSecurityInvalidateApiKey (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, result } = opts
/**
* Perform a [security.invalidate_api_key](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html) request
*
* @param {object} body - The api key request to invalidate API key(s)
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function securityInvalidateApiKey (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// promises support
if (callback == null) {
return new Promise((resolve, reject) => {
securityInvalidateApiKey(params, options, (err, body) => {
err ? reject(err) : resolve(body)
})
})
}
// check required parameters
if (params['body'] == null) {
return callback(
new ConfigurationError('Missing required parameter: body'),
result
)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
return callback(
new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`),
result
)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
if (method == null) {
method = 'DELETE'
}
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
var path = ''
path = '/' + '_security' + '/' + 'api_key'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
}
}
module.exports = buildSecurityInvalidateApiKey

View File

@ -22,8 +22,8 @@ function buildUpdate (opts) {
* @param {number} retry_on_conflict - Specify how many times should the operation be retried when a conflict occurs (default: 0)
* @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 {number} if_seq_no - only perform the update operation if the last operation that has changed the document has the specified sequence number
* @param {number} if_primary_term - only perform the update operation if the last operation that has changed the document has the specified primary term
* @param {object} body - The request definition requires either `script` or partial `doc`
*/
@ -38,8 +38,8 @@ function buildUpdate (opts) {
'retry_on_conflict',
'routing',
'timeout',
'version',
'version_type',
'if_seq_no',
'if_primary_term',
'pretty',
'human',
'error_trace',
@ -52,7 +52,8 @@ function buildUpdate (opts) {
_sourceExcludes: '_source_excludes',
_sourceIncludes: '_source_includes',
retryOnConflict: 'retry_on_conflict',
versionType: 'version_type',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -12,16 +12,21 @@ function buildXpackWatcherPutWatch (opts) {
* @param {string} id - Watch ID
* @param {boolean} active - Specify whether the watch is in/active by default
* @param {number} version - Explicit version number for concurrency control
* @param {number} if_seq_no - only update the watch if the last operation that has changed the watch has the specified sequence number
* @param {number} if_primary_term - only update the watch if the last operation that has changed the watch has the specified primary term
* @param {object} body - The watch
*/
const acceptedQuerystring = [
'active',
'version'
'version',
'if_seq_no',
'if_primary_term'
]
const snakeCase = {
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term'
}
return function xpackWatcherPutWatch (params, options, callback) {

View File

@ -37,6 +37,8 @@ function ESAPI (opts) {
delete_auto_follow_pattern: lazyLoad('./api/ccr.delete_auto_follow_pattern.js', opts),
deleteAutoFollowPattern: lazyLoad('./api/ccr.delete_auto_follow_pattern.js', opts),
follow: lazyLoad('./api/ccr.follow.js', opts),
follow_info: lazyLoad('./api/ccr.follow_info.js', opts),
followInfo: lazyLoad('./api/ccr.follow_info.js', opts),
follow_stats: lazyLoad('./api/ccr.follow_stats.js', opts),
followStats: lazyLoad('./api/ccr.follow_stats.js', opts),
get_auto_follow_pattern: lazyLoad('./api/ccr.get_auto_follow_pattern.js', opts),
@ -255,6 +257,8 @@ function ESAPI (opts) {
putJob: lazyLoad('./api/ml.put_job.js', opts),
revert_model_snapshot: lazyLoad('./api/ml.revert_model_snapshot.js', opts),
revertModelSnapshot: lazyLoad('./api/ml.revert_model_snapshot.js', opts),
set_upgrade_mode: lazyLoad('./api/ml.set_upgrade_mode.js', opts),
setUpgradeMode: lazyLoad('./api/ml.set_upgrade_mode.js', opts),
start_datafeed: lazyLoad('./api/ml.start_datafeed.js', opts),
startDatafeed: lazyLoad('./api/ml.start_datafeed.js', opts),
stop_datafeed: lazyLoad('./api/ml.stop_datafeed.js', opts),
@ -313,6 +317,8 @@ function ESAPI (opts) {
clearCachedRealms: lazyLoad('./api/security.clear_cached_realms.js', opts),
clear_cached_roles: lazyLoad('./api/security.clear_cached_roles.js', opts),
clearCachedRoles: lazyLoad('./api/security.clear_cached_roles.js', opts),
create_api_key: lazyLoad('./api/security.create_api_key.js', opts),
createApiKey: lazyLoad('./api/security.create_api_key.js', opts),
delete_privileges: lazyLoad('./api/security.delete_privileges.js', opts),
deletePrivileges: lazyLoad('./api/security.delete_privileges.js', opts),
delete_role: lazyLoad('./api/security.delete_role.js', opts),
@ -325,6 +331,8 @@ function ESAPI (opts) {
disableUser: lazyLoad('./api/security.disable_user.js', opts),
enable_user: lazyLoad('./api/security.enable_user.js', opts),
enableUser: lazyLoad('./api/security.enable_user.js', opts),
get_api_key: lazyLoad('./api/security.get_api_key.js', opts),
getApiKey: lazyLoad('./api/security.get_api_key.js', opts),
get_privileges: lazyLoad('./api/security.get_privileges.js', opts),
getPrivileges: lazyLoad('./api/security.get_privileges.js', opts),
get_role: lazyLoad('./api/security.get_role.js', opts),
@ -339,6 +347,8 @@ function ESAPI (opts) {
getUserPrivileges: lazyLoad('./api/security.get_user_privileges.js', opts),
has_privileges: lazyLoad('./api/security.has_privileges.js', opts),
hasPrivileges: lazyLoad('./api/security.has_privileges.js', opts),
invalidate_api_key: lazyLoad('./api/security.invalidate_api_key.js', opts),
invalidateApiKey: lazyLoad('./api/security.invalidate_api_key.js', opts),
invalidate_token: lazyLoad('./api/security.invalidate_token.js', opts),
invalidateToken: lazyLoad('./api/security.invalidate_token.js', opts),
put_privileges: lazyLoad('./api/security.put_privileges.js', opts),

View File

@ -337,7 +337,7 @@ export interface Count extends Generic {
export interface Create extends Generic {
id: string;
index: string;
type: string;
type?: string;
wait_for_active_shards?: string;
parent?: string;
refresh?: 'true' | 'false' | 'wait_for';
@ -358,6 +358,8 @@ export interface Delete extends Generic {
refresh?: 'true' | 'false' | 'wait_for';
routing?: string;
timeout?: string;
if_seq_no?: number;
if_primary_term?: number;
version?: number;
version_type?: 'internal' | 'external' | 'external_gte' | 'force';
}
@ -431,7 +433,7 @@ export interface Exists extends Generic {
export interface ExistsSource extends Generic {
id: string;
index: string;
type: string;
type?: string;
parent?: string;
preference?: string;
realtime?: boolean;
@ -499,7 +501,7 @@ export interface GetScript extends Generic {
export interface GetSource extends Generic {
id: string;
index: string;
type: string;
type?: string;
parent?: string;
preference?: string;
realtime?: boolean;
@ -524,6 +526,8 @@ export interface Index extends Generic {
timeout?: string;
version?: number;
version_type?: 'internal' | 'external' | 'external_gte' | 'force';
if_seq_no?: number;
if_primary_term?: number;
pipeline?: string;
body: any;
}
@ -555,7 +559,7 @@ export interface IndicesClose extends Generic {
export interface IndicesCreate extends Generic {
index: string;
include_type_name?: string;
include_type_name?: boolean;
wait_for_active_shards?: string;
timeout?: string;
master_timeout?: string;
@ -647,6 +651,7 @@ export interface IndicesForcemerge extends Generic {
export interface IndicesGet extends Generic {
index: string | string[];
include_type_name?: boolean;
local?: boolean;
ignore_unavailable?: boolean;
allow_no_indices?: boolean;
@ -669,6 +674,7 @@ export interface IndicesGetFieldMapping extends Generic {
index?: string | string[];
type?: string | string[];
fields: string | string[];
include_type_name?: boolean;
include_defaults?: boolean;
ignore_unavailable?: boolean;
allow_no_indices?: boolean;
@ -679,7 +685,7 @@ export interface IndicesGetFieldMapping extends Generic {
export interface IndicesGetMapping extends Generic {
index?: string | string[];
type?: string | string[];
include_type_name?: string;
include_type_name?: boolean;
ignore_unavailable?: boolean;
allow_no_indices?: boolean;
expand_wildcards?: 'open' | 'closed' | 'none' | 'all';
@ -701,6 +707,7 @@ export interface IndicesGetSettings extends Generic {
export interface IndicesGetTemplate extends Generic {
name?: string | string[];
include_type_name?: boolean;
flat_settings?: boolean;
master_timeout?: string;
local?: boolean;
@ -734,7 +741,7 @@ export interface IndicesPutAlias extends Generic {
export interface IndicesPutMapping extends Generic {
index?: string | string[];
type?: string;
include_type_name?: string;
include_type_name?: boolean;
timeout?: string;
master_timeout?: string;
ignore_unavailable?: boolean;
@ -757,6 +764,7 @@ export interface IndicesPutSettings extends Generic {
export interface IndicesPutTemplate extends Generic {
name: string;
include_type_name?: boolean;
order?: number;
create?: boolean;
timeout?: string;
@ -781,6 +789,7 @@ export interface IndicesRefresh extends Generic {
export interface IndicesRollover extends Generic {
alias: string;
new_index?: string;
include_type_name?: boolean;
timeout?: string;
dry_run?: boolean;
master_timeout?: string;
@ -922,6 +931,7 @@ export interface Msearch extends Generic {
pre_filter_shard_size?: number;
max_concurrent_shard_requests?: number;
rest_total_hits_as_int?: boolean;
ccs_minimize_roundtrips?: boolean;
body: any;
}
@ -932,6 +942,7 @@ export interface MsearchTemplate extends Generic {
typed_keys?: boolean;
max_concurrent_searches?: number;
rest_total_hits_as_int?: boolean;
ccs_minimize_roundtrips?: boolean;
body: any;
}
@ -1051,6 +1062,7 @@ export interface Search extends Generic {
type?: string | string[];
analyzer?: string;
analyze_wildcard?: boolean;
ccs_minimize_roundtrips?: boolean;
default_operator?: 'AND' | 'OR';
df?: string;
explain?: boolean;
@ -1084,6 +1096,7 @@ export interface Search extends Generic {
allow_partial_search_results?: boolean;
typed_keys?: boolean;
version?: boolean;
seq_no_primary_term?: boolean;
request_cache?: boolean;
batched_reduce_size?: number;
max_concurrent_shard_requests?: number;
@ -1117,6 +1130,7 @@ export interface SearchTemplate extends Generic {
profile?: boolean;
typed_keys?: boolean;
rest_total_hits_as_int?: boolean;
ccs_minimize_roundtrips?: boolean;
body: any;
}
@ -1239,8 +1253,8 @@ export interface Update extends Generic {
retry_on_conflict?: number;
routing?: string;
timeout?: string;
version?: number;
version_type?: 'internal' | 'force';
if_seq_no?: number;
if_primary_term?: number;
body: any;
}
@ -1295,9 +1309,14 @@ export interface CcrDeleteAutoFollowPattern extends Generic {
export interface CcrFollow extends Generic {
index: string;
wait_for_active_shards?: string;
body: any;
}
export interface CcrFollowInfo extends Generic {
index?: string | string[];
}
export interface CcrFollowStats extends Generic {
index?: string | string[];
}
@ -1317,7 +1336,7 @@ export interface CcrPutAutoFollowPattern extends Generic {
export interface CcrResumeFollow extends Generic {
index: string;
body: any;
body?: any;
}
export interface CcrStats extends Generic {
@ -1392,6 +1411,7 @@ export interface MlCloseJob extends Generic {
allow_no_jobs?: boolean;
force?: boolean;
timeout?: string;
body?: any;
}
export interface MlDeleteCalendar extends Generic {
@ -1642,6 +1662,11 @@ export interface MlRevertModelSnapshot extends Generic {
body?: any;
}
export interface MlSetUpgradeMode extends Generic {
enabled?: boolean;
timeout?: string;
}
export interface MlStartDatafeed extends Generic {
datafeed_id: string;
start?: string;
@ -1712,6 +1737,11 @@ export interface SecurityClearCachedRoles extends Generic {
name: string | string[];
}
export interface SecurityCreateApiKey extends Generic {
refresh?: 'true' | 'false' | 'wait_for';
body: any;
}
export interface SecurityDeletePrivileges extends Generic {
application: string;
name: string;
@ -1743,6 +1773,13 @@ export interface SecurityEnableUser extends Generic {
refresh?: 'true' | 'false' | 'wait_for';
}
export interface SecurityGetApiKey extends Generic {
id?: string;
name?: string;
username?: string;
realm_name?: string;
}
export interface SecurityGetPrivileges extends Generic {
application?: string;
name?: string;
@ -1772,6 +1809,10 @@ export interface SecurityHasPrivileges extends Generic {
body: any;
}
export interface SecurityInvalidateApiKey extends Generic {
body: any;
}
export interface SecurityInvalidateToken extends Generic {
body: any;
}
@ -1944,6 +1985,8 @@ export interface XpackWatcherPutWatch extends Generic {
id: string;
active?: boolean;
version?: number;
if_seq_no?: number;
if_primary_term?: number;
body?: any;
}