diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index ef562122a..a5fdd3107 100644 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -1,6 +1,6 @@ --- ELASTICSEARCH_VERSION: - - 7.4.0 + - 7.5.0 NODE_JS_VERSION: - 12 diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index a291a4629..a706265dd 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -14,7 +14,6 @@ function buildCatAliases (opts) { const acceptedQuerystring = [ 'format', 'local', - 'master_timeout', 'h', 'help', 's', @@ -27,7 +26,6 @@ function buildCatAliases (opts) { ] const snakeCase = { - masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/cat.count.js b/api/api/cat.count.js index 7578a3259..10cf6fd2c 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -13,8 +13,6 @@ function buildCatCount (opts) { const acceptedQuerystring = [ 'format', - 'local', - 'master_timeout', 'h', 'help', 's', @@ -27,7 +25,6 @@ function buildCatCount (opts) { ] const snakeCase = { - masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 6a058e46f..e8767eb00 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -14,8 +14,6 @@ function buildCatFielddata (opts) { const acceptedQuerystring = [ 'format', 'bytes', - 'local', - 'master_timeout', 'h', 'help', 's', @@ -29,7 +27,6 @@ function buildCatFielddata (opts) { ] const snakeCase = { - masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/cat.health.js b/api/api/cat.health.js index e6b99d266..c655333e7 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -13,11 +13,10 @@ function buildCatHealth (opts) { const acceptedQuerystring = [ 'format', - 'local', - 'master_timeout', 'h', 'help', 's', + 'time', 'ts', 'v', 'pretty', @@ -28,7 +27,6 @@ function buildCatHealth (opts) { ] const snakeCase = { - masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 6bbcd49cc..cf5876aff 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -21,6 +21,7 @@ function buildCatIndices (opts) { 'help', 'pri', 's', + 'time', 'v', 'include_unloaded_segments', 'pretty', diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 8c7beed6f..01923de06 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -12,6 +12,7 @@ function buildCatNodes (opts) { const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const acceptedQuerystring = [ + 'bytes', 'format', 'full_id', 'local', @@ -19,6 +20,7 @@ function buildCatNodes (opts) { 'h', 'help', 's', + 'time', 'v', 'pretty', 'human', diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index f97e120b3..10f6b5ab0 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -18,6 +18,7 @@ function buildCatPendingTasks (opts) { 'h', 'help', 's', + 'time', 'v', 'pretty', 'human', diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index 05b2c0f65..7a75f6433 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -13,11 +13,14 @@ function buildCatRecovery (opts) { const acceptedQuerystring = [ 'format', + 'active_only', 'bytes', - 'master_timeout', + 'detailed', 'h', 'help', + 'index', 's', + 'time', 'v', 'pretty', 'human', @@ -27,7 +30,7 @@ function buildCatRecovery (opts) { ] const snakeCase = { - masterTimeout: 'master_timeout', + activeOnly: 'active_only', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index 551488839..634d78cd0 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -19,6 +19,7 @@ function buildCatShards (opts) { 'h', 'help', 's', + 'time', 'v', 'pretty', 'human', diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index 22809b988..78d8921b9 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -18,6 +18,7 @@ function buildCatSnapshots (opts) { 'h', 'help', 's', + 'time', 'v', 'pretty', 'human', diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index c84a22797..1e0eda879 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -20,6 +20,7 @@ function buildCatTasks (opts) { 'h', 'help', 's', + 'time', 'v', 'pretty', 'human', diff --git a/api/api/ccr.pause_auto_follow_pattern.js b/api/api/ccr.pause_auto_follow_pattern.js new file mode 100644 index 000000000..5782467f9 --- /dev/null +++ b/api/api/ccr.pause_auto_follow_pattern.js @@ -0,0 +1,77 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrPauseAutoFollowPattern (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + /** + * Perform a ccr.pause_auto_follow_pattern request + * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-auto-follow-pattern.html + */ + return function ccrPauseAutoFollowPattern (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'POST' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + '/' + 'pause' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildCcrPauseAutoFollowPattern diff --git a/api/api/ccr.resume_auto_follow_pattern.js b/api/api/ccr.resume_auto_follow_pattern.js new file mode 100644 index 000000000..d8adf6dc0 --- /dev/null +++ b/api/api/ccr.resume_auto_follow_pattern.js @@ -0,0 +1,77 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrResumeAutoFollowPattern (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + /** + * Perform a ccr.resume_auto_follow_pattern request + * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-auto-follow-pattern.html + */ + return function ccrResumeAutoFollowPattern (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'POST' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + '/' + 'resume' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildCcrResumeAutoFollowPattern diff --git a/api/api/enrich.delete_policy.js b/api/api/enrich.delete_policy.js new file mode 100644 index 000000000..c2658df0a --- /dev/null +++ b/api/api/enrich.delete_policy.js @@ -0,0 +1,76 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildEnrichDeletePolicy (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + /** + * Perform a enrich.delete_policy request + */ + return function enrichDeletePolicy (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'DELETE' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildEnrichDeletePolicy diff --git a/api/api/enrich.execute_policy.js b/api/api/enrich.execute_policy.js new file mode 100644 index 000000000..61f09e411 --- /dev/null +++ b/api/api/enrich.execute_policy.js @@ -0,0 +1,76 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildEnrichExecutePolicy (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + 'wait_for_completion' + ] + + const snakeCase = { + waitForCompletion: 'wait_for_completion' + } + + /** + * Perform a enrich.execute_policy request + */ + return function enrichExecutePolicy (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'PUT' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + '/' + '_execute' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildEnrichExecutePolicy diff --git a/api/api/enrich.get_policy.js b/api/api/enrich.get_policy.js new file mode 100644 index 000000000..4225e808b --- /dev/null +++ b/api/api/enrich.get_policy.js @@ -0,0 +1,75 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildEnrichGetPolicy (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + /** + * Perform a enrich.get_policy request + */ + return function enrichGetPolicy (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_enrich' + '/' + 'policy' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildEnrichGetPolicy diff --git a/api/api/enrich.put_policy.js b/api/api/enrich.put_policy.js new file mode 100644 index 000000000..53830f100 --- /dev/null +++ b/api/api/enrich.put_policy.js @@ -0,0 +1,80 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildEnrichPutPolicy (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + /** + * Perform a enrich.put_policy request + */ + return function enrichPutPolicy (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'PUT' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildEnrichPutPolicy diff --git a/api/api/enrich.stats.js b/api/api/enrich.stats.js new file mode 100644 index 000000000..98d7cd7cf --- /dev/null +++ b/api/api/enrich.stats.js @@ -0,0 +1,70 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildEnrichStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + /** + * Perform a enrich.stats request + */ + return function enrichStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'GET' + path = '/' + '_enrich' + '/' + '_stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildEnrichStats diff --git a/api/api/index.js b/api/api/index.js index 67f47b96a..6136772b9 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -84,10 +84,10 @@ function buildIndex (opts) { var path = '' if ((index) != null && (type) != null && (id) != null) { - if (method == null) method = 'POST' + if (method == null) method = 'PUT' path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) } else if ((index) != null && (id) != null) { - if (method == null) method = 'POST' + if (method == null) method = 'PUT' path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) } else if ((index) != null && (type) != null) { if (method == null) method = 'POST' diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index f10bb25d5..7f5da226b 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -79,10 +79,10 @@ function buildIndicesDeleteAlias (opts) { if ((index) != null && (name) != null) { if (method == null) method = 'DELETE' - path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) } else { if (method == null) method = 'DELETE' - path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) + path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) } // build request object diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index bb32f3098..4e72de0d6 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -79,10 +79,10 @@ function buildIndicesPutAlias (opts) { if ((index) != null && (name) != null) { if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) } else { if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) + path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) } // build request object diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index be4fcaa5a..6e2a44d4b 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -67,16 +67,16 @@ function buildNodesHotThreads (opts) { if ((node_id || nodeId) != null) { if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads' } else if ((node_id || nodeId) != null) { if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hotthreads' + path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hotthreads' } else if ((node_id || nodeId) != null) { if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hotthreads' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hotthreads' } else if ((node_id || nodeId) != null) { if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads' + path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads' } else { if (method == null) method = 'GET' path = '/' + '_nodes' + '/' + 'hot_threads' diff --git a/api/api/security.get_api_key.js b/api/api/security.get_api_key.js index bbcfc0162..80e21a104 100644 --- a/api/api/security.get_api_key.js +++ b/api/api/security.get_api_key.js @@ -15,11 +15,13 @@ function buildSecurityGetApiKey (opts) { 'id', 'name', 'username', - 'realm_name' + 'realm_name', + 'owner' ] const snakeCase = { realmName: 'realm_name' + } /** diff --git a/api/api/slm.execute_retention.js b/api/api/slm.execute_retention.js new file mode 100644 index 000000000..f23dfb5e2 --- /dev/null +++ b/api/api/slm.execute_retention.js @@ -0,0 +1,71 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSlmExecuteRetention (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + /** + * Perform a slm.execute_retention request + * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-retention.html + */ + return function slmExecuteRetention (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'POST' + path = '/' + '_slm' + '/' + '_execute_retention' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildSlmExecuteRetention diff --git a/api/api/slm.get_stats.js b/api/api/slm.get_stats.js new file mode 100644 index 000000000..07369f451 --- /dev/null +++ b/api/api/slm.get_stats.js @@ -0,0 +1,71 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSlmGetStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + /** + * Perform a slm.get_stats request + * https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-get-stats.html + */ + return function slmGetStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'GET' + path = '/' + '_slm' + '/' + 'stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildSlmGetStats diff --git a/api/api/data_frame.delete_data_frame_transform.js b/api/api/transform.delete_transform.js similarity index 84% rename from api/api/data_frame.delete_data_frame_transform.js rename to api/api/transform.delete_transform.js index ce0d66f1e..043e3d13a 100644 --- a/api/api/data_frame.delete_data_frame_transform.js +++ b/api/api/transform.delete_transform.js @@ -7,7 +7,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDataFrameDeleteDataFrameTransform (opts) { +function buildTransformDeleteTransform (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -20,10 +20,10 @@ function buildDataFrameDeleteDataFrameTransform (opts) { } /** - * Perform a data_frame.delete_data_frame_transform request + * Perform a transform.delete_transform request * https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html */ - return function dataFrameDeleteDataFrameTransform (params, options, callback) { + return function transformDeleteTransform (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -59,7 +59,7 @@ function buildDataFrameDeleteDataFrameTransform (opts) { var path = '' if (method == null) method = 'DELETE' - path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) // build request object const request = { @@ -74,4 +74,4 @@ function buildDataFrameDeleteDataFrameTransform (opts) { } } -module.exports = buildDataFrameDeleteDataFrameTransform +module.exports = buildTransformDeleteTransform diff --git a/api/api/data_frame.get_data_frame_transform.js b/api/api/transform.get_transform.js similarity index 81% rename from api/api/data_frame.get_data_frame_transform.js rename to api/api/transform.get_transform.js index dd7aea3c2..643debd27 100644 --- a/api/api/data_frame.get_data_frame_transform.js +++ b/api/api/transform.get_transform.js @@ -7,7 +7,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDataFrameGetDataFrameTransform (opts) { +function buildTransformGetTransform (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -22,10 +22,10 @@ function buildDataFrameGetDataFrameTransform (opts) { } /** - * Perform a data_frame.get_data_frame_transform request + * Perform a transform.get_transform request * https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html */ - return function dataFrameGetDataFrameTransform (params, options, callback) { + return function transformGetTransform (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -56,10 +56,10 @@ function buildDataFrameGetDataFrameTransform (opts) { if ((transform_id || transformId) != null) { if (method == null) method = 'GET' - path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) } else { if (method == null) method = 'GET' - path = '/' + '_data_frame' + '/' + 'transforms' + path = '/' + '_transform' } // build request object @@ -75,4 +75,4 @@ function buildDataFrameGetDataFrameTransform (opts) { } } -module.exports = buildDataFrameGetDataFrameTransform +module.exports = buildTransformGetTransform diff --git a/api/api/data_frame.get_data_frame_transform_stats.js b/api/api/transform.get_transform_stats.js similarity index 83% rename from api/api/data_frame.get_data_frame_transform_stats.js rename to api/api/transform.get_transform_stats.js index 32b6d358d..7dc8fa140 100644 --- a/api/api/data_frame.get_data_frame_transform_stats.js +++ b/api/api/transform.get_transform_stats.js @@ -7,7 +7,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDataFrameGetDataFrameTransformStats (opts) { +function buildTransformGetTransformStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -22,10 +22,10 @@ function buildDataFrameGetDataFrameTransformStats (opts) { } /** - * Perform a data_frame.get_data_frame_transform_stats request + * Perform a transform.get_transform_stats request * https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html */ - return function dataFrameGetDataFrameTransformStats (params, options, callback) { + return function transformGetTransformStats (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -61,7 +61,7 @@ function buildDataFrameGetDataFrameTransformStats (opts) { var path = '' if (method == null) method = 'GET' - path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stats' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stats' // build request object const request = { @@ -76,4 +76,4 @@ function buildDataFrameGetDataFrameTransformStats (opts) { } } -module.exports = buildDataFrameGetDataFrameTransformStats +module.exports = buildTransformGetTransformStats diff --git a/api/api/data_frame.preview_data_frame_transform.js b/api/api/transform.preview_transform.js similarity index 84% rename from api/api/data_frame.preview_data_frame_transform.js rename to api/api/transform.preview_transform.js index 820ec1e2b..78333d69f 100644 --- a/api/api/data_frame.preview_data_frame_transform.js +++ b/api/api/transform.preview_transform.js @@ -7,7 +7,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDataFramePreviewDataFrameTransform (opts) { +function buildTransformPreviewTransform (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -20,10 +20,10 @@ function buildDataFramePreviewDataFrameTransform (opts) { } /** - * Perform a data_frame.preview_data_frame_transform request + * Perform a transform.preview_transform request * https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html */ - return function dataFramePreviewDataFrameTransform (params, options, callback) { + return function transformPreviewTransform (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -59,7 +59,7 @@ function buildDataFramePreviewDataFrameTransform (opts) { var path = '' if (method == null) method = 'POST' - path = '/' + '_data_frame' + '/' + 'transforms' + '/' + '_preview' + path = '/' + '_transform' + '/' + '_preview' // build request object const request = { @@ -74,4 +74,4 @@ function buildDataFramePreviewDataFrameTransform (opts) { } } -module.exports = buildDataFramePreviewDataFrameTransform +module.exports = buildTransformPreviewTransform diff --git a/api/api/data_frame.put_data_frame_transform.js b/api/api/transform.put_transform.js similarity index 85% rename from api/api/data_frame.put_data_frame_transform.js rename to api/api/transform.put_transform.js index 1f3028380..4832ea689 100644 --- a/api/api/data_frame.put_data_frame_transform.js +++ b/api/api/transform.put_transform.js @@ -7,7 +7,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDataFramePutDataFrameTransform (opts) { +function buildTransformPutTransform (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -20,10 +20,10 @@ function buildDataFramePutDataFrameTransform (opts) { } /** - * Perform a data_frame.put_data_frame_transform request + * Perform a transform.put_transform request * https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html */ - return function dataFramePutDataFrameTransform (params, options, callback) { + return function transformPutTransform (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -63,7 +63,7 @@ function buildDataFramePutDataFrameTransform (opts) { var path = '' if (method == null) method = 'PUT' - path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) // build request object const request = { @@ -78,4 +78,4 @@ function buildDataFramePutDataFrameTransform (opts) { } } -module.exports = buildDataFramePutDataFrameTransform +module.exports = buildTransformPutTransform diff --git a/api/api/data_frame.start_data_frame_transform.js b/api/api/transform.start_transform.js similarity index 83% rename from api/api/data_frame.start_data_frame_transform.js rename to api/api/transform.start_transform.js index 7ade50b5d..8482d4dd6 100644 --- a/api/api/data_frame.start_data_frame_transform.js +++ b/api/api/transform.start_transform.js @@ -7,7 +7,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDataFrameStartDataFrameTransform (opts) { +function buildTransformStartTransform (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -20,10 +20,10 @@ function buildDataFrameStartDataFrameTransform (opts) { } /** - * Perform a data_frame.start_data_frame_transform request + * Perform a transform.start_transform request * https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html */ - return function dataFrameStartDataFrameTransform (params, options, callback) { + return function transformStartTransform (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -59,7 +59,7 @@ function buildDataFrameStartDataFrameTransform (opts) { var path = '' if (method == null) method = 'POST' - path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_start' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_start' // build request object const request = { @@ -74,4 +74,4 @@ function buildDataFrameStartDataFrameTransform (opts) { } } -module.exports = buildDataFrameStartDataFrameTransform +module.exports = buildTransformStartTransform diff --git a/api/api/data_frame.stop_data_frame_transform.js b/api/api/transform.stop_transform.js similarity index 84% rename from api/api/data_frame.stop_data_frame_transform.js rename to api/api/transform.stop_transform.js index 09a09bef2..1ee434793 100644 --- a/api/api/data_frame.stop_data_frame_transform.js +++ b/api/api/transform.stop_transform.js @@ -7,7 +7,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDataFrameStopDataFrameTransform (opts) { +function buildTransformStopTransform (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -23,10 +23,10 @@ function buildDataFrameStopDataFrameTransform (opts) { } /** - * Perform a data_frame.stop_data_frame_transform request + * Perform a transform.stop_transform request * https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html */ - return function dataFrameStopDataFrameTransform (params, options, callback) { + return function transformStopTransform (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -62,7 +62,7 @@ function buildDataFrameStopDataFrameTransform (opts) { var path = '' if (method == null) method = 'POST' - path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stop' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stop' // build request object const request = { @@ -77,4 +77,4 @@ function buildDataFrameStopDataFrameTransform (opts) { } } -module.exports = buildDataFrameStopDataFrameTransform +module.exports = buildTransformStopTransform diff --git a/api/api/data_frame.update_data_frame_transform.js b/api/api/transform.update_transform.js similarity index 84% rename from api/api/data_frame.update_data_frame_transform.js rename to api/api/transform.update_transform.js index dbb7519ef..d8623e7a9 100644 --- a/api/api/data_frame.update_data_frame_transform.js +++ b/api/api/transform.update_transform.js @@ -7,7 +7,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDataFrameUpdateDataFrameTransform (opts) { +function buildTransformUpdateTransform (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -20,10 +20,10 @@ function buildDataFrameUpdateDataFrameTransform (opts) { } /** - * Perform a data_frame.update_data_frame_transform request + * Perform a transform.update_transform request * https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html */ - return function dataFrameUpdateDataFrameTransform (params, options, callback) { + return function transformUpdateTransform (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -63,7 +63,7 @@ function buildDataFrameUpdateDataFrameTransform (opts) { var path = '' if (method == null) method = 'POST' - path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_update' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_update' // build request object const request = { @@ -78,4 +78,4 @@ function buildDataFrameUpdateDataFrameTransform (opts) { } } -module.exports = buildDataFrameUpdateDataFrameTransform +module.exports = buildTransformUpdateTransform diff --git a/api/index.js b/api/index.js index e64a3456c..79f9519f6 100644 --- a/api/index.js +++ b/api/index.js @@ -53,10 +53,14 @@ function ESAPI (opts) { forgetFollower: lazyLoad('ccr.forget_follower', opts), get_auto_follow_pattern: lazyLoad('ccr.get_auto_follow_pattern', opts), getAutoFollowPattern: lazyLoad('ccr.get_auto_follow_pattern', opts), + pause_auto_follow_pattern: lazyLoad('ccr.pause_auto_follow_pattern', opts), + pauseAutoFollowPattern: lazyLoad('ccr.pause_auto_follow_pattern', opts), pause_follow: lazyLoad('ccr.pause_follow', opts), pauseFollow: lazyLoad('ccr.pause_follow', opts), put_auto_follow_pattern: lazyLoad('ccr.put_auto_follow_pattern', opts), putAutoFollowPattern: lazyLoad('ccr.put_auto_follow_pattern', opts), + resume_auto_follow_pattern: lazyLoad('ccr.resume_auto_follow_pattern', opts), + resumeAutoFollowPattern: lazyLoad('ccr.resume_auto_follow_pattern', opts), resume_follow: lazyLoad('ccr.resume_follow', opts), resumeFollow: lazyLoad('ccr.resume_follow', opts), stats: lazyLoad('ccr.stats', opts), @@ -82,42 +86,6 @@ function ESAPI (opts) { }, count: lazyLoad('count', opts), create: lazyLoad('create', opts), - data_frame: { - delete_data_frame_transform: lazyLoad('data_frame.delete_data_frame_transform', opts), - deleteDataFrameTransform: lazyLoad('data_frame.delete_data_frame_transform', opts), - get_data_frame_transform: lazyLoad('data_frame.get_data_frame_transform', opts), - getDataFrameTransform: lazyLoad('data_frame.get_data_frame_transform', opts), - get_data_frame_transform_stats: lazyLoad('data_frame.get_data_frame_transform_stats', opts), - getDataFrameTransformStats: lazyLoad('data_frame.get_data_frame_transform_stats', opts), - preview_data_frame_transform: lazyLoad('data_frame.preview_data_frame_transform', opts), - previewDataFrameTransform: lazyLoad('data_frame.preview_data_frame_transform', opts), - put_data_frame_transform: lazyLoad('data_frame.put_data_frame_transform', opts), - putDataFrameTransform: lazyLoad('data_frame.put_data_frame_transform', opts), - start_data_frame_transform: lazyLoad('data_frame.start_data_frame_transform', opts), - startDataFrameTransform: lazyLoad('data_frame.start_data_frame_transform', opts), - stop_data_frame_transform: lazyLoad('data_frame.stop_data_frame_transform', opts), - stopDataFrameTransform: lazyLoad('data_frame.stop_data_frame_transform', opts), - update_data_frame_transform: lazyLoad('data_frame.update_data_frame_transform', opts), - updateDataFrameTransform: lazyLoad('data_frame.update_data_frame_transform', opts) - }, - dataFrame: { - delete_data_frame_transform: lazyLoad('data_frame.delete_data_frame_transform', opts), - deleteDataFrameTransform: lazyLoad('data_frame.delete_data_frame_transform', opts), - get_data_frame_transform: lazyLoad('data_frame.get_data_frame_transform', opts), - getDataFrameTransform: lazyLoad('data_frame.get_data_frame_transform', opts), - get_data_frame_transform_stats: lazyLoad('data_frame.get_data_frame_transform_stats', opts), - getDataFrameTransformStats: lazyLoad('data_frame.get_data_frame_transform_stats', opts), - preview_data_frame_transform: lazyLoad('data_frame.preview_data_frame_transform', opts), - previewDataFrameTransform: lazyLoad('data_frame.preview_data_frame_transform', opts), - put_data_frame_transform: lazyLoad('data_frame.put_data_frame_transform', opts), - putDataFrameTransform: lazyLoad('data_frame.put_data_frame_transform', opts), - start_data_frame_transform: lazyLoad('data_frame.start_data_frame_transform', opts), - startDataFrameTransform: lazyLoad('data_frame.start_data_frame_transform', opts), - stop_data_frame_transform: lazyLoad('data_frame.stop_data_frame_transform', opts), - stopDataFrameTransform: lazyLoad('data_frame.stop_data_frame_transform', opts), - update_data_frame_transform: lazyLoad('data_frame.update_data_frame_transform', opts), - updateDataFrameTransform: lazyLoad('data_frame.update_data_frame_transform', opts) - }, delete: lazyLoad('delete', opts), delete_by_query: lazyLoad('delete_by_query', opts), deleteByQuery: lazyLoad('delete_by_query', opts), @@ -125,6 +93,17 @@ function ESAPI (opts) { deleteByQueryRethrottle: lazyLoad('delete_by_query_rethrottle', opts), delete_script: lazyLoad('delete_script', opts), deleteScript: lazyLoad('delete_script', opts), + enrich: { + delete_policy: lazyLoad('enrich.delete_policy', opts), + deletePolicy: lazyLoad('enrich.delete_policy', opts), + execute_policy: lazyLoad('enrich.execute_policy', opts), + executePolicy: lazyLoad('enrich.execute_policy', opts), + get_policy: lazyLoad('enrich.get_policy', opts), + getPolicy: lazyLoad('enrich.get_policy', opts), + put_policy: lazyLoad('enrich.put_policy', opts), + putPolicy: lazyLoad('enrich.put_policy', opts), + stats: lazyLoad('enrich.stats', opts) + }, exists: lazyLoad('exists', opts), exists_source: lazyLoad('exists_source', opts), existsSource: lazyLoad('exists_source', opts), @@ -469,8 +448,12 @@ function ESAPI (opts) { deleteLifecycle: lazyLoad('slm.delete_lifecycle', opts), execute_lifecycle: lazyLoad('slm.execute_lifecycle', opts), executeLifecycle: lazyLoad('slm.execute_lifecycle', opts), + execute_retention: lazyLoad('slm.execute_retention', opts), + executeRetention: lazyLoad('slm.execute_retention', opts), get_lifecycle: lazyLoad('slm.get_lifecycle', opts), getLifecycle: lazyLoad('slm.get_lifecycle', opts), + get_stats: lazyLoad('slm.get_stats', opts), + getStats: lazyLoad('slm.get_stats', opts), put_lifecycle: lazyLoad('slm.put_lifecycle', opts), putLifecycle: lazyLoad('slm.put_lifecycle', opts) }, @@ -506,6 +489,24 @@ function ESAPI (opts) { list: lazyLoad('tasks.list', opts) }, termvectors: lazyLoad('termvectors', opts), + transform: { + delete_transform: lazyLoad('transform.delete_transform', opts), + deleteTransform: lazyLoad('transform.delete_transform', opts), + get_transform: lazyLoad('transform.get_transform', opts), + getTransform: lazyLoad('transform.get_transform', opts), + get_transform_stats: lazyLoad('transform.get_transform_stats', opts), + getTransformStats: lazyLoad('transform.get_transform_stats', opts), + preview_transform: lazyLoad('transform.preview_transform', opts), + previewTransform: lazyLoad('transform.preview_transform', opts), + put_transform: lazyLoad('transform.put_transform', opts), + putTransform: lazyLoad('transform.put_transform', opts), + start_transform: lazyLoad('transform.start_transform', opts), + startTransform: lazyLoad('transform.start_transform', opts), + stop_transform: lazyLoad('transform.stop_transform', opts), + stopTransform: lazyLoad('transform.stop_transform', opts), + update_transform: lazyLoad('transform.update_transform', opts), + updateTransform: lazyLoad('transform.update_transform', opts) + }, update: lazyLoad('update', opts), update_by_query: lazyLoad('update_by_query', opts), updateByQuery: lazyLoad('update_by_query', opts), diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index d1f1555bd..9883f9d50 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -32,7 +32,6 @@ export interface CatAliases extends Generic { name?: string | string[]; format?: string; local?: boolean; - master_timeout?: string; h?: string | string[]; help?: boolean; s?: string | string[]; @@ -54,8 +53,6 @@ export interface CatAllocation extends Generic { export interface CatCount extends Generic { index?: string | string[]; format?: string; - local?: boolean; - master_timeout?: string; h?: string | string[]; help?: boolean; s?: string | string[]; @@ -66,8 +63,6 @@ export interface CatFielddata extends Generic { fields?: string | string[]; format?: string; bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; - local?: boolean; - master_timeout?: string; h?: string | string[]; help?: boolean; s?: string | string[]; @@ -76,11 +71,10 @@ export interface CatFielddata extends Generic { export interface CatHealth extends Generic { format?: string; - local?: boolean; - master_timeout?: string; h?: string | string[]; help?: boolean; s?: string | string[]; + time?: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)'; ts?: boolean; v?: boolean; } @@ -101,6 +95,7 @@ export interface CatIndices extends Generic { help?: boolean; pri?: boolean; s?: string | string[]; + time?: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)'; v?: boolean; include_unloaded_segments?: boolean; } @@ -126,6 +121,7 @@ export interface CatNodeattrs extends Generic { } export interface CatNodes extends Generic { + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; format?: string; full_id?: boolean; local?: boolean; @@ -133,6 +129,7 @@ export interface CatNodes extends Generic { h?: string | string[]; help?: boolean; s?: string | string[]; + time?: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)'; v?: boolean; } @@ -143,6 +140,7 @@ export interface CatPendingTasks extends Generic { h?: string | string[]; help?: boolean; s?: string | string[]; + time?: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)'; v?: boolean; } @@ -159,11 +157,13 @@ export interface CatPlugins extends Generic { export interface CatRecovery extends Generic { index?: string | string[]; format?: string; + active_only?: boolean; bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; - master_timeout?: string; + detailed?: boolean; h?: string | string[]; help?: boolean; s?: string | string[]; + time?: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)'; v?: boolean; } @@ -196,6 +196,7 @@ export interface CatShards extends Generic { h?: string | string[]; help?: boolean; s?: string | string[]; + time?: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)'; v?: boolean; } @@ -207,6 +208,7 @@ export interface CatSnapshots extends Generic { h?: string | string[]; help?: boolean; s?: string | string[]; + time?: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)'; v?: boolean; } @@ -219,6 +221,7 @@ export interface CatTasks extends Generic { h?: string | string[]; help?: boolean; s?: string | string[]; + time?: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)'; v?: boolean; } @@ -351,7 +354,7 @@ export interface Create extends Generic { routing?: string; timeout?: string; version?: number; - version_type?: 'internal' | 'external' | 'external_gte' | 'force'; + version_type?: 'internal' | 'external' | 'external_gte'; pipeline?: string; body: T; } @@ -536,7 +539,7 @@ export interface Index extends Generic { routing?: string; timeout?: string; version?: number; - version_type?: 'internal' | 'external' | 'external_gte' | 'force'; + version_type?: 'internal' | 'external' | 'external_gte'; if_seq_no?: number; if_primary_term?: number; pipeline?: string; @@ -1367,6 +1370,10 @@ export interface CcrGetAutoFollowPattern extends Generic { name?: string; } +export interface CcrPauseAutoFollowPattern extends Generic { + name: string; +} + export interface CcrPauseFollow extends Generic { index: string; } @@ -1376,6 +1383,10 @@ export interface CcrPutAutoFollowPattern extends Generic { body: T; } +export interface CcrResumeAutoFollowPattern extends Generic { + name: string; +} + export interface CcrResumeFollow extends Generic { index: string; body?: T; @@ -1388,51 +1399,25 @@ export interface CcrUnfollow extends Generic { index: string; } -export interface DataFrameDeleteDataFrameTransform extends Generic { - transform_id: string; - force?: boolean; -} - -export interface DataFrameGetDataFrameTransform extends Generic { - transform_id?: string; - from?: number; - size?: number; - allow_no_match?: boolean; +export interface EnrichDeletePolicy extends Generic { + name: string; } -export interface DataFrameGetDataFrameTransformStats extends Generic { - transform_id: string; - from?: number; - size?: number; - allow_no_match?: boolean; +export interface EnrichExecutePolicy extends Generic { + name: string; + wait_for_completion?: boolean; } -export interface DataFramePreviewDataFrameTransform extends Generic { - body: T; +export interface EnrichGetPolicy extends Generic { + name?: string; } -export interface DataFramePutDataFrameTransform extends Generic { - transform_id: string; - defer_validation?: boolean; +export interface EnrichPutPolicy extends Generic { + name: string; body: T; } -export interface DataFrameStartDataFrameTransform extends Generic { - transform_id: string; - timeout?: string; -} - -export interface DataFrameStopDataFrameTransform extends Generic { - transform_id: string; - wait_for_completion?: boolean; - timeout?: string; - allow_no_match?: boolean; -} - -export interface DataFrameUpdateDataFrameTransform extends Generic { - transform_id: string; - defer_validation?: boolean; - body: T; +export interface EnrichStats extends Generic { } export interface GraphExplore extends Generic { @@ -1998,6 +1983,7 @@ export interface SecurityGetApiKey extends Generic { name?: string; username?: string; realm_name?: string; + owner?: boolean; } export interface SecurityGetBuiltinPrivileges extends Generic { @@ -2071,8 +2057,14 @@ export interface SlmExecuteLifecycle extends Generic { policy_id: string; } +export interface SlmExecuteRetention extends Generic { +} + export interface SlmGetLifecycle extends Generic { - policy_id?: string; + policy_id?: string | string[]; +} + +export interface SlmGetStats extends Generic { } export interface SlmPutLifecycle extends Generic { @@ -2096,6 +2088,53 @@ export interface SqlTranslate extends Generic { export interface SslCertificates extends Generic { } +export interface TransformDeleteTransform extends Generic { + transform_id: string; + force?: boolean; +} + +export interface TransformGetTransform extends Generic { + transform_id?: string; + from?: number; + size?: number; + allow_no_match?: boolean; +} + +export interface TransformGetTransformStats extends Generic { + transform_id: string; + from?: number; + size?: number; + allow_no_match?: boolean; +} + +export interface TransformPreviewTransform extends Generic { + body: T; +} + +export interface TransformPutTransform extends Generic { + transform_id: string; + defer_validation?: boolean; + body: T; +} + +export interface TransformStartTransform extends Generic { + transform_id: string; + timeout?: string; +} + +export interface TransformStopTransform extends Generic { + transform_id: string; + wait_for_completion?: boolean; + timeout?: string; + allow_no_match?: boolean; +} + +export interface TransformUpdateTransform extends Generic { + transform_id: string; + defer_validation?: boolean; + body: T; +} + export interface WatcherAckWatch extends Generic { watch_id: string; action_id?: string | string[]; diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 12e12685f..630c51142 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -181,6 +181,11 @@ function generateRequestId (params, options) { |`string` - The name to identify the client instance in the events. + _Default:_ `elasticsearch-js` +|`opaqueIdPrefix` +|`string` - A string that will be use to prefix any `X-Opaque-Id` header. + +See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/observability.html#_x-opaque-id_support[`X-Opaque-Id` support] for more details. + +_Default:_ `null` + |`headers` |`object` - A set of custom headers to send in every request. + _Default:_ `{}` diff --git a/docs/observability.asciidoc b/docs/observability.asciidoc index c72c340e1..074654f38 100644 --- a/docs/observability.asciidoc +++ b/docs/observability.asciidoc @@ -248,3 +248,46 @@ child.search({ if (err) console.log(err) }) ---- + +=== X-Opaque-Id support +To improve the overall observability, the client offers an easy way to configure the `X-Opaque-Id` header. If you set the `X-Opaque-Id` in a specific request, this will allow you to discover this identifier in the https://www.elastic.co/guide/en/elasticsearch/reference/master/logging.html#deprecation-logging[deprecation logs], help you with https://www.elastic.co/guide/en/elasticsearch/reference/master/index-modules-slowlog.html#_identifying_search_slow_log_origin[identifying search slow log origin] as well as https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html#_identifying_running_tasks[identifying running tasks]. + +The `X-Opaque-Id` should be configured in each request, for doing that you can use the `opaqueId` option, as you can see in the following example. + +The resulting header will be `{ 'X-Opaque-Id': 'my-search' }`. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ + node: 'http://localhost:9200' +}) + +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, { + opaqueId: 'my-search' +}, (err, result) => { + if (err) console.log(err) +}) +---- + +Sometimes it may be useful to prefix all the `X-Opaque-Id` headers with a specific string, in case you need to identify a specific client or server. For doing this, the client offers a top-level configuration option: `opaqueIdPrefix`. + +In the following example, the resulting header will be `{ 'X-Opaque-Id': 'proxy-client::my-search' }`. +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ + node: 'http://localhost:9200', + opaqueIdPrefix: 'proxy-client::' +}) + +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, { + opaqueId: 'my-search' +}, (err, result) => { + if (err) console.log(err) +}) +---- diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 6e3eecd48..4620e362d 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -1,18 +1,12 @@ [[api-reference]] == API Reference -This document contains the entire list of the {es} API supported by the client, -both OSS and commercial. The client is entirely licensed under Apache 2.0. +This document contains the entire list of the Elasticsearch API supported by the client, both OSS and commercial. The client is entirely licensed under Apache 2.0. -{es} exposes an HTTP layer to communicate with, and the client is a library that -helps you do this. Because of this reason, you will see HTTP related parameters, -such as `body` or `headers`. +Elasticsearch exposes an HTTP layer to communicate with, and the client is a library that will help you do this. Because of this reason, you will see HTTP related parameters, such as `body` or `headers`. -Every API can accept two objects, the first contains all the parameters that -will be sent to {es}, while the second includes the request specific parameters, -such as timeouts, headers, and so on. In the first object, every parameter but -the body will be sent via querystring or url parameter, depending on the API, -and every unrecognized parameter will be sent as querystring. +Every API can accept two objects, the first contains all the parameters that will be sent to Elasticsearch, while the second includes the request specific parameters, such as timeouts, headers, and so on. +In the first object, every parameter but the body will be sent via querystring or url parameter, depending on the API, and every unrecognized parameter will be sent as querystring. [source,js] ---- @@ -41,10 +35,7 @@ client.search({ }) ---- -In this document, you will find the reference of every parameter accepted by the -querystring or the url. If you also need to send the body, you can find the -documentation of its format in the reference link that is present along with -every endpoint. +In this document, you will find the reference of every parameter accepted by the querystring or the url. If you also need to send the body, you can find the documentation of its format in the reference link that is present along with every endpoint. //////// @@ -142,7 +133,6 @@ client.cat.aliases({ name: string | string[], format: string, local: boolean, - master_timeout: string, h: string | string[], help: boolean, s: string | string[], @@ -161,9 +151,6 @@ link:{ref}/cat-alias.html[Reference] |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - |`h` |`string \| string[]` - Comma-separated list of column names to display @@ -233,8 +220,6 @@ link:{ref}/cat-allocation.html[Reference] client.cat.count({ index: string | string[], format: string, - local: boolean, - master_timeout: string, h: string | string[], help: boolean, s: string | string[], @@ -250,12 +235,6 @@ link:{ref}/cat-count.html[Reference] |`format` |`string` - a short version of the Accept header, e.g. json, yaml -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - |`h` |`string \| string[]` - Comma-separated list of column names to display @@ -278,8 +257,6 @@ client.cat.fielddata({ fields: string | string[], format: string, bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - local: boolean, - master_timeout: string, h: string | string[], help: boolean, s: string | string[], @@ -298,12 +275,6 @@ link:{ref}/cat-fielddata.html[Reference] |`bytes` |`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - |`h` |`string \| string[]` - Comma-separated list of column names to display @@ -324,11 +295,10 @@ link:{ref}/cat-fielddata.html[Reference] ---- client.cat.health({ format: string, - local: boolean, - master_timeout: string, h: string | string[], help: boolean, s: string | string[], + time: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)', ts: boolean, v: boolean }) @@ -339,12 +309,6 @@ link:{ref}/cat-health.html[Reference] |`format` |`string` - a short version of the Accept header, e.g. json, yaml -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - |`h` |`string \| string[]` - Comma-separated list of column names to display @@ -354,6 +318,9 @@ link:{ref}/cat-health.html[Reference] |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +|`time` +|`'d (Days)' \| 'h (Hours)' \| 'm (Minutes)' \| 's (Seconds)' \| 'ms (Milliseconds)' \| 'micros (Microseconds)' \| 'nanos (Nanoseconds)'` - The unit in which to display time values + |`ts` |`boolean` - Set to false to disable timestamping + _Default:_ `true` @@ -398,6 +365,7 @@ client.cat.indices({ help: boolean, pri: boolean, s: string | string[], + time: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)', v: boolean, include_unloaded_segments: boolean }) @@ -435,6 +403,9 @@ link:{ref}/cat-indices.html[Reference] |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +|`time` +|`'d (Days)' \| 'h (Hours)' \| 'm (Minutes)' \| 's (Seconds)' \| 'ms (Milliseconds)' \| 'micros (Microseconds)' \| 'nanos (Nanoseconds)'` - The unit in which to display time values + |`v` |`boolean` - Verbose mode. Display column headers @@ -528,6 +499,7 @@ link:{ref}/cat-nodeattrs.html[Reference] [source,ts] ---- client.cat.nodes({ + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', format: string, full_id: boolean, local: boolean, @@ -535,12 +507,16 @@ client.cat.nodes({ h: string | string[], help: boolean, s: string | string[], + time: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)', v: boolean }) ---- link:{ref}/cat-nodes.html[Reference] [cols=2*] |=== +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + |`format` |`string` - a short version of the Accept header, e.g. json, yaml @@ -562,6 +538,9 @@ link:{ref}/cat-nodes.html[Reference] |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +|`time` +|`'d (Days)' \| 'h (Hours)' \| 'm (Minutes)' \| 's (Seconds)' \| 'ms (Milliseconds)' \| 'micros (Microseconds)' \| 'nanos (Nanoseconds)'` - The unit in which to display time values + |`v` |`boolean` - Verbose mode. Display column headers @@ -578,6 +557,7 @@ client.cat.pendingTasks({ h: string | string[], help: boolean, s: string | string[], + time: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)', v: boolean }) ---- @@ -602,6 +582,9 @@ link:{ref}/cat-pending-tasks.html[Reference] |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +|`time` +|`'d (Days)' \| 'h (Hours)' \| 'm (Minutes)' \| 's (Seconds)' \| 'ms (Milliseconds)' \| 'micros (Microseconds)' \| 'nanos (Nanoseconds)'` - The unit in which to display time values + |`v` |`boolean` - Verbose mode. Display column headers @@ -654,11 +637,13 @@ link:{ref}/cat-plugins.html[Reference] client.cat.recovery({ index: string | string[], format: string, + active_only: boolean, bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - master_timeout: string, + detailed: boolean, h: string | string[], help: boolean, s: string | string[], + time: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)', v: boolean }) ---- @@ -666,16 +651,19 @@ link:{ref}/cat-recovery.html[Reference] [cols=2*] |=== |`index` -|`string \| string[]` - A comma-separated list of index names to limit the returned information +|`string \| string[]` - Comma-separated list or wildcard expression of index names to limit the returned information |`format` |`string` - a short version of the Accept header, e.g. json, yaml +|`active_only` or `activeOnly` +|`boolean` - If `true`, the response only includes ongoing shard recoveries + |`bytes` |`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node +|`detailed` +|`boolean` - If `true`, the response includes detailed information about shard recoveries |`h` |`string \| string[]` - Comma-separated list of column names to display @@ -686,6 +674,9 @@ link:{ref}/cat-recovery.html[Reference] |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +|`time` +|`'d (Days)' \| 'h (Hours)' \| 'm (Minutes)' \| 's (Seconds)' \| 'ms (Milliseconds)' \| 'micros (Microseconds)' \| 'nanos (Nanoseconds)'` - The unit in which to display time values + |`v` |`boolean` - Verbose mode. Display column headers @@ -784,6 +775,7 @@ client.cat.shards({ h: string | string[], help: boolean, s: string | string[], + time: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)', v: boolean }) ---- @@ -814,6 +806,9 @@ link:{ref}/cat-shards.html[Reference] |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +|`time` +|`'d (Days)' \| 'h (Hours)' \| 'm (Minutes)' \| 's (Seconds)' \| 'ms (Milliseconds)' \| 'micros (Microseconds)' \| 'nanos (Nanoseconds)'` - The unit in which to display time values + |`v` |`boolean` - Verbose mode. Display column headers @@ -831,6 +826,7 @@ client.cat.snapshots({ h: string | string[], help: boolean, s: string | string[], + time: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)', v: boolean }) ---- @@ -858,6 +854,9 @@ link:{ref}/cat-snapshots.html[Reference] |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +|`time` +|`'d (Days)' \| 'h (Hours)' \| 'm (Minutes)' \| 's (Seconds)' \| 'ms (Milliseconds)' \| 'micros (Microseconds)' \| 'nanos (Nanoseconds)'` - The unit in which to display time values + |`v` |`boolean` - Verbose mode. Display column headers @@ -876,6 +875,7 @@ client.cat.tasks({ h: string | string[], help: boolean, s: string | string[], + time: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)', v: boolean }) ---- @@ -906,6 +906,9 @@ link:{ref}/tasks.html[Reference] |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +|`time` +|`'d (Days)' \| 'h (Hours)' \| 'm (Minutes)' \| 's (Seconds)' \| 'ms (Milliseconds)' \| 'micros (Microseconds)' \| 'nanos (Nanoseconds)'` - The unit in which to display time values + |`v` |`boolean` - Verbose mode. Display column headers @@ -1408,7 +1411,7 @@ client.create({ routing: string, timeout: string, version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force', + version_type: 'internal' | 'external' | 'external_gte', pipeline: string, body: object }) @@ -1443,7 +1446,7 @@ WARNING: This parameter has been deprecated. |`number` - Explicit version number for concurrency control |`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +|`'internal' \| 'external' \| 'external_gte'` - Specific version type |`pipeline` |`string` - The pipeline id to preprocess incoming documents with @@ -2119,7 +2122,7 @@ client.index({ routing: string, timeout: string, version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force', + version_type: 'internal' | 'external' | 'external_gte', if_seq_no: number, if_primary_term: number, pipeline: string, @@ -2144,8 +2147,7 @@ WARNING: This parameter has been deprecated. |`string` - 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) |`op_type` or `opType` -|`'index' \| 'create'` - Explicit operation type + -_Default:_ `index` +|`'index' \| 'create'` - Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID |`refresh` |`'true' \| 'false' \| 'wait_for'` - 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. @@ -2160,7 +2162,7 @@ _Default:_ `index` |`number` - Explicit version number for concurrency control |`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +|`'internal' \| 'external' \| 'external_gte'` - Specific version type |`if_seq_no` or `ifSeqNo` |`number` - only perform the index operation if the last operation that has changed the document has the specified sequence number @@ -5507,6 +5509,22 @@ link:{ref}/ccr-get-auto-follow-pattern.html[Reference] |=== +=== ccr.pauseAutoFollowPattern + +[source,ts] +---- +client.ccr.pauseAutoFollowPattern({ + name: string +}) +---- +link:{ref}/ccr-pause-auto-follow-pattern.html[Reference] +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern that should pause discovering new indices to follow. + +|=== + === ccr.pauseFollow [source,ts] @@ -5543,6 +5561,22 @@ link:{ref}/ccr-put-auto-follow-pattern.html[Reference] |=== +=== ccr.resumeAutoFollowPattern + +[source,ts] +---- +client.ccr.resumeAutoFollowPattern({ + name: string +}) +---- +link:{ref}/ccr-resume-auto-follow-pattern.html[Reference] +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern to resume discovering new indices to follow. + +|=== + === ccr.resumeFollow [source,ts] @@ -5588,193 +5622,82 @@ link:http://www.elastic.co/guide/en/elasticsearch/reference/current[Reference] |=== -=== dataFrame.deleteDataFrameTransform -*Stability:* beta -[source,ts] ----- -client.dataFrame.deleteDataFrameTransform({ - transform_id: string, - force: boolean -}) ----- -link:{ref}/delete-transform.html[Reference] -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform to delete +=== enrich.deletePolicy -|`force` -|`boolean` - When `true`, the transform is deleted regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be deleted. - -|=== - -=== dataFrame.getDataFrameTransform -*Stability:* beta [source,ts] ---- -client.dataFrame.getDataFrameTransform({ - transform_id: string, - from: number, - size: number, - allow_no_match: boolean +client.enrich.deletePolicy({ + name: string }) ---- -link:{ref}/get-transform.html[Reference] [cols=2*] |=== -|`transform_id` or `transformId` -|`string` - The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all transforms - -|`from` -|`number` - skips a number of transform configs, defaults to 0 - -|`size` -|`number` - specifies a max number of transforms to get, defaults to 100 - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no data frame transforms. (This includes `_all` string or when no data frame transforms have been specified) +|`name` +|`string` - The name of the enrich policy |=== -=== dataFrame.getDataFrameTransformStats -*Stability:* beta +=== enrich.executePolicy + [source,ts] ---- -client.dataFrame.getDataFrameTransformStats({ - transform_id: string, - from: number, - size: number, - allow_no_match: boolean +client.enrich.executePolicy({ + name: string, + wait_for_completion: boolean }) ---- -link:{ref}/get-transform-stats.html[Reference] [cols=2*] |=== -|`transform_id` or `transformId` -|`string` - The id of the transform for which to get stats. '_all' or '*' implies all transforms - -|`from` -|`number` - skips a number of transform stats, defaults to 0 - -|`size` -|`number` - specifies a max number of transform stats to get, defaults to 100 +|`name` +|`string` - The name of the enrich policy -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no data frame transforms. (This includes `_all` string or when no data frame transforms have been specified) +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request should block until the execution is complete. + +_Default:_ `true` |=== -=== dataFrame.previewDataFrameTransform -*Stability:* beta +=== enrich.getPolicy + [source,ts] ---- -client.dataFrame.previewDataFrameTransform({ - body: object +client.enrich.getPolicy({ + name: string }) ---- -link:{ref}/preview-transform.html[Reference] [cols=2*] |=== -|`body` -|`object` - The definition for the data_frame transform to preview +|`name` +|`string` - The name of the enrich policy |=== -=== dataFrame.putDataFrameTransform -*Stability:* beta +=== enrich.putPolicy + [source,ts] ---- -client.dataFrame.putDataFrameTransform({ - transform_id: string, - defer_validation: boolean, +client.enrich.putPolicy({ + name: string, body: object }) ---- -link:{ref}/put-transform.html[Reference] [cols=2*] |=== -|`transform_id` or `transformId` -|`string` - The id of the new transform. - -|`defer_validation` or `deferValidation` -|`boolean` - If validations should be deferred until data frame transform starts, defaults to false. +|`name` +|`string` - The name of the enrich policy |`body` -|`object` - The data frame transform definition +|`object` - The enrich policy to register |=== -=== dataFrame.startDataFrameTransform -*Stability:* beta -[source,ts] ----- -client.dataFrame.startDataFrameTransform({ - transform_id: string, - timeout: string -}) ----- -link:{ref}/start-transform.html[Reference] -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform to start +=== enrich.stats -|`timeout` -|`string` - Controls the time to wait for the transform to start - -|=== - -=== dataFrame.stopDataFrameTransform -*Stability:* beta [source,ts] ---- -client.dataFrame.stopDataFrameTransform({ - transform_id: string, - wait_for_completion: boolean, - timeout: string, - allow_no_match: boolean -}) +client.enrich.stats() ---- -link:{ref}/stop-transform.html[Reference] -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform to stop - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Whether to wait for the transform to fully stop before returning or not. Default to false -|`timeout` -|`string` - Controls the time to wait until the transform has stopped. Default to 30 seconds - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no data frame transforms. (This includes `_all` string or when no data frame transforms have been specified) - -|=== - -=== dataFrame.updateDataFrameTransform -*Stability:* beta -[source,ts] ----- -client.dataFrame.updateDataFrameTransform({ - transform_id: string, - defer_validation: boolean, - body: object -}) ----- -link:{ref}/update-transform.html[Reference] -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform. - -|`defer_validation` or `deferValidation` -|`boolean` - If validations should be deferred until data frame transform starts, defaults to false. - -|`body` -|`object` - The update data frame transform definition - -|=== === graph.explore @@ -6408,6 +6331,22 @@ link:{ref}/ml-delete-snapshot.html[Reference] |=== +=== ml.estimateMemoryUsage +*Stability:* experimental +[source,ts] +---- +client.ml.estimateMemoryUsage({ + body: object +}) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/estimate-memory-usage-dfanalytics.html[Reference] +[cols=2*] +|=== +|`body` +|`object` - Memory usage estimation definition + +|=== + === ml.evaluateDataFrame *Stability:* experimental [source,ts] @@ -7965,7 +7904,8 @@ client.security.getApiKey({ id: string, name: string, username: string, - realm_name: string + realm_name: string, + owner: boolean }) ---- link:{ref}/security-api-get-api-key.html[Reference] @@ -7983,6 +7923,9 @@ link:{ref}/security-api-get-api-key.html[Reference] |`realm_name` or `realmName` |`string` - realm name of the user who created this API key to be retrieved +|`owner` +|`boolean` - flag to query API keys owned by the currently authenticated user + |=== === security.getBuiltinPrivileges @@ -8263,22 +8206,40 @@ link:{ref}/slm-api-execute.html[Reference] |=== +=== slm.executeRetention + +[source,ts] +---- +client.slm.executeRetention() +---- +link:{ref}/slm-api-execute-retention.html[Reference] + + === slm.getLifecycle [source,ts] ---- client.slm.getLifecycle({ - policy_id: string + policy_id: string | string[] }) ---- link:{ref}/slm-api-get.html[Reference] [cols=2*] |=== |`policy_id` or `policyId` -|`string` - Comma-separated list of snapshot lifecycle policies to retrieve +|`string \| string[]` - Comma-separated list of snapshot lifecycle policies to retrieve |=== +=== slm.getStats + +[source,ts] +---- +client.slm.getStats() +---- +link:{ref}/slm-get-stats.html[Reference] + + === slm.putLifecycle [source,ts] @@ -8360,6 +8321,194 @@ client.ssl.certificates() link:{ref}/security-api-ssl.html[Reference] +=== transform.deleteTransform +*Stability:* beta +[source,ts] +---- +client.transform.deleteTransform({ + transform_id: string, + force: boolean +}) +---- +link:{ref}/delete-transform.html[Reference] +[cols=2*] +|=== +|`transform_id` or `transformId` +|`string` - The id of the transform to delete + +|`force` +|`boolean` - When `true`, the transform is deleted regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be deleted. + +|=== + +=== transform.getTransform +*Stability:* beta +[source,ts] +---- +client.transform.getTransform({ + transform_id: string, + from: number, + size: number, + allow_no_match: boolean +}) +---- +link:{ref}/get-transform.html[Reference] +[cols=2*] +|=== +|`transform_id` or `transformId` +|`string` - The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all transforms + +|`from` +|`number` - skips a number of transform configs, defaults to 0 + +|`size` +|`number` - specifies a max number of transforms to get, defaults to 100 + +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) + +|=== + +=== transform.getTransformStats +*Stability:* beta +[source,ts] +---- +client.transform.getTransformStats({ + transform_id: string, + from: number, + size: number, + allow_no_match: boolean +}) +---- +link:{ref}/get-transform-stats.html[Reference] +[cols=2*] +|=== +|`transform_id` or `transformId` +|`string` - The id of the transform for which to get stats. '_all' or '*' implies all transforms + +|`from` +|`number` - skips a number of transform stats, defaults to 0 + +|`size` +|`number` - specifies a max number of transform stats to get, defaults to 100 + +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) + +|=== + +=== transform.previewTransform +*Stability:* beta +[source,ts] +---- +client.transform.previewTransform({ + body: object +}) +---- +link:{ref}/preview-transform.html[Reference] +[cols=2*] +|=== +|`body` +|`object` - The definition for the transform to preview + +|=== + +=== transform.putTransform +*Stability:* beta +[source,ts] +---- +client.transform.putTransform({ + transform_id: string, + defer_validation: boolean, + body: object +}) +---- +link:{ref}/put-transform.html[Reference] +[cols=2*] +|=== +|`transform_id` or `transformId` +|`string` - The id of the new transform. + +|`defer_validation` or `deferValidation` +|`boolean` - If validations should be deferred until transform starts, defaults to false. + +|`body` +|`object` - The transform definition + +|=== + +=== transform.startTransform +*Stability:* beta +[source,ts] +---- +client.transform.startTransform({ + transform_id: string, + timeout: string +}) +---- +link:{ref}/start-transform.html[Reference] +[cols=2*] +|=== +|`transform_id` or `transformId` +|`string` - The id of the transform to start + +|`timeout` +|`string` - Controls the time to wait for the transform to start + +|=== + +=== transform.stopTransform +*Stability:* beta +[source,ts] +---- +client.transform.stopTransform({ + transform_id: string, + wait_for_completion: boolean, + timeout: string, + allow_no_match: boolean +}) +---- +link:{ref}/stop-transform.html[Reference] +[cols=2*] +|=== +|`transform_id` or `transformId` +|`string` - The id of the transform to stop + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Whether to wait for the transform to fully stop before returning or not. Default to false + +|`timeout` +|`string` - Controls the time to wait until the transform has stopped. Default to 30 seconds + +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) + +|=== + +=== transform.updateTransform +*Stability:* beta +[source,ts] +---- +client.transform.updateTransform({ + transform_id: string, + defer_validation: boolean, + body: object +}) +---- +link:{ref}/update-transform.html[Reference] +[cols=2*] +|=== +|`transform_id` or `transformId` +|`string` - The id of the transform. + +|`defer_validation` or `deferValidation` +|`boolean` - If validations should be deferred until transform starts, defaults to false. + +|`body` +|`object` - The update transform definition + +|=== + === watcher.ackWatch [source,ts] diff --git a/index.d.ts b/index.d.ts index a23793e36..f0879b818 100644 --- a/index.d.ts +++ b/index.d.ts @@ -94,6 +94,7 @@ interface ClientOptions { nodeFilter?: nodeFilterFn; nodeSelector?: nodeSelectorFn | string; headers?: anyObject; + opaqueIdPrefix?: string; generateRequestId?: generateRequestIdFn; name?: string; auth?: BasicAuth | ApiKeyAuth; @@ -151,10 +152,14 @@ declare class Client extends EventEmitter { forgetFollower: ApiMethod get_auto_follow_pattern: ApiMethod getAutoFollowPattern: ApiMethod + pause_auto_follow_pattern: ApiMethod + pauseAutoFollowPattern: ApiMethod pause_follow: ApiMethod pauseFollow: ApiMethod put_auto_follow_pattern: ApiMethod putAutoFollowPattern: ApiMethod + resume_auto_follow_pattern: ApiMethod + resumeAutoFollowPattern: ApiMethod resume_follow: ApiMethod resumeFollow: ApiMethod stats: ApiMethod @@ -180,42 +185,6 @@ declare class Client extends EventEmitter { } count: ApiMethod create: ApiMethod - data_frame: { - delete_data_frame_transform: ApiMethod - deleteDataFrameTransform: ApiMethod - get_data_frame_transform: ApiMethod - getDataFrameTransform: ApiMethod - get_data_frame_transform_stats: ApiMethod - getDataFrameTransformStats: ApiMethod - preview_data_frame_transform: ApiMethod - previewDataFrameTransform: ApiMethod - put_data_frame_transform: ApiMethod - putDataFrameTransform: ApiMethod - start_data_frame_transform: ApiMethod - startDataFrameTransform: ApiMethod - stop_data_frame_transform: ApiMethod - stopDataFrameTransform: ApiMethod - update_data_frame_transform: ApiMethod - updateDataFrameTransform: ApiMethod - } - dataFrame: { - delete_data_frame_transform: ApiMethod - deleteDataFrameTransform: ApiMethod - get_data_frame_transform: ApiMethod - getDataFrameTransform: ApiMethod - get_data_frame_transform_stats: ApiMethod - getDataFrameTransformStats: ApiMethod - preview_data_frame_transform: ApiMethod - previewDataFrameTransform: ApiMethod - put_data_frame_transform: ApiMethod - putDataFrameTransform: ApiMethod - start_data_frame_transform: ApiMethod - startDataFrameTransform: ApiMethod - stop_data_frame_transform: ApiMethod - stopDataFrameTransform: ApiMethod - update_data_frame_transform: ApiMethod - updateDataFrameTransform: ApiMethod - } delete: ApiMethod delete_by_query: ApiMethod deleteByQuery: ApiMethod @@ -223,6 +192,17 @@ declare class Client extends EventEmitter { deleteByQueryRethrottle: ApiMethod delete_script: ApiMethod deleteScript: ApiMethod + enrich: { + delete_policy: ApiMethod + deletePolicy: ApiMethod + execute_policy: ApiMethod + executePolicy: ApiMethod + get_policy: ApiMethod + getPolicy: ApiMethod + put_policy: ApiMethod + putPolicy: ApiMethod + stats: ApiMethod + } exists: ApiMethod exists_source: ApiMethod existsSource: ApiMethod @@ -567,8 +547,12 @@ declare class Client extends EventEmitter { deleteLifecycle: ApiMethod execute_lifecycle: ApiMethod executeLifecycle: ApiMethod + execute_retention: ApiMethod + executeRetention: ApiMethod get_lifecycle: ApiMethod getLifecycle: ApiMethod + get_stats: ApiMethod + getStats: ApiMethod put_lifecycle: ApiMethod putLifecycle: ApiMethod } @@ -604,6 +588,24 @@ declare class Client extends EventEmitter { list: ApiMethod } termvectors: ApiMethod + transform: { + delete_transform: ApiMethod + deleteTransform: ApiMethod + get_transform: ApiMethod + getTransform: ApiMethod + get_transform_stats: ApiMethod + getTransformStats: ApiMethod + preview_transform: ApiMethod + previewTransform: ApiMethod + put_transform: ApiMethod + putTransform: ApiMethod + start_transform: ApiMethod + startTransform: ApiMethod + stop_transform: ApiMethod + stopTransform: ApiMethod + update_transform: ApiMethod + updateTransform: ApiMethod + } update: ApiMethod update_by_query: ApiMethod updateByQuery: ApiMethod diff --git a/index.js b/index.js index 6fc3e7708..0b3fc17c7 100644 --- a/index.js +++ b/index.js @@ -79,7 +79,8 @@ class Client extends EventEmitter { nodeSelector: 'round-robin', generateRequestId: null, name: 'elasticsearch-js', - auth: null + auth: null, + opaqueIdPrefix: null }, opts) this[kInitialOptions] = options @@ -121,7 +122,8 @@ class Client extends EventEmitter { nodeFilter: options.nodeFilter, nodeSelector: options.nodeSelector, generateRequestId: options.generateRequestId, - name: options.name + name: options.name, + opaqueIdPrefix: options.opaqueIdPrefix }) const apis = buildApi({ diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 8099de2ea..f0fdae9d4 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -38,6 +38,7 @@ interface TransportOptions { headers?: anyObject; generateRequestId?: generateRequestIdFn; name: string; + opaqueIdPrefix?: string; } export interface RequestEvent { @@ -90,6 +91,7 @@ export interface TransportRequestOptions { id?: any; context?: any; warnings?: [string]; + opaqueId?: string; } export interface TransportRequestCallback { @@ -121,6 +123,7 @@ export default class Transport { compression: 'gzip' | false; sniffInterval: number; sniffOnConnectionFault: boolean; + opaqueIdPrefix: string | null; sniffEndpoint: string; _sniffEnabled: boolean; _nextSniff: number; diff --git a/lib/Transport.js b/lib/Transport.js index 7e5b83681..d00a2e8bb 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -41,6 +41,7 @@ class Transport { this.sniffEndpoint = opts.sniffEndpoint this.generateRequestId = opts.generateRequestId || generateRequestId() this.name = opts.name + this.opaqueIdPrefix = opts.opaqueIdPrefix this.nodeFilter = opts.nodeFilter || defaultNodeFilter if (typeof opts.nodeSelector === 'function') { @@ -114,6 +115,12 @@ class Transport { // TODO: make this assignment FAST const headers = Object.assign({}, this.headers, options.headers) + if (options.opaqueId !== undefined) { + headers['X-Opaque-Id'] = this.opaqueIdPrefix !== null + ? this.opaqueIdPrefix + options.opaqueId + : options.opaqueId + } + // handle json body if (params.body != null) { if (shouldSerialize(params.body) === true) { diff --git a/scripts/generate.js b/scripts/generate.js index 86c944ffc..e1c23de46 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -48,6 +48,7 @@ function start (opts) { const apiFolderContents = readdirSync(apiFolder) const xPackFolderContents = readdirSync(xPackFolder) + .filter(file => !file.startsWith('data_frame_transform_deprecated')) apiFolderContents.forEach(generateApiFile(apiFolder, log)) xPackFolderContents.forEach(generateApiFile(xPackFolder, log)) diff --git a/test/integration/helper.js b/test/integration/helper.js index b8b0a7dfa..f9d0d8eec 100644 --- a/test/integration/helper.js +++ b/test/integration/helper.js @@ -13,6 +13,7 @@ const esDefaultRoles = [ 'code_user', 'data_frame_transforms_admin', 'data_frame_transforms_user', + 'enrich_user', 'ingest_admin', 'kibana_dashboard_only_user', 'kibana_system', @@ -29,6 +30,8 @@ const esDefaultRoles = [ 'rollup_user', 'snapshot_user', 'superuser', + 'transform_admin', + 'transform_user', 'transport_client', 'watcher_admin', 'watcher_user' diff --git a/test/unit/client.test.js b/test/unit/client.test.js index f6a86a985..ca3649379 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -851,3 +851,87 @@ test('Elastic cloud config', t => { t.end() }) + +test('Opaque Id support', t => { + t.test('No opaqueId', t => { + t.plan(3) + + function handler (req, res) { + t.strictEqual(req.headers['x-opaque-id'], undefined) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://localhost:${port}` + }) + + client.search({ + index: 'test', + q: 'foo:bar' + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) + }) + + t.test('No prefix', t => { + t.plan(3) + + function handler (req, res) { + t.strictEqual(req.headers['x-opaque-id'], 'bar') + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://localhost:${port}` + }) + + client.search({ + index: 'test', + q: 'foo:bar' + }, { + opaqueId: 'bar' + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) + }) + + t.test('With prefix', t => { + t.plan(3) + + function handler (req, res) { + t.strictEqual(req.headers['x-opaque-id'], 'foo-bar') + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://localhost:${port}`, + opaqueIdPrefix: 'foo-' + }) + + client.search({ + index: 'test', + q: 'foo:bar' + }, { + opaqueId: 'bar' + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) + }) + + t.end() +})