diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 2aee8f125..94fda34be 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -101,6 +101,49 @@ jobs: run: | npm run test:integration:helpers + bundler-support: + name: Bundler support + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Configure sysctl limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + + - name: Runs Elasticsearch + uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 8.0.0-SNAPSHOT + + - name: Use Node.js 14.x + uses: actions/setup-node@v1 + with: + node-version: 14.x + + - name: Install + run: | + npm install + npm install --prefix test/bundlers/parcel-test + npm install --prefix test/bundlers/rollup-test + npm install --prefix test/bundlers/webpack-test + + - name: Build + run: | + npm run build --prefix test/bundlers/parcel-test + npm run build --prefix test/bundlers/rollup-test + npm run build --prefix test/bundlers/webpack-test + + - name: Run bundle + run: | + npm start --prefix test/bundlers/parcel-test + npm start --prefix test/bundlers/rollup-test + npm start --prefix test/bundlers/webpack-test + code-coverage: name: Code coverage runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index c610926ce..4e5d66081 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,7 @@ elasticsearch* test/benchmarks/macro/fixtures/* *-junit.xml + +.cache + +test/bundlers/**/bundle.js diff --git a/api/api/async_search.js b/api/api/async_search.js new file mode 100644 index 000000000..d7e4ee8e7 --- /dev/null +++ b/api/api/async_search.js @@ -0,0 +1,114 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_completion_timeout', 'keep_alive', 'typed_keys', 'keep_on_completion', 'batched_reduce_size', 'request_cache', 'analyzer', 'analyze_wildcard', 'default_operator', 'df', 'explain', 'stored_fields', 'docvalue_fields', 'from', 'ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'lenient', 'preference', 'q', 'routing', 'search_type', 'size', 'sort', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'terminate_after', 'stats', 'suggest_field', 'suggest_mode', 'suggest_size', 'suggest_text', 'timeout', 'track_scores', 'track_total_hits', 'allow_partial_search_results', 'version', 'seq_no_primary_term', 'max_concurrent_shard_requests'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', waitForCompletionTimeout: 'wait_for_completion_timeout', keepAlive: 'keep_alive', typedKeys: 'typed_keys', keepOnCompletion: 'keep_on_completion', batchedReduceSize: 'batched_reduce_size', requestCache: 'request_cache', analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', storedFields: 'stored_fields', docvalueFields: 'docvalue_fields', ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', terminateAfter: 'terminate_after', suggestField: 'suggest_field', suggestMode: 'suggest_mode', suggestSize: 'suggest_size', suggestText: 'suggest_text', trackScores: 'track_scores', trackTotalHits: 'track_total_hits', allowPartialSearchResults: 'allow_partial_search_results', seqNoPrimaryTerm: 'seq_no_primary_term', maxConcurrentShardRequests: 'max_concurrent_shard_requests' } + +function AsyncSearchApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +AsyncSearchApi.prototype.delete = function asyncSearchDeleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_async_search' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +AsyncSearchApi.prototype.get = function asyncSearchGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_async_search' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +AsyncSearchApi.prototype.submit = function asyncSearchSubmitApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_async_search' + } else { + if (method == null) method = 'POST' + path = '/' + '_async_search' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = AsyncSearchApi diff --git a/api/api/autoscaling.js b/api/api/autoscaling.js new file mode 100644 index 000000000..7a968b06c --- /dev/null +++ b/api/api/autoscaling.js @@ -0,0 +1,147 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function AutoscalingApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +AutoscalingApi.prototype.deleteAutoscalingPolicy = function autoscalingDeleteAutoscalingPolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_autoscaling' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +AutoscalingApi.prototype.getAutoscalingDecision = function autoscalingGetAutoscalingDecisionApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_autoscaling' + '/' + 'decision' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +AutoscalingApi.prototype.getAutoscalingPolicy = function autoscalingGetAutoscalingPolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_autoscaling' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +AutoscalingApi.prototype.putAutoscalingPolicy = function autoscalingPutAutoscalingPolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_autoscaling' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(AutoscalingApi.prototype, { + delete_autoscaling_policy: { get () { return this.deleteAutoscalingPolicy } }, + get_autoscaling_decision: { get () { return this.getAutoscalingDecision } }, + get_autoscaling_policy: { get () { return this.getAutoscalingPolicy } }, + put_autoscaling_policy: { get () { return this.putAutoscalingPolicy } } +}) + +module.exports = AutoscalingApi diff --git a/api/api/bulk.js b/api/api/bulk.js index 683c50310..8a3f3edb0 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -7,10 +7,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildBulk (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'type', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'pipeline', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'wait_for_active_shards', 'refresh', @@ -38,76 +39,47 @@ function buildBulk (opts) { _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +function bulkApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } - /** - * Perform a bulk request - * Allows to perform multiple index/update/delete operations in a single request. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html - */ - return function bulk (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['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - 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, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null) { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_bulk' - } else if ((index) != null) { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_bulk' - } else { - if (method == null) method = 'POST' - path = '/' + '_bulk' - } - - // build request object - const request = { - method, - path, - bulkBody: body, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) } + + var { method, body, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (type) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_bulk' + } else if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_bulk' + } else { + if (method == null) method = 'POST' + path = '/' + '_bulk' + } + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildBulk +module.exports = bulkApi diff --git a/api/api/cat.js b/api/api/cat.js new file mode 100644 index 000000000..5958aa02b --- /dev/null +++ b/api/api/cat.js @@ -0,0 +1,648 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['format', 'local', 'h', 'help', 's', 'v', 'expand_wildcards', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'bytes', 'master_timeout', 'fields', 'time', 'ts', 'health', 'pri', 'include_unloaded_segments', 'full_id', 'active_only', 'detailed', 'index', 'ignore_unavailable', 'node_id', 'actions', 'parent_task', 'allow_no_match', 'allow_no_datafeeds', 'allow_no_jobs', 'from', 'size'] +const snakeCase = { expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path', masterTimeout: 'master_timeout', includeUnloadedSegments: 'include_unloaded_segments', fullId: 'full_id', activeOnly: 'active_only', ignoreUnavailable: 'ignore_unavailable', nodeId: 'node_id', parentTask: 'parent_task', allowNoMatch: 'allow_no_match', allowNoDatafeeds: 'allow_no_datafeeds', allowNoJobs: 'allow_no_jobs' } + +function CatApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +CatApi.prototype.aliases = function catAliasesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'aliases' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.allocation = function catAllocationApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(node_id || nodeId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'allocation' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.count = function catCountApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'count' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.fielddata = function catFielddataApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, fields, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((fields) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(fields) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'fielddata' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.health = function catHealthApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'health' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.help = function catHelpApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.indices = function catIndicesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'indices' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.master = function catMasterApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'master' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.nodeattrs = function catNodeattrsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'nodeattrs' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.nodes = function catNodesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'nodes' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.pendingTasks = function catPendingTasksApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'pending_tasks' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.plugins = function catPluginsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'plugins' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.recovery = function catRecoveryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'recovery' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.repositories = function catRepositoriesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'repositories' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.segments = function catSegmentsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'segments' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.shards = function catShardsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'shards' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.snapshots = function catSnapshotsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((repository) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(repository) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'snapshots' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.tasks = function catTasksApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'tasks' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.templates = function catTemplatesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'templates' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.threadPool = function catThreadPoolApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, threadPoolPatterns, thread_pool_patterns, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((thread_pool_patterns || threadPoolPatterns) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'thread_pool' + '/' + encodeURIComponent(thread_pool_patterns || threadPoolPatterns) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'thread_pool' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.mlDataFrameAnalytics = function catMlDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'data_frame' + '/' + 'analytics' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.mlDatafeeds = function catMlDatafeedsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((datafeed_id || datafeedId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'datafeeds' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.mlJobs = function catMlJobsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.mlTrainedModels = function catMlTrainedModelsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, modelId, model_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((model_id || modelId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'trained_models' + '/' + encodeURIComponent(model_id || modelId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'trained_models' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.transforms = function catTransformsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((transform_id || transformId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'transforms' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(CatApi.prototype, { + pending_tasks: { get () { return this.pendingTasks } }, + thread_pool: { get () { return this.threadPool } }, + ml_data_frame_analytics: { get () { return this.mlDataFrameAnalytics } }, + ml_datafeeds: { get () { return this.mlDatafeeds } }, + ml_jobs: { get () { return this.mlJobs } }, + ml_trained_models: { get () { return this.mlTrainedModels } } +}) + +module.exports = CatApi diff --git a/api/api/ccr.js b/api/api/ccr.js new file mode 100644 index 000000000..e832c7491 --- /dev/null +++ b/api/api/ccr.js @@ -0,0 +1,403 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_active_shards'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', waitForActiveShards: 'wait_for_active_shards' } + +function CcrApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +CcrApi.prototype.deleteAutoFollowPattern = function ccrDeleteAutoFollowPatternApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.follow = function ccrFollowApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'follow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.followInfo = function ccrFollowInfoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'info' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.followStats = function ccrFollowStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.forgetFollower = function ccrForgetFollowerApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'forget_follower' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.getAutoFollowPattern = function ccrGetAutoFollowPatternApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_ccr' + '/' + 'auto_follow' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.pauseAutoFollowPattern = function ccrPauseAutoFollowPatternApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + '/' + 'pause' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.pauseFollow = function ccrPauseFollowApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'pause_follow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.putAutoFollowPattern = function ccrPutAutoFollowPatternApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.resumeAutoFollowPattern = function ccrResumeAutoFollowPatternApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + '/' + 'resume' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.resumeFollow = function ccrResumeFollowApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'resume_follow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.stats = function ccrStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ccr' + '/' + 'stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.unfollow = function ccrUnfollowApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'unfollow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(CcrApi.prototype, { + delete_auto_follow_pattern: { get () { return this.deleteAutoFollowPattern } }, + follow_info: { get () { return this.followInfo } }, + follow_stats: { get () { return this.followStats } }, + forget_follower: { get () { return this.forgetFollower } }, + get_auto_follow_pattern: { get () { return this.getAutoFollowPattern } }, + pause_auto_follow_pattern: { get () { return this.pauseAutoFollowPattern } }, + pause_follow: { get () { return this.pauseFollow } }, + put_auto_follow_pattern: { get () { return this.putAutoFollowPattern } }, + resume_auto_follow_pattern: { get () { return this.resumeAutoFollowPattern } }, + resume_follow: { get () { return this.resumeFollow } } +}) + +module.exports = CcrApi diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index d3017af36..c91317c2e 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -7,76 +7,34 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildClearScroll (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function clearScrollApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, scrollId, scroll_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((scroll_id || scrollId) != null) { + if (method == null) method = 'DELETE' + path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId) + } else { + if (method == null) method = 'DELETE' + path = '/' + '_search' + '/' + 'scroll' } - /** - * Perform a clear_scroll request - * Explicitly clears the search context for a scroll. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-scroll-api.html - */ - return function clearScroll (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, scrollId, scroll_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((scroll_id || scrollId) != null) { - if (method == null) method = 'DELETE' - path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId) - } else { - if (method == null) method = 'DELETE' - path = '/' + '_search' + '/' + 'scroll' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildClearScroll +module.exports = clearScrollApi diff --git a/api/api/close_point_in_time.js b/api/api/close_point_in_time.js new file mode 100644 index 000000000..c66305b11 --- /dev/null +++ b/api/api/close_point_in_time.js @@ -0,0 +1,101 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function closePointInTimeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_pit' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + +<<<<<<< HEAD + /** + * Perform a close_point_in_time request + * Close a point in time + * https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time.html + */ + return function closePointInTime (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 = 'DELETE' + path = '/' + '_pit' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +======= + return this.transport.request(request, options, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) +} + +module.exports = closePointInTimeApi diff --git a/api/api/cluster.js b/api/api/cluster.js new file mode 100644 index 000000000..088a74fea --- /dev/null +++ b/api/api/cluster.js @@ -0,0 +1,420 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['include_yes_decisions', 'include_disk_info', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'timeout', 'master_timeout', 'wait_for_removal', 'local', 'flat_settings', 'include_defaults', 'expand_wildcards', 'level', 'wait_for_active_shards', 'wait_for_nodes', 'wait_for_events', 'wait_for_no_relocating_shards', 'wait_for_no_initializing_shards', 'wait_for_status', 'node_ids', 'node_names', 'create', 'dry_run', 'explain', 'retry_failed', 'metric', 'wait_for_metadata_version', 'wait_for_timeout', 'ignore_unavailable', 'allow_no_indices'] +const snakeCase = { includeYesDecisions: 'include_yes_decisions', includeDiskInfo: 'include_disk_info', errorTrace: 'error_trace', filterPath: 'filter_path', masterTimeout: 'master_timeout', waitForRemoval: 'wait_for_removal', flatSettings: 'flat_settings', includeDefaults: 'include_defaults', expandWildcards: 'expand_wildcards', waitForActiveShards: 'wait_for_active_shards', waitForNodes: 'wait_for_nodes', waitForEvents: 'wait_for_events', waitForNoRelocatingShards: 'wait_for_no_relocating_shards', waitForNoInitializingShards: 'wait_for_no_initializing_shards', waitForStatus: 'wait_for_status', nodeIds: 'node_ids', nodeNames: 'node_names', dryRun: 'dry_run', retryFailed: 'retry_failed', waitForMetadataVersion: 'wait_for_metadata_version', waitForTimeout: 'wait_for_timeout', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices' } + +function ClusterApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +ClusterApi.prototype.allocationExplain = function clusterAllocationExplainApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_cluster' + '/' + 'allocation' + '/' + 'explain' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.deleteComponentTemplate = function clusterDeleteComponentTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_component_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.deleteVotingConfigExclusions = function clusterDeleteVotingConfigExclusionsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_cluster' + '/' + 'voting_config_exclusions' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.existsComponentTemplate = function clusterExistsComponentTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + '_component_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.getComponentTemplate = function clusterGetComponentTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_component_template' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_component_template' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.getSettings = function clusterGetSettingsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'settings' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.health = function clusterHealthApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'health' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.pendingTasks = function clusterPendingTasksApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'pending_tasks' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.postVotingConfigExclusions = function clusterPostVotingConfigExclusionsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_cluster' + '/' + 'voting_config_exclusions' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.putComponentTemplate = function clusterPutComponentTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_component_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.putSettings = function clusterPutSettingsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_cluster' + '/' + 'settings' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.remoteInfo = function clusterRemoteInfoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_remote' + '/' + 'info' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.reroute = function clusterRerouteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_cluster' + '/' + 'reroute' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.state = function clusterStateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required url components + if (params['index'] != null && (params['metric'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: metric') + return handleError(err, callback) + } + + var { method, body, metric, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((metric) != null && (index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index) + } else if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) + } else { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'state' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.stats = function clusterStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(ClusterApi.prototype, { + allocation_explain: { get () { return this.allocationExplain } }, + delete_component_template: { get () { return this.deleteComponentTemplate } }, + delete_voting_config_exclusions: { get () { return this.deleteVotingConfigExclusions } }, + exists_component_template: { get () { return this.existsComponentTemplate } }, + get_component_template: { get () { return this.getComponentTemplate } }, + get_settings: { get () { return this.getSettings } }, + pending_tasks: { get () { return this.pendingTasks } }, + post_voting_config_exclusions: { get () { return this.postVotingConfigExclusions } }, + put_component_template: { get () { return this.putComponentTemplate } }, + put_settings: { get () { return this.putSettings } }, + remote_info: { get () { return this.remoteInfo } } +}) + +module.exports = ClusterApi diff --git a/api/api/count.js b/api/api/count.js index e8e733aa8..dd270f36d 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -7,45 +7,26 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildCount (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'min_score', 'preference', 'routing', 'q', 'analyzer', 'analyze_wildcard', 'default_operator', 'df', 'lenient', 'terminate_after', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', minScore: 'min_score', analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', terminateAfter: 'terminate_after', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'ignore_unavailable', - 'ignore_throttled', - 'allow_no_indices', - 'expand_wildcards', - 'min_score', - 'preference', - 'routing', - 'q', - 'analyzer', - 'analyze_wildcard', - 'default_operator', - 'df', - 'lenient', - 'terminate_after', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function countApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - ignoreThrottled: 'ignore_throttled', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - minScore: 'min_score', - analyzeWildcard: 'analyze_wildcard', - defaultOperator: 'default_operator', - terminateAfter: 'terminate_after', - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_count' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_count' } +<<<<<<< HEAD /** * Perform a count request * Returns number of documents matching a query. @@ -107,7 +88,17 @@ function buildCount (opts) { options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) +======= + // build request object + const request = { + method, + path, + body: body || '', + querystring +>>>>>>> a064f0f3... Improve child performances (#1314) } + + return this.transport.request(request, options, callback) } -module.exports = buildCount +module.exports = countApi diff --git a/api/api/create.js b/api/api/create.js index d9bedb3d9..2eed11754 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -7,101 +7,48 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildCreate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'version', 'version_type', 'pipeline', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'wait_for_active_shards', - 'refresh', - 'routing', - 'timeout', - 'version', - 'version_type', - 'pipeline', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function createApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - waitForActiveShards: 'wait_for_active_shards', - versionType: 'version_type', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a create request - * Creates a new document in the index. + var { method, body, id, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) -Returns a 409 response when a document with a same ID already exists in the index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html - */ - return function create (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['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - 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, id, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null && (id) != null) { - if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create' - } else { - if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id) - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + var path = '' + if ((index) != null && (type) != null && (id) != null) { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create' + } else { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id) } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildCreate +module.exports = createApi diff --git a/api/api/dangling_indices.js b/api/api/dangling_indices.js new file mode 100644 index 000000000..b6475c69b --- /dev/null +++ b/api/api/dangling_indices.js @@ -0,0 +1,115 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['accept_data_loss', 'timeout', 'master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { acceptDataLoss: 'accept_data_loss', masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function DanglingIndicesApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +DanglingIndicesApi.prototype.deleteDanglingIndex = function danglingIndicesDeleteDanglingIndexApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index_uuid'] == null && params['indexUuid'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index_uuid or indexUuid') + return handleError(err, callback) + } + + var { method, body, indexUuid, index_uuid, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_dangling' + '/' + encodeURIComponent(index_uuid || indexUuid) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +DanglingIndicesApi.prototype.importDanglingIndex = function danglingIndicesImportDanglingIndexApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index_uuid'] == null && params['indexUuid'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index_uuid or indexUuid') + return handleError(err, callback) + } + + var { method, body, indexUuid, index_uuid, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_dangling' + '/' + encodeURIComponent(index_uuid || indexUuid) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +DanglingIndicesApi.prototype.listDanglingIndices = function danglingIndicesListDanglingIndicesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_dangling' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(DanglingIndicesApi.prototype, { + delete_dangling_index: { get () { return this.deleteDanglingIndex } }, + import_dangling_index: { get () { return this.importDanglingIndex } }, + list_dangling_indices: { get () { return this.listDanglingIndices } } +}) + +module.exports = DanglingIndicesApi diff --git a/api/api/delete.js b/api/api/delete.js index 146ec5d63..838c6207c 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -7,98 +7,44 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDelete (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'if_seq_no', 'if_primary_term', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'wait_for_active_shards', - 'refresh', - 'routing', - 'timeout', - 'if_seq_no', - 'if_primary_term', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function deleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - waitForActiveShards: 'wait_for_active_shards', - ifSeqNo: 'if_seq_no', - ifPrimaryTerm: 'if_primary_term', - versionType: 'version_type', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) } - /** - * Perform a delete request - * Removes a document from the index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html - */ - return function _delete (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, id, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - 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, id, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null && (id) != null) { - if (method == null) method = 'DELETE' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) - } else { - if (method == null) method = 'DELETE' - path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + var path = '' + if ((index) != null && (type) != null && (id) != null) { + if (method == null) method = 'DELETE' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'DELETE' + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildDelete +module.exports = deleteApi diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 41f23ce59..9cab4cd5a 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -7,10 +7,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDeleteByQuery (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['analyzer', 'analyze_wildcard', 'default_operator', 'df', 'from', 'ignore_unavailable', 'allow_no_indices', 'conflicts', 'expand_wildcards', 'lenient', 'preference', 'q', 'routing', 'scroll', 'search_type', 'search_timeout', 'max_docs', 'sort', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'terminate_after', 'stats', 'version', 'request_cache', 'refresh', 'timeout', 'wait_for_active_shards', 'scroll_size', 'wait_for_completion', 'requests_per_second', 'slices', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', searchTimeout: 'search_timeout', maxDocs: 'max_docs', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', terminateAfter: 'terminate_after', requestCache: 'request_cache', waitForActiveShards: 'wait_for_active_shards', scrollSize: 'scroll_size', waitForCompletion: 'wait_for_completion', requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'analyzer', 'analyze_wildcard', @@ -134,18 +135,37 @@ function buildDeleteByQuery (opts) { if (method == null) method = 'POST' path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query' } +======= +function deleteByQueryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildDeleteByQuery +module.exports = deleteByQueryApi diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index 066823a68..6e2ade9a0 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -7,83 +7,39 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDeleteByQueryRethrottle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['requests_per_second', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'requests_per_second', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function deleteByQueryRethrottleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - requestsPerSecond: 'requests_per_second', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId') + return handleError(err, callback) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) } - /** - * Perform a delete_by_query_rethrottle request - * Changes the number of requests per second for a particular Delete By Query operation. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html - */ - return function deleteByQueryRethrottle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, taskId, task_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['task_id'] == null && params['taskId'] == null) { - const err = new ConfigurationError('Missing required parameter: task_id or taskId') - return handleError(err, callback) - } - if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { - const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'POST' + path = '/' + '_delete_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - // 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, taskId, task_id, ...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 = '/' + '_delete_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildDeleteByQueryRethrottle +module.exports = deleteByQueryRethrottleApi diff --git a/api/api/delete_script.js b/api/api/delete_script.js index edf6ed203..e38f8d7fc 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -7,80 +7,35 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDeleteScript (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['timeout', 'master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function deleteScriptApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } - /** - * Perform a delete_script request - * Deletes a script. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html - */ - return function deleteScript (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_scripts' + '/' + encodeURIComponent(id) - // 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, id, ...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 = '/' + '_scripts' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildDeleteScript +module.exports = deleteScriptApi diff --git a/api/api/enrich.js b/api/api/enrich.js new file mode 100644 index 000000000..780ee943d --- /dev/null +++ b/api/api/enrich.js @@ -0,0 +1,173 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_completion'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', waitForCompletion: 'wait_for_completion' } + +function EnrichApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +EnrichApi.prototype.deletePolicy = function enrichDeletePolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +EnrichApi.prototype.executePolicy = function enrichExecutePolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + '/' + '_execute' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +EnrichApi.prototype.getPolicy = function enrichGetPolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + 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 + } + + return this.transport.request(request, options, callback) +} + +EnrichApi.prototype.putPolicy = function enrichPutPolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +EnrichApi.prototype.stats = function enrichStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_enrich' + '/' + '_stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(EnrichApi.prototype, { + delete_policy: { get () { return this.deletePolicy } }, + execute_policy: { get () { return this.executePolicy } }, + get_policy: { get () { return this.getPolicy } }, + put_policy: { get () { return this.putPolicy } } +}) + +module.exports = EnrichApi diff --git a/api/api/eql.js b/api/api/eql.js new file mode 100644 index 000000000..3813a5aff --- /dev/null +++ b/api/api/eql.js @@ -0,0 +1,119 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_completion_timeout', 'keep_alive', 'keep_on_completion'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', waitForCompletionTimeout: 'wait_for_completion_timeout', keepAlive: 'keep_alive', keepOnCompletion: 'keep_on_completion' } + +function EqlApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +EqlApi.prototype.delete = function eqlDeleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_eql' + '/' + 'search' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +EqlApi.prototype.get = function eqlGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_eql' + '/' + 'search' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +EqlApi.prototype.search = function eqlSearchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_eql' + '/' + 'search' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = EqlApi diff --git a/api/api/exists.js b/api/api/exists.js index c48a5299b..ec39d42d0 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -7,10 +7,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildExists (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'stored_fields', 'preference', @@ -93,18 +94,37 @@ function buildExists (opts) { if (method == null) method = 'HEAD' path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) } +======= +function existsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, id, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildExists +module.exports = existsApi diff --git a/api/api/exists_source.js b/api/api/exists_source.js index fab3f6d85..391c56353 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -7,10 +7,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildExistsSource (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'preference', 'realtime', @@ -38,80 +39,51 @@ function buildExistsSource (opts) { versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +function existsSourceApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } - /** - * Perform a exists_source request - * Returns information about whether a document source exists in an index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html - */ - return function existsSource (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['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: type, index') - return handleError(err, callback) - } else if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - 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, id, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null && (id) != null) { - if (method == null) method = 'HEAD' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source' - } else { - if (method == null) method = 'HEAD' - path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id) - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: type, index') + return handleError(err, callback) + } else if (params['type'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) } + + var { method, body, id, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (type) != null && (id) != null) { + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source' + } else { + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id) + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildExistsSource +module.exports = existsSourceApi diff --git a/api/api/explain.js b/api/api/explain.js index 71aab5acf..831fce1ab 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -7,10 +7,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildExplain (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['analyze_wildcard', 'analyzer', 'default_operator', 'df', 'stored_fields', 'lenient', 'preference', 'q', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'analyze_wildcard', 'analyzer', @@ -96,18 +97,37 @@ function buildExplain (opts) { if (method == null) method = body == null ? 'GET' : 'POST' path = '/' + encodeURIComponent(index) + '/' + '_explain' + '/' + encodeURIComponent(id) } +======= +function explainApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, id, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_explain' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildExplain +module.exports = explainApi diff --git a/api/api/field_caps.js b/api/api/field_caps.js index 94e2f601b..abaa79f3f 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -7,85 +7,34 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildFieldCaps (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['fields', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'include_unmapped', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', includeUnmapped: 'include_unmapped', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'fields', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'include_unmapped', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function fieldCapsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - includeUnmapped: 'include_unmapped', - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_field_caps' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_field_caps' } - /** - * Perform a field_caps request - * Returns the information about the capabilities of fields among multiple indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html - */ - return function fieldCaps (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // 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, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_field_caps' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_field_caps' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildFieldCaps +module.exports = fieldCapsApi diff --git a/api/api/get.js b/api/api/get.js index 87b127cab..9c9d5813d 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -7,10 +7,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildGet (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'stored_fields', 'preference', @@ -93,18 +94,37 @@ function buildGet (opts) { if (method == null) method = 'GET' path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) } +======= +function getApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, id, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildGet +module.exports = getApi diff --git a/api/api/get_script.js b/api/api/get_script.js index 0531b98a2..f8a9aacef 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -7,79 +7,35 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildGetScript (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function getScriptApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } - /** - * Perform a get_script request - * Returns a script. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html - */ - return function getScript (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'GET' + path = '/' + '_scripts' + '/' + encodeURIComponent(id) - // 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, id, ...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 = '/' + '_scripts' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: null, + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildGetScript +module.exports = getScriptApi diff --git a/api/api/get_script_context.js b/api/api/get_script_context.js index 1edc10047..3b712bc18 100644 --- a/api/api/get_script_context.js +++ b/api/api/get_script_context.js @@ -7,71 +7,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildGetScriptContext (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function getScriptContextApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_script_context' + + // build request object + const request = { + method, + path, + body: null, + querystring } - /** - * Perform a get_script_context request - * Returns all script contexts. - * https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html - */ - return function getScriptContext (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 = '/' + '_script_context' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } + return this.transport.request(request, options, callback) } -module.exports = buildGetScriptContext +module.exports = getScriptContextApi diff --git a/api/api/get_script_languages.js b/api/api/get_script_languages.js index 38f70452b..6b2611bf1 100644 --- a/api/api/get_script_languages.js +++ b/api/api/get_script_languages.js @@ -7,71 +7,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildGetScriptLanguages (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function getScriptLanguagesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_script_language' + + // build request object + const request = { + method, + path, + body: null, + querystring } - /** - * Perform a get_script_languages request - * Returns available script types, languages and contexts - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html - */ - return function getScriptLanguages (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 = '/' + '_script_language' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } + return this.transport.request(request, options, callback) } -module.exports = buildGetScriptLanguages +module.exports = getScriptLanguagesApi diff --git a/api/api/get_source.js b/api/api/get_source.js index 70bd3deff..47f6ae210 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -7,10 +7,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildGetSource (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'preference', 'realtime', @@ -91,18 +92,37 @@ function buildGetSource (opts) { if (method == null) method = 'GET' path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id) } +======= +function getSourceApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, id, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildGetSource +module.exports = getSourceApi diff --git a/api/api/graph.js b/api/api/graph.js new file mode 100644 index 000000000..bfbd967cc --- /dev/null +++ b/api/api/graph.js @@ -0,0 +1,61 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['routing', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function GraphApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +GraphApi.prototype.explore = function graphExploreApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_graph' + '/' + 'explore' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = GraphApi diff --git a/api/api/ilm.js b/api/api/ilm.js new file mode 100644 index 000000000..55c138c00 --- /dev/null +++ b/api/api/ilm.js @@ -0,0 +1,295 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'only_managed', 'only_errors'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', onlyManaged: 'only_managed', onlyErrors: 'only_errors' } + +function IlmApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +IlmApi.prototype.deleteLifecycle = function ilmDeleteLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['policy'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: policy') + return handleError(err, callback) + } + + var { method, body, policy, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.explainLifecycle = function ilmExplainLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'explain' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.getLifecycle = function ilmGetLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, policy, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((policy) != null) { + if (method == null) method = 'GET' + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) + } else { + if (method == null) method = 'GET' + path = '/' + '_ilm' + '/' + 'policy' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.getStatus = function ilmGetStatusApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ilm' + '/' + 'status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.moveToStep = function ilmMoveToStepApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.putLifecycle = function ilmPutLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['policy'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: policy') + return handleError(err, callback) + } + + var { method, body, policy, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.removePolicy = function ilmRemovePolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'remove' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.retry = function ilmRetryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'retry' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.start = function ilmStartApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ilm' + '/' + 'start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.stop = function ilmStopApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ilm' + '/' + 'stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(IlmApi.prototype, { + delete_lifecycle: { get () { return this.deleteLifecycle } }, + explain_lifecycle: { get () { return this.explainLifecycle } }, + get_lifecycle: { get () { return this.getLifecycle } }, + get_status: { get () { return this.getStatus } }, + move_to_step: { get () { return this.moveToStep } }, + put_lifecycle: { get () { return this.putLifecycle } }, + remove_policy: { get () { return this.removePolicy } } +}) + +module.exports = IlmApi diff --git a/api/api/index.js b/api/api/index.js index 6136772b9..060c2d5da 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -7,6 +7,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ +<<<<<<< HEAD function buildIndex (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -37,8 +38,26 @@ function buildIndex (opts) { ifPrimaryTerm: 'if_primary_term', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['wait_for_active_shards', 'op_type', 'refresh', 'routing', 'timeout', 'version', 'version_type', 'if_seq_no', 'if_primary_term', 'pipeline', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', opType: 'op_type', versionType: 'version_type', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function indexApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) +>>>>>>> 3db1bed4... Improve child performances (#1314) } +<<<<<<< HEAD /** * Perform a index request * Creates or updates a document in an index. @@ -96,18 +115,29 @@ function buildIndex (opts) { if (method == null) method = 'POST' path = '/' + encodeURIComponent(index) + '/' + '_doc' } +======= + var { method, body, id, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + var path = '' + if ((index) != null && (id) != null) { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_doc' } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildIndex +module.exports = indexApi diff --git a/api/api/indices.js b/api/api/indices.js new file mode 100644 index 000000000..05ba8d352 --- /dev/null +++ b/api/api/indices.js @@ -0,0 +1,1588 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['timeout', 'master_timeout', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'index', 'fielddata', 'fields', 'query', 'request', 'wait_for_active_shards', 'local', 'flat_settings', 'include_defaults', 'force', 'wait_if_ongoing', 'flush', 'max_num_segments', 'only_expunge_deletes', 'create', 'cause', 'write_index_only', 'preserve_existing', 'order', 'detailed', 'active_only', 'dry_run', 'verbose', 'status', 'completion_fields', 'fielddata_fields', 'groups', 'level', 'types', 'include_segment_file_sizes', 'include_unloaded_segments', 'forbid_closed_indices', 'wait_for_completion', 'only_ancient_segments', 'explain', 'q', 'analyzer', 'analyze_wildcard', 'default_operator', 'df', 'lenient', 'rewrite', 'all_shards'] +const snakeCase = { masterTimeout: 'master_timeout', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path', waitForActiveShards: 'wait_for_active_shards', flatSettings: 'flat_settings', includeDefaults: 'include_defaults', waitIfOngoing: 'wait_if_ongoing', maxNumSegments: 'max_num_segments', onlyExpungeDeletes: 'only_expunge_deletes', writeIndexOnly: 'write_index_only', preserveExisting: 'preserve_existing', activeOnly: 'active_only', dryRun: 'dry_run', completionFields: 'completion_fields', fielddataFields: 'fielddata_fields', includeSegmentFileSizes: 'include_segment_file_sizes', includeUnloadedSegments: 'include_unloaded_segments', forbidClosedIndices: 'forbid_closed_indices', waitForCompletion: 'wait_for_completion', onlyAncientSegments: 'only_ancient_segments', analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', allShards: 'all_shards' } + +function IndicesApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +IndicesApi.prototype.addBlock = function indicesAddBlockApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['block'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: block') + return handleError(err, callback) + } + + // check required url components + if (params['block'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, block, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_block' + '/' + encodeURIComponent(block) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.analyze = function indicesAnalyzeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_analyze' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_analyze' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.clearCache = function indicesClearCacheApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_cache' + '/' + 'clear' + } else { + if (method == null) method = 'POST' + path = '/' + '_cache' + '/' + 'clear' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.clone = function indicesCloneApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['target'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: target') + return handleError(err, callback) + } + + // check required url components + if (params['target'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, target, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_clone' + '/' + encodeURIComponent(target) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.close = function indicesCloseApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_close' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.create = function indicesCreateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.delete = function indicesDeleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.deleteAlias = function indicesDeleteAliasApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + // check required url components + if (params['name'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (name) != null) { + if (method == null) method = 'DELETE' + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'DELETE' + path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.deleteIndexTemplate = function indicesDeleteIndexTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_index_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.deleteTemplate = function indicesDeleteTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.exists = function indicesExistsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.existsAlias = function indicesExistsAliasApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (name) != null) { + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'HEAD' + path = '/' + '_alias' + '/' + encodeURIComponent(name) + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.existsIndexTemplate = function indicesExistsIndexTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + '_index_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.existsTemplate = function indicesExistsTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + '_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.existsType = function indicesExistsTypeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['type'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: type') + return handleError(err, callback) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.flush = function indicesFlushApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_flush' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_flush' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.forcemerge = function indicesForcemergeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_forcemerge' + } else { + if (method == null) method = 'POST' + path = '/' + '_forcemerge' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.get = function indicesGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getAlias = function indicesGetAliasApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (name) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) + } else if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_alias' + '/' + encodeURIComponent(name) + } else if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_alias' + } else { + if (method == null) method = 'GET' + path = '/' + '_alias' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getFieldMapping = function indicesGetFieldMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['fields'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: fields') + return handleError(err, callback) + } + + var { method, body, fields, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (fields) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields) + } else { + if (method == null) method = 'GET' + path = '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields) + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getIndexTemplate = function indicesGetIndexTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_index_template' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_index_template' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getMapping = function indicesGetMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + } else { + if (method == null) method = 'GET' + path = '/' + '_mapping' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getSettings = function indicesGetSettingsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (name) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_settings' + '/' + encodeURIComponent(name) + } else if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_settings' + } else if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_settings' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_settings' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getTemplate = function indicesGetTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_template' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_template' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getUpgrade = function indicesGetUpgradeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_upgrade' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.open = function indicesOpenApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_open' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.putAlias = function indicesPutAliasApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + // check required url components + if (params['name'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (name) != null) { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.putIndexTemplate = function indicesPutIndexTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_index_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.putMapping = function indicesPutMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.putSettings = function indicesPutSettingsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_settings' + } else { + if (method == null) method = 'PUT' + path = '/' + '_settings' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.putTemplate = function indicesPutTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.recovery = function indicesRecoveryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_recovery' + } else { + if (method == null) method = 'GET' + path = '/' + '_recovery' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.refresh = function indicesRefreshApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_refresh' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_refresh' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.resolveIndex = function indicesResolveIndexApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_resolve' + '/' + 'index' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.rollover = function indicesRolloverApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['alias'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: alias') + return handleError(err, callback) + } + + // check required url components + if ((params['new_index'] != null || params['newIndex'] != null) && (params['alias'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: alias') + return handleError(err, callback) + } + + var { method, body, alias, newIndex, new_index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((alias) != null && (new_index || newIndex) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(alias) + '/' + '_rollover' + '/' + encodeURIComponent(new_index || newIndex) + } else { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(alias) + '/' + '_rollover' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.segments = function indicesSegmentsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_segments' + } else { + if (method == null) method = 'GET' + path = '/' + '_segments' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.shardStores = function indicesShardStoresApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_shard_stores' + } else { + if (method == null) method = 'GET' + path = '/' + '_shard_stores' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.shrink = function indicesShrinkApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['target'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: target') + return handleError(err, callback) + } + + // check required url components + if (params['target'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, target, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_shrink' + '/' + encodeURIComponent(target) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.simulateIndexTemplate = function indicesSimulateIndexTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_index_template' + '/' + '_simulate_index' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.simulateTemplate = function indicesSimulateTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'POST' + path = '/' + '_index_template' + '/' + '_simulate' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'POST' + path = '/' + '_index_template' + '/' + '_simulate' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.split = function indicesSplitApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['target'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: target') + return handleError(err, callback) + } + + // check required url components + if (params['target'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, target, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_split' + '/' + encodeURIComponent(target) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.stats = function indicesStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, metric, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (metric) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_stats' + '/' + encodeURIComponent(metric) + } else if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_stats' + '/' + encodeURIComponent(metric) + } else if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.updateAliases = function indicesUpdateAliasesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_aliases' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.upgrade = function indicesUpgradeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_upgrade' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.validateQuery = function indicesValidateQueryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (type) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_validate' + '/' + 'query' + } else if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_validate' + '/' + 'query' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_validate' + '/' + 'query' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.createDataStream = function indicesCreateDataStreamApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.dataStreamsStats = function indicesDataStreamsStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_data_stream' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.deleteDataStream = function indicesDeleteDataStreamApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.freeze = function indicesFreezeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_freeze' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getDataStream = function indicesGetDataStreamApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_data_stream' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.reloadSearchAnalyzers = function indicesReloadSearchAnalyzersApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_reload_search_analyzers' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.unfreeze = function indicesUnfreezeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_unfreeze' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(IndicesApi.prototype, { + add_block: { get () { return this.addBlock } }, + clear_cache: { get () { return this.clearCache } }, + delete_alias: { get () { return this.deleteAlias } }, + delete_index_template: { get () { return this.deleteIndexTemplate } }, + delete_template: { get () { return this.deleteTemplate } }, + exists_alias: { get () { return this.existsAlias } }, + exists_index_template: { get () { return this.existsIndexTemplate } }, + exists_template: { get () { return this.existsTemplate } }, + exists_type: { get () { return this.existsType } }, + get_alias: { get () { return this.getAlias } }, + get_field_mapping: { get () { return this.getFieldMapping } }, + get_index_template: { get () { return this.getIndexTemplate } }, + get_mapping: { get () { return this.getMapping } }, + get_settings: { get () { return this.getSettings } }, + get_template: { get () { return this.getTemplate } }, + get_upgrade: { get () { return this.getUpgrade } }, + put_alias: { get () { return this.putAlias } }, + put_index_template: { get () { return this.putIndexTemplate } }, + put_mapping: { get () { return this.putMapping } }, + put_settings: { get () { return this.putSettings } }, + put_template: { get () { return this.putTemplate } }, + resolve_index: { get () { return this.resolveIndex } }, + shard_stores: { get () { return this.shardStores } }, + simulate_index_template: { get () { return this.simulateIndexTemplate } }, + simulate_template: { get () { return this.simulateTemplate } }, + update_aliases: { get () { return this.updateAliases } }, + validate_query: { get () { return this.validateQuery } }, + create_data_stream: { get () { return this.createDataStream } }, + data_streams_stats: { get () { return this.dataStreamsStats } }, + delete_data_stream: { get () { return this.deleteDataStream } }, + get_data_stream: { get () { return this.getDataStream } }, + reload_search_analyzers: { get () { return this.reloadSearchAnalyzers } } +}) + +module.exports = IndicesApi diff --git a/api/api/info.js b/api/api/info.js index b0d0201f2..bd763230c 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -7,71 +7,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildInfo (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function infoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + + // build request object + const request = { + method, + path, + body: null, + querystring } - /** - * Perform a info request - * Returns basic information about the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html - */ - return function info (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 = '/' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } + return this.transport.request(request, options, callback) } -module.exports = buildInfo +module.exports = infoApi diff --git a/api/api/ingest.js b/api/api/ingest.js new file mode 100644 index 000000000..5763190ea --- /dev/null +++ b/api/api/ingest.js @@ -0,0 +1,178 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['master_timeout', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'verbose'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function IngestApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +IngestApi.prototype.deletePipeline = function ingestDeletePipelineApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IngestApi.prototype.getPipeline = function ingestGetPipelineApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'GET' + path = '/' + '_ingest' + '/' + 'pipeline' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IngestApi.prototype.processorGrok = function ingestProcessorGrokApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ingest' + '/' + 'processor' + '/' + 'grok' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IngestApi.prototype.putPipeline = function ingestPutPipelineApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IngestApi.prototype.simulate = function ingestSimulateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + '/' + '_simulate' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + '_simulate' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(IngestApi.prototype, { + delete_pipeline: { get () { return this.deletePipeline } }, + get_pipeline: { get () { return this.getPipeline } }, + processor_grok: { get () { return this.processorGrok } }, + put_pipeline: { get () { return this.putPipeline } } +}) + +module.exports = IngestApi diff --git a/api/api/license.js b/api/api/license.js new file mode 100644 index 000000000..6bc197c6a --- /dev/null +++ b/api/api/license.js @@ -0,0 +1,188 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'local', 'accept_enterprise', 'acknowledge', 'type'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', acceptEnterprise: 'accept_enterprise' } + +function LicenseApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +LicenseApi.prototype.delete = function licenseDeleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_license' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.get = function licenseGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_license' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.getBasicStatus = function licenseGetBasicStatusApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_license' + '/' + 'basic_status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.getTrialStatus = function licenseGetTrialStatusApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_license' + '/' + 'trial_status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.post = function licensePostApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_license' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.postStartBasic = function licensePostStartBasicApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_license' + '/' + 'start_basic' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.postStartTrial = function licensePostStartTrialApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_license' + '/' + 'start_trial' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(LicenseApi.prototype, { + get_basic_status: { get () { return this.getBasicStatus } }, + get_trial_status: { get () { return this.getTrialStatus } }, + post_start_basic: { get () { return this.postStartBasic } }, + post_start_trial: { get () { return this.postStartTrial } } +}) + +module.exports = LicenseApi diff --git a/api/api/mget.js b/api/api/mget.js index fbf6f03f4..05d7a9f5d 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -7,10 +7,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildMget (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'stored_fields', 'preference', @@ -37,25 +38,21 @@ function buildMget (opts) { _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +function mgetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } - /** - * Perform a mget request - * Allows to get multiple documents in one request. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html - */ - return function mget (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +<<<<<<< HEAD // check required parameters if (params['body'] == null) { const err = new ConfigurationError('Missing required parameter: body') @@ -103,10 +100,26 @@ function buildMget (opts) { body: body || '', querystring } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) +======= + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_mget' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_mget' } +>>>>>>> a064f0f3... Improve child performances (#1314) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildMget +module.exports = mgetApi diff --git a/api/api/migration.js b/api/api/migration.js new file mode 100644 index 000000000..f77baf7e5 --- /dev/null +++ b/api/api/migration.js @@ -0,0 +1,60 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function MigrationApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +MigrationApi.prototype.deprecations = function migrationDeprecationsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_migration' + '/' + 'deprecations' + } else { + if (method == null) method = 'GET' + path = '/' + '_migration' + '/' + 'deprecations' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = MigrationApi diff --git a/api/api/ml.js b/api/api/ml.js new file mode 100644 index 000000000..1943cb0a7 --- /dev/null +++ b/api/api/ml.js @@ -0,0 +1,1842 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['allow_no_match', 'allow_no_jobs', 'force', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'requests_per_second', 'allow_no_forecasts', 'wait_for_completion', 'lines_to_sample', 'line_merge_size_limit', 'charset', 'format', 'has_header_row', 'column_names', 'delimiter', 'quote', 'should_trim_fields', 'grok_pattern', 'timestamp_field', 'timestamp_format', 'explain', 'calc_interim', 'start', 'end', 'advance_time', 'skip_time', 'duration', 'expires_in', 'max_model_memory', 'expand', 'exclude_interim', 'from', 'size', 'anomaly_score', 'sort', 'desc', 'job_id', 'partition_field_value', 'verbose', 'allow_no_datafeeds', 'influencer_score', 'top_n', 'bucket_span', 'overall_score', 'record_score', 'include', 'decompress_definition', 'tags', 'for_export', 'reset_start', 'reset_end', 'ignore_unavailable', 'allow_no_indices', 'ignore_throttled', 'expand_wildcards', 'delete_intervening_results', 'enabled'] +const snakeCase = { allowNoMatch: 'allow_no_match', allowNoJobs: 'allow_no_jobs', errorTrace: 'error_trace', filterPath: 'filter_path', requestsPerSecond: 'requests_per_second', allowNoForecasts: 'allow_no_forecasts', waitForCompletion: 'wait_for_completion', linesToSample: 'lines_to_sample', lineMergeSizeLimit: 'line_merge_size_limit', hasHeaderRow: 'has_header_row', columnNames: 'column_names', shouldTrimFields: 'should_trim_fields', grokPattern: 'grok_pattern', timestampField: 'timestamp_field', timestampFormat: 'timestamp_format', calcInterim: 'calc_interim', advanceTime: 'advance_time', skipTime: 'skip_time', expiresIn: 'expires_in', maxModelMemory: 'max_model_memory', excludeInterim: 'exclude_interim', anomalyScore: 'anomaly_score', jobId: 'job_id', partitionFieldValue: 'partition_field_value', allowNoDatafeeds: 'allow_no_datafeeds', influencerScore: 'influencer_score', topN: 'top_n', bucketSpan: 'bucket_span', overallScore: 'overall_score', recordScore: 'record_score', decompressDefinition: 'decompress_definition', forExport: 'for_export', resetStart: 'reset_start', resetEnd: 'reset_end', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', ignoreThrottled: 'ignore_throttled', expandWildcards: 'expand_wildcards', deleteInterveningResults: 'delete_intervening_results' } + +function MlApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +MlApi.prototype.closeJob = function mlCloseJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_close' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteCalendar = function mlDeleteCalendarApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteCalendarEvent = function mlDeleteCalendarEventApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['event_id'] == null && params['eventId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: event_id or eventId') + return handleError(err, callback) + } + + // check required url components + if ((params['event_id'] != null || params['eventId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: calendar_id') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, eventId, event_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + '/' + encodeURIComponent(event_id || eventId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteCalendarJob = function mlDeleteCalendarJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: calendar_id') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'jobs' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteDataFrameAnalytics = function mlDeleteDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteDatafeed = function mlDeleteDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteExpiredData = function mlDeleteExpiredDataApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null) { + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + '_delete_expired_data' + '/' + encodeURIComponent(job_id || jobId) + } else { + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + '_delete_expired_data' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteFilter = function mlDeleteFilterApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: filter_id or filterId') + return handleError(err, callback) + } + + var { method, body, filterId, filter_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteForecast = function mlDeleteForecastApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['forecast_id'] != null || params['forecastId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, forecastId, forecast_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null && (forecast_id || forecastId) != null) { + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + '/' + encodeURIComponent(forecast_id || forecastId) + } else { + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteJob = function mlDeleteJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteModelSnapshot = function mlDeleteModelSnapshotApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteTrainedModel = function mlDeleteTrainedModelApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['model_id'] == null && params['modelId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: model_id or modelId') + return handleError(err, callback) + } + + var { method, body, modelId, model_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.estimateModelMemory = function mlEstimateModelMemoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_estimate_model_memory' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.evaluateDataFrame = function mlEvaluateDataFrameApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + '_evaluate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.explainDataFrameAnalytics = function mlExplainDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_explain' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + '_explain' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.findFileStructure = function mlFindFileStructureApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'find_file_structure' + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.flushJob = function mlFlushJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_flush' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.forecast = function mlForecastApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getBuckets = function mlGetBucketsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if (params['timestamp'] != null && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, timestamp, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null && (timestamp) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'buckets' + '/' + encodeURIComponent(timestamp) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'buckets' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getCalendarEvents = function mlGetCalendarEventsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getCalendars = function mlGetCalendarsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, calendarId, calendar_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((calendar_id || calendarId) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'calendars' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getCategories = function mlGetCategoriesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['category_id'] != null || params['categoryId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, categoryId, category_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null && (category_id || categoryId) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'categories' + '/' + encodeURIComponent(category_id || categoryId) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'categories' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getDataFrameAnalytics = function mlGetDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getDataFrameAnalyticsStats = function mlGetDataFrameAnalyticsStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getDatafeedStats = function mlGetDatafeedStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((datafeed_id || datafeedId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getDatafeeds = function mlGetDatafeedsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((datafeed_id || datafeedId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'datafeeds' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getFilters = function mlGetFiltersApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, filterId, filter_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((filter_id || filterId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'filters' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getInfluencers = function mlGetInfluencersApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'influencers' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getJobStats = function mlGetJobStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getJobs = function mlGetJobsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getModelSnapshots = function mlGetModelSnapshotsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null && (snapshot_id || snapshotId) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getOverallBuckets = function mlGetOverallBucketsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'overall_buckets' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getRecords = function mlGetRecordsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'records' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getTrainedModels = function mlGetTrainedModelsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, modelId, model_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((model_id || modelId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'inference' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getTrainedModelsStats = function mlGetTrainedModelsStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, modelId, model_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((model_id || modelId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'inference' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.info = function mlInfoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'info' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.openJob = function mlOpenJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_open' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.postCalendarEvents = function mlPostCalendarEventsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.postData = function mlPostDataApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_data' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.previewDatafeed = function mlPreviewDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_preview' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putCalendar = function mlPutCalendarApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putCalendarJob = function mlPutCalendarJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: calendar_id') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'jobs' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putDataFrameAnalytics = function mlPutDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putDatafeed = function mlPutDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putFilter = function mlPutFilterApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: filter_id or filterId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, filterId, filter_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putJob = function mlPutJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putTrainedModel = function mlPutTrainedModelApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['model_id'] == null && params['modelId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: model_id or modelId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, modelId, model_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.revertModelSnapshot = function mlRevertModelSnapshotApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + '/' + '_revert' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.setUpgradeMode = function mlSetUpgradeModeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'set_upgrade_mode' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.startDataFrameAnalytics = function mlStartDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.startDatafeed = function mlStartDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.stopDataFrameAnalytics = function mlStopDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.stopDatafeed = function mlStopDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.updateDataFrameAnalytics = function mlUpdateDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.updateDatafeed = function mlUpdateDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.updateFilter = function mlUpdateFilterApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: filter_id or filterId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, filterId, filter_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.updateJob = function mlUpdateJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.updateModelSnapshot = function mlUpdateModelSnapshotApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.validate = function mlValidateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.validateDetector = function mlValidateDetectorApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + '/' + 'detector' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(MlApi.prototype, { + close_job: { get () { return this.closeJob } }, + delete_calendar: { get () { return this.deleteCalendar } }, + delete_calendar_event: { get () { return this.deleteCalendarEvent } }, + delete_calendar_job: { get () { return this.deleteCalendarJob } }, + delete_data_frame_analytics: { get () { return this.deleteDataFrameAnalytics } }, + delete_datafeed: { get () { return this.deleteDatafeed } }, + delete_expired_data: { get () { return this.deleteExpiredData } }, + delete_filter: { get () { return this.deleteFilter } }, + delete_forecast: { get () { return this.deleteForecast } }, + delete_job: { get () { return this.deleteJob } }, + delete_model_snapshot: { get () { return this.deleteModelSnapshot } }, + delete_trained_model: { get () { return this.deleteTrainedModel } }, + estimate_model_memory: { get () { return this.estimateModelMemory } }, + evaluate_data_frame: { get () { return this.evaluateDataFrame } }, + explain_data_frame_analytics: { get () { return this.explainDataFrameAnalytics } }, + find_file_structure: { get () { return this.findFileStructure } }, + flush_job: { get () { return this.flushJob } }, + get_buckets: { get () { return this.getBuckets } }, + get_calendar_events: { get () { return this.getCalendarEvents } }, + get_calendars: { get () { return this.getCalendars } }, + get_categories: { get () { return this.getCategories } }, + get_data_frame_analytics: { get () { return this.getDataFrameAnalytics } }, + get_data_frame_analytics_stats: { get () { return this.getDataFrameAnalyticsStats } }, + get_datafeed_stats: { get () { return this.getDatafeedStats } }, + get_datafeeds: { get () { return this.getDatafeeds } }, + get_filters: { get () { return this.getFilters } }, + get_influencers: { get () { return this.getInfluencers } }, + get_job_stats: { get () { return this.getJobStats } }, + get_jobs: { get () { return this.getJobs } }, + get_model_snapshots: { get () { return this.getModelSnapshots } }, + get_overall_buckets: { get () { return this.getOverallBuckets } }, + get_records: { get () { return this.getRecords } }, + get_trained_models: { get () { return this.getTrainedModels } }, + get_trained_models_stats: { get () { return this.getTrainedModelsStats } }, + open_job: { get () { return this.openJob } }, + post_calendar_events: { get () { return this.postCalendarEvents } }, + post_data: { get () { return this.postData } }, + preview_datafeed: { get () { return this.previewDatafeed } }, + put_calendar: { get () { return this.putCalendar } }, + put_calendar_job: { get () { return this.putCalendarJob } }, + put_data_frame_analytics: { get () { return this.putDataFrameAnalytics } }, + put_datafeed: { get () { return this.putDatafeed } }, + put_filter: { get () { return this.putFilter } }, + put_job: { get () { return this.putJob } }, + put_trained_model: { get () { return this.putTrainedModel } }, + revert_model_snapshot: { get () { return this.revertModelSnapshot } }, + set_upgrade_mode: { get () { return this.setUpgradeMode } }, + start_data_frame_analytics: { get () { return this.startDataFrameAnalytics } }, + start_datafeed: { get () { return this.startDatafeed } }, + stop_data_frame_analytics: { get () { return this.stopDataFrameAnalytics } }, + stop_datafeed: { get () { return this.stopDatafeed } }, + update_data_frame_analytics: { get () { return this.updateDataFrameAnalytics } }, + update_datafeed: { get () { return this.updateDatafeed } }, + update_filter: { get () { return this.updateFilter } }, + update_job: { get () { return this.updateJob } }, + update_model_snapshot: { get () { return this.updateModelSnapshot } }, + validate_detector: { get () { return this.validateDetector } } +}) + +module.exports = MlApi diff --git a/api/api/monitoring.js b/api/api/monitoring.js new file mode 100644 index 000000000..db24d5d4e --- /dev/null +++ b/api/api/monitoring.js @@ -0,0 +1,66 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['system_id', 'system_api_version', 'interval', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { systemId: 'system_id', systemApiVersion: 'system_api_version', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function MonitoringApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +MonitoringApi.prototype.bulk = function monitoringBulkApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((type) != null) { + if (method == null) method = 'POST' + path = '/' + '_monitoring' + '/' + encodeURIComponent(type) + '/' + 'bulk' + } else { + if (method == null) method = 'POST' + path = '/' + '_monitoring' + '/' + 'bulk' + } + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = MonitoringApi diff --git a/api/api/msearch.js b/api/api/msearch.js index db80ef03b..0edbdc645 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -7,54 +7,23 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildMsearch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['search_type', 'max_concurrent_searches', 'typed_keys', 'pre_filter_shard_size', 'max_concurrent_shard_requests', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { searchType: 'search_type', maxConcurrentSearches: 'max_concurrent_searches', typedKeys: 'typed_keys', preFilterShardSize: 'pre_filter_shard_size', maxConcurrentShardRequests: 'max_concurrent_shard_requests', restTotalHitsAsInt: 'rest_total_hits_as_int', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'search_type', - 'max_concurrent_searches', - 'typed_keys', - 'pre_filter_shard_size', - 'max_concurrent_shard_requests', - 'rest_total_hits_as_int', - 'ccs_minimize_roundtrips', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function msearchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - searchType: 'search_type', - maxConcurrentSearches: 'max_concurrent_searches', - typedKeys: 'typed_keys', - preFilterShardSize: 'pre_filter_shard_size', - maxConcurrentShardRequests: 'max_concurrent_shard_requests', - restTotalHitsAsInt: 'rest_total_hits_as_int', - ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a msearch request - * Allows to execute several search operations in one request. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html - */ - return function msearch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +<<<<<<< HEAD // check required parameters if (params['body'] == null) { const err = new ConfigurationError('Missing required parameter: body') @@ -102,10 +71,26 @@ function buildMsearch (opts) { bulkBody: body, querystring } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) +======= + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_msearch' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_msearch' } +>>>>>>> a064f0f3... Improve child performances (#1314) + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildMsearch +module.exports = msearchApi diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 5bad34db8..478aa6d30 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -7,50 +7,23 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildMsearchTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['search_type', 'typed_keys', 'max_concurrent_searches', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { searchType: 'search_type', typedKeys: 'typed_keys', maxConcurrentSearches: 'max_concurrent_searches', restTotalHitsAsInt: 'rest_total_hits_as_int', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'search_type', - 'typed_keys', - 'max_concurrent_searches', - 'rest_total_hits_as_int', - 'ccs_minimize_roundtrips', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function msearchTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - searchType: 'search_type', - typedKeys: 'typed_keys', - maxConcurrentSearches: 'max_concurrent_searches', - restTotalHitsAsInt: 'rest_total_hits_as_int', - ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a msearch_template request - * Allows to execute several search template operations in one request. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html - */ - return function msearchTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +<<<<<<< HEAD // check required parameters if (params['body'] == null) { const err = new ConfigurationError('Missing required parameter: body') @@ -98,10 +71,26 @@ function buildMsearchTemplate (opts) { bulkBody: body, querystring } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) +======= + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_msearch' + '/' + 'template' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_msearch' + '/' + 'template' } +>>>>>>> a064f0f3... Improve child performances (#1314) + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildMsearchTemplate +module.exports = msearchTemplateApi diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index c11e0537f..e7cc1cbf5 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -7,38 +7,26 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildMtermvectors (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['ids', 'term_statistics', 'field_statistics', 'fields', 'offsets', 'positions', 'payloads', 'preference', 'routing', 'realtime', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { termStatistics: 'term_statistics', fieldStatistics: 'field_statistics', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'ids', - 'term_statistics', - 'field_statistics', - 'fields', - 'offsets', - 'positions', - 'payloads', - 'preference', - 'routing', - 'realtime', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function mtermvectorsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - termStatistics: 'term_statistics', - fieldStatistics: 'field_statistics', - versionType: 'version_type', - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_mtermvectors' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_mtermvectors' } +<<<<<<< HEAD /** * Perform a mtermvectors request * Returns multiple termvectors in one request. @@ -100,7 +88,17 @@ function buildMtermvectors (opts) { options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) +======= + // build request object + const request = { + method, + path, + body: body || '', + querystring +>>>>>>> a064f0f3... Improve child performances (#1314) } + + return this.transport.request(request, options, callback) } -module.exports = buildMtermvectors +module.exports = mtermvectorsApi diff --git a/api/api/nodes.js b/api/api/nodes.js new file mode 100644 index 000000000..4fb496114 --- /dev/null +++ b/api/api/nodes.js @@ -0,0 +1,193 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['interval', 'snapshots', 'threads', 'ignore_idle_threads', 'type', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'flat_settings', 'completion_fields', 'fielddata_fields', 'fields', 'groups', 'level', 'types', 'include_segment_file_sizes'] +const snakeCase = { ignoreIdleThreads: 'ignore_idle_threads', errorTrace: 'error_trace', filterPath: 'filter_path', flatSettings: 'flat_settings', completionFields: 'completion_fields', fielddataFields: 'fielddata_fields', includeSegmentFileSizes: 'include_segment_file_sizes' } + +function NodesApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +NodesApi.prototype.hotThreads = function nodesHotThreadsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads' + } else { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'hot_threads' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +NodesApi.prototype.info = function nodesInfoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, metric, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null && (metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + encodeURIComponent(metric) + } else if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + } else if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(metric) + } else { + if (method == null) method = 'GET' + path = '/' + '_nodes' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +NodesApi.prototype.reloadSecureSettings = function nodesReloadSecureSettingsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null) { + if (method == null) method = 'POST' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'reload_secure_settings' + } else { + if (method == null) method = 'POST' + path = '/' + '_nodes' + '/' + 'reload_secure_settings' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +NodesApi.prototype.stats = function nodesStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, metric, indexMetric, index_metric, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null && (metric) != null && (index_metric || indexMetric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index_metric || indexMetric) + } else if ((node_id || nodeId) != null && (metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + '/' + encodeURIComponent(metric) + } else if ((metric) != null && (index_metric || indexMetric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index_metric || indexMetric) + } else if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + } else if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(metric) + } else { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +NodesApi.prototype.usage = function nodesUsageApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, metric, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null && (metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'usage' + '/' + encodeURIComponent(metric) + } else if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'usage' + } else if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'usage' + '/' + encodeURIComponent(metric) + } else { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'usage' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(NodesApi.prototype, { + hot_threads: { get () { return this.hotThreads } }, + reload_secure_settings: { get () { return this.reloadSecureSettings } } +}) + +module.exports = NodesApi diff --git a/api/api/open_point_in_time.js b/api/api/open_point_in_time.js new file mode 100644 index 000000000..b45581834 --- /dev/null +++ b/api/api/open_point_in_time.js @@ -0,0 +1,110 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['preference', 'routing', 'ignore_unavailable', 'expand_wildcards', 'keep_alive', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', expandWildcards: 'expand_wildcards', keepAlive: 'keep_alive', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function openPointInTimeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_pit' + } else { + if (method == null) method = 'POST' + path = '/' + '_pit' + } + +<<<<<<< HEAD + /** + * Perform a open_point_in_time request + * Open a point in time that can be used in subsequent searches + * https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time.html + */ + return function openPointInTime (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, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_pit' + } else { + if (method == null) method = 'POST' + path = '/' + '_pit' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) +======= + // build request object + const request = { + method, + path, + body: body || '', + querystring +>>>>>>> a064f0f3... Improve child performances (#1314) + } + + return this.transport.request(request, options, callback) +} + +module.exports = openPointInTimeApi diff --git a/api/api/ping.js b/api/api/ping.js index f37fa4103..a919cc39a 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -7,71 +7,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildPing (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function pingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + + // build request object + const request = { + method, + path, + body: null, + querystring } - /** - * Perform a ping request - * Returns whether the cluster is running. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html - */ - return function ping (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 = 'HEAD' - path = '/' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } + return this.transport.request(request, options, callback) } -module.exports = buildPing +module.exports = pingApi diff --git a/api/api/put_script.js b/api/api/put_script.js index 160114e11..e3d83d8a4 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -7,96 +7,50 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildPutScript (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['timeout', 'master_timeout', 'context', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'context', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function putScriptApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a put_script request - * Creates or updates a script. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html - */ - return function putScript (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['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // check required url components - if (params['context'] != null && (params['id'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: id') - 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, id, context, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null && (context) != null) { - if (method == null) method = 'PUT' - path = '/' + '_scripts' + '/' + encodeURIComponent(id) + '/' + encodeURIComponent(context) - } else { - if (method == null) method = 'PUT' - path = '/' + '_scripts' + '/' + encodeURIComponent(id) - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required url components + if (params['context'] != null && (params['id'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: id') + return handleError(err, callback) } + + var { method, body, id, context, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null && (context) != null) { + if (method == null) method = 'PUT' + path = '/' + '_scripts' + '/' + encodeURIComponent(id) + '/' + encodeURIComponent(context) + } else { + if (method == null) method = 'PUT' + path = '/' + '_scripts' + '/' + encodeURIComponent(id) + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildPutScript +module.exports = putScriptApi diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index 2debba204..bd38540c8 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -7,90 +7,40 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildRankEval (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'search_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'search_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function rankEvalApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - searchType: 'search_type', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a rank_eval request - * Allows to evaluate the quality of ranked search results over a set of typical search queries - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html - */ - return function rankEval (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - 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, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_rank_eval' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_rank_eval' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_rank_eval' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_rank_eval' } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildRankEval +module.exports = rankEvalApi diff --git a/api/api/reindex.js b/api/api/reindex.js index 5712b2c56..66403b4f0 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -7,91 +7,35 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildReindex (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['refresh', 'timeout', 'wait_for_active_shards', 'wait_for_completion', 'requests_per_second', 'scroll', 'slices', 'max_docs', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', waitForCompletion: 'wait_for_completion', requestsPerSecond: 'requests_per_second', maxDocs: 'max_docs', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'refresh', - 'timeout', - 'wait_for_active_shards', - 'wait_for_completion', - 'requests_per_second', - 'scroll', - 'slices', - 'max_docs', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function reindexApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - waitForActiveShards: 'wait_for_active_shards', - waitForCompletion: 'wait_for_completion', - requestsPerSecond: 'requests_per_second', - maxDocs: 'max_docs', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a reindex request - * Allows to copy documents from one index to another, optionally filtering the source -documents by a query, changing the destination index settings, or fetching the -documents from a remote cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html - */ - return function reindex (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'POST' + path = '/' + '_reindex' - // 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 = '/' + '_reindex' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildReindex +module.exports = reindexApi diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 37fd8a031..496602d17 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -7,83 +7,39 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildReindexRethrottle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['requests_per_second', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'requests_per_second', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function reindexRethrottleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - requestsPerSecond: 'requests_per_second', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId') + return handleError(err, callback) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) } - /** - * Perform a reindex_rethrottle request - * Changes the number of requests per second for a particular Reindex operation. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html - */ - return function reindexRethrottle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, taskId, task_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['task_id'] == null && params['taskId'] == null) { - const err = new ConfigurationError('Missing required parameter: task_id or taskId') - return handleError(err, callback) - } - if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { - const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'POST' + path = '/' + '_reindex' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - // 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, taskId, task_id, ...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 = '/' + '_reindex' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildReindexRethrottle +module.exports = reindexRethrottleApi diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index 3cdefa7cc..f3ffce673 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -7,76 +7,34 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildRenderSearchTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function renderSearchTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_render' + '/' + 'template' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_render' + '/' + 'template' } - /** - * Perform a render_search_template request - * Allows to use the Mustache language to pre-render a search definition. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#_validating_templates - */ - return function renderSearchTemplate (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, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_render' + '/' + 'template' + '/' + encodeURIComponent(id) - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_render' + '/' + 'template' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildRenderSearchTemplate +module.exports = renderSearchTemplateApi diff --git a/api/api/rollup.js b/api/api/rollup.js new file mode 100644 index 000000000..fc4a2793b --- /dev/null +++ b/api/api/rollup.js @@ -0,0 +1,278 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'typed_keys', 'rest_total_hits_as_int', 'wait_for_completion', 'timeout'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', typedKeys: 'typed_keys', restTotalHitsAsInt: 'rest_total_hits_as_int', waitForCompletion: 'wait_for_completion' } + +function RollupApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +RollupApi.prototype.deleteJob = function rollupDeleteJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.getJobs = function rollupGetJobsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'GET' + path = '/' + '_rollup' + '/' + 'job' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.getRollupCaps = function rollupGetRollupCapsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_rollup' + '/' + 'data' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'GET' + path = '/' + '_rollup' + '/' + 'data' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.getRollupIndexCaps = function rollupGetRollupIndexCapsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_rollup' + '/' + 'data' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.putJob = function rollupPutJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.rollupSearch = function rollupRollupSearchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (type) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_rollup_search' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_rollup_search' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.startJob = function rollupStartJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.stopJob = function rollupStopJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(RollupApi.prototype, { + delete_job: { get () { return this.deleteJob } }, + get_jobs: { get () { return this.getJobs } }, + get_rollup_caps: { get () { return this.getRollupCaps } }, + get_rollup_index_caps: { get () { return this.getRollupIndexCaps } }, + put_job: { get () { return this.putJob } }, + rollup_search: { get () { return this.rollupSearch } }, + start_job: { get () { return this.startJob } }, + stop_job: { get () { return this.stopJob } } +}) + +module.exports = RollupApi diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index 1bb435492..64fb67234 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -7,71 +7,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildScriptsPainlessExecute (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function scriptsPainlessExecuteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_scripts' + '/' + 'painless' + '/' + '_execute' + + // build request object + const request = { + method, + path, + body: body || '', + querystring } - /** - * Perform a scripts_painless_execute request - * Allows an arbitrary script to be executed and a result to be returned - * https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html - */ - return function scriptsPainlessExecute (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 = body == null ? 'GET' : 'POST' - path = '/' + '_scripts' + '/' + 'painless' + '/' + '_execute' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } + return this.transport.request(request, options, callback) } -module.exports = buildScriptsPainlessExecute +module.exports = scriptsPainlessExecuteApi diff --git a/api/api/scroll.js b/api/api/scroll.js index 47c10e30e..148857e25 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -7,81 +7,34 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildScroll (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['scroll', 'scroll_id', 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { scrollId: 'scroll_id', restTotalHitsAsInt: 'rest_total_hits_as_int', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'scroll', - 'scroll_id', - 'rest_total_hits_as_int', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function scrollApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - scrollId: 'scroll_id', - restTotalHitsAsInt: 'rest_total_hits_as_int', - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, scrollId, scroll_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((scroll_id || scrollId) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_search' + '/' + 'scroll' } - /** - * Perform a scroll request - * Allows to retrieve a large numbers of results from a single search request. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll - */ - return function scroll (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, scrollId, scroll_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((scroll_id || scrollId) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId) - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_search' + '/' + 'scroll' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildScroll +module.exports = scrollApi diff --git a/api/api/search.js b/api/api/search.js index 8e058048f..75d8d1c30 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -7,6 +7,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ +<<<<<<< HEAD function buildSearch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -158,7 +159,36 @@ function buildSearch (opts) { options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) +======= +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['analyzer', 'analyze_wildcard', 'ccs_minimize_roundtrips', 'default_operator', 'df', 'explain', 'stored_fields', 'docvalue_fields', 'from', 'ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'lenient', 'preference', 'q', 'routing', 'scroll', 'search_type', 'size', 'sort', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'terminate_after', 'stats', 'suggest_field', 'suggest_mode', 'suggest_size', 'suggest_text', 'timeout', 'track_scores', 'track_total_hits', 'allow_partial_search_results', 'typed_keys', 'version', 'seq_no_primary_term', 'request_cache', 'batched_reduce_size', 'max_concurrent_shard_requests', 'pre_filter_shard_size', 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { analyzeWildcard: 'analyze_wildcard', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', defaultOperator: 'default_operator', storedFields: 'stored_fields', docvalueFields: 'docvalue_fields', ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', terminateAfter: 'terminate_after', suggestField: 'suggest_field', suggestMode: 'suggest_mode', suggestSize: 'suggest_size', suggestText: 'suggest_text', trackScores: 'track_scores', trackTotalHits: 'track_total_hits', allowPartialSearchResults: 'allow_partial_search_results', typedKeys: 'typed_keys', seqNoPrimaryTerm: 'seq_no_primary_term', requestCache: 'request_cache', batchedReduceSize: 'batched_reduce_size', maxConcurrentShardRequests: 'max_concurrent_shard_requests', preFilterShardSize: 'pre_filter_shard_size', restTotalHitsAsInt: 'rest_total_hits_as_int', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function searchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_search' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_search' } + + // build request object + const request = { + method, + path, + body: body || '', + querystring +>>>>>>> a064f0f3... Improve child performances (#1314) + } + + return this.transport.request(request, options, callback) } -module.exports = buildSearch +module.exports = searchApi diff --git a/api/api/search_shards.js b/api/api/search_shards.js index 227ec04ba..11f34be63 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -7,85 +7,34 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildSearchShards (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['preference', 'routing', 'local', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'preference', - 'routing', - 'local', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function searchShardsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_search_shards' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_search_shards' } - /** - * Perform a search_shards request - * Returns information about the indices and shards that a search request would be executed against. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html - */ - return function searchShards (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, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_search_shards' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_search_shards' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildSearchShards +module.exports = searchShardsApi diff --git a/api/api/search_template.js b/api/api/search_template.js index 73298e7a4..4fd14f8df 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -7,61 +7,23 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildSearchTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'preference', 'routing', 'scroll', 'search_type', 'explain', 'profile', 'typed_keys', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', typedKeys: 'typed_keys', restTotalHitsAsInt: 'rest_total_hits_as_int', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'ignore_unavailable', - 'ignore_throttled', - 'allow_no_indices', - 'expand_wildcards', - 'preference', - 'routing', - 'scroll', - 'search_type', - 'explain', - 'profile', - 'typed_keys', - 'rest_total_hits_as_int', - 'ccs_minimize_roundtrips', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function searchTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - ignoreThrottled: 'ignore_throttled', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - searchType: 'search_type', - typedKeys: 'typed_keys', - restTotalHitsAsInt: 'rest_total_hits_as_int', - ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a search_template request - * Allows to use the Mustache language to pre-render a search definition. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html - */ - return function searchTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +<<<<<<< HEAD // check required parameters if (params['body'] == null) { const err = new ConfigurationError('Missing required parameter: body') @@ -109,10 +71,26 @@ function buildSearchTemplate (opts) { body: body || '', querystring } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) +======= + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_search' + '/' + 'template' } +>>>>>>> a064f0f3... Improve child performances (#1314) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildSearchTemplate +module.exports = searchTemplateApi diff --git a/api/api/searchable_snapshots.js b/api/api/searchable_snapshots.js new file mode 100644 index 000000000..38f857cac --- /dev/null +++ b/api/api/searchable_snapshots.js @@ -0,0 +1,159 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'index', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'master_timeout', 'wait_for_completion'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path', masterTimeout: 'master_timeout', waitForCompletion: 'wait_for_completion' } + +function SearchableSnapshotsApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SearchableSnapshotsApi.prototype.clearCache = function searchableSnapshotsClearCacheApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_searchable_snapshots' + '/' + 'cache' + '/' + 'clear' + } else { + if (method == null) method = 'POST' + path = '/' + '_searchable_snapshots' + '/' + 'cache' + '/' + 'clear' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SearchableSnapshotsApi.prototype.mount = function searchableSnapshotsMountApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_mount' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SearchableSnapshotsApi.prototype.repositoryStats = function searchableSnapshotsRepositoryStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SearchableSnapshotsApi.prototype.stats = function searchableSnapshotsStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_searchable_snapshots' + '/' + 'stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_searchable_snapshots' + '/' + 'stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(SearchableSnapshotsApi.prototype, { + clear_cache: { get () { return this.clearCache } }, + repository_stats: { get () { return this.repositoryStats } } +}) + +module.exports = SearchableSnapshotsApi diff --git a/api/api/security.js b/api/api/security.js new file mode 100644 index 000000000..f63a42c5c --- /dev/null +++ b/api/api/security.js @@ -0,0 +1,805 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'refresh', 'usernames', 'id', 'name', 'username', 'realm_name', 'owner'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', realmName: 'realm_name' } + +function SecurityApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SecurityApi.prototype.authenticate = function securityAuthenticateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + '_authenticate' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.changePassword = function securityChangePasswordApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((username) != null) { + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_password' + } else { + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'user' + '/' + '_password' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.clearCachedPrivileges = function securityClearCachedPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['application'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: application') + return handleError(err, callback) + } + + var { method, body, application, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + '_clear_cache' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.clearCachedRealms = function securityClearCachedRealmsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['realms'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: realms') + return handleError(err, callback) + } + + var { method, body, realms, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_security' + '/' + 'realm' + '/' + encodeURIComponent(realms) + '/' + '_clear_cache' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.clearCachedRoles = function securityClearCachedRolesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + '/' + '_clear_cache' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.createApiKey = function securityCreateApiKeyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.deletePrivileges = function securityDeletePrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['application'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: application') + return handleError(err, callback) + } + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + // check required url components + if (params['name'] != null && (params['application'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: application') + return handleError(err, callback) + } + + var { method, body, application, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.deleteRole = function securityDeleteRoleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.deleteRoleMapping = function securityDeleteRoleMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.deleteUser = function securityDeleteUserApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['username'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: username') + return handleError(err, callback) + } + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.disableUser = function securityDisableUserApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['username'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: username') + return handleError(err, callback) + } + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_disable' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.enableUser = function securityEnableUserApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['username'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: username') + return handleError(err, callback) + } + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_enable' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getApiKey = function securityGetApiKeyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getBuiltinPrivileges = function securityGetBuiltinPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'privilege' + '/' + '_builtin' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getPrivileges = function securityGetPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required url components + if (params['name'] != null && (params['application'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: application') + return handleError(err, callback) + } + + var { method, body, application, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((application) != null && (name) != null) { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) + } else if ((application) != null) { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + } else { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'privilege' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getRole = function securityGetRoleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'role' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getRoleMapping = function securityGetRoleMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'role_mapping' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getToken = function securityGetTokenApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getUser = function securityGetUserApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((username) != null) { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + } else { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'user' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getUserPrivileges = function securityGetUserPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'user' + '/' + '_privileges' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.hasPrivileges = function securityHasPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, user, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((user) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(user) + '/' + '_has_privileges' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_security' + '/' + 'user' + '/' + '_has_privileges' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.invalidateApiKey = function securityInvalidateApiKeyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.invalidateToken = function securityInvalidateTokenApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.putPrivileges = function securityPutPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'privilege' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.putRole = function securityPutRoleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.putRoleMapping = function securityPutRoleMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.putUser = function securityPutUserApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['username'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: username') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(SecurityApi.prototype, { + change_password: { get () { return this.changePassword } }, + clear_cached_privileges: { get () { return this.clearCachedPrivileges } }, + clear_cached_realms: { get () { return this.clearCachedRealms } }, + clear_cached_roles: { get () { return this.clearCachedRoles } }, + create_api_key: { get () { return this.createApiKey } }, + delete_privileges: { get () { return this.deletePrivileges } }, + delete_role: { get () { return this.deleteRole } }, + delete_role_mapping: { get () { return this.deleteRoleMapping } }, + delete_user: { get () { return this.deleteUser } }, + disable_user: { get () { return this.disableUser } }, + enable_user: { get () { return this.enableUser } }, + get_api_key: { get () { return this.getApiKey } }, + get_builtin_privileges: { get () { return this.getBuiltinPrivileges } }, + get_privileges: { get () { return this.getPrivileges } }, + get_role: { get () { return this.getRole } }, + get_role_mapping: { get () { return this.getRoleMapping } }, + get_token: { get () { return this.getToken } }, + get_user: { get () { return this.getUser } }, + get_user_privileges: { get () { return this.getUserPrivileges } }, + has_privileges: { get () { return this.hasPrivileges } }, + invalidate_api_key: { get () { return this.invalidateApiKey } }, + invalidate_token: { get () { return this.invalidateToken } }, + put_privileges: { get () { return this.putPrivileges } }, + put_role: { get () { return this.putRole } }, + put_role_mapping: { get () { return this.putRoleMapping } }, + put_user: { get () { return this.putUser } } +}) + +module.exports = SecurityApi diff --git a/api/api/slm.js b/api/api/slm.js new file mode 100644 index 000000000..3947dc365 --- /dev/null +++ b/api/api/slm.js @@ -0,0 +1,256 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function SlmApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SlmApi.prototype.deleteLifecycle = function slmDeleteLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['policy_id'] == null && params['policyId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: policy_id or policyId') + return handleError(err, callback) + } + + var { method, body, policyId, policy_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.executeLifecycle = function slmExecuteLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['policy_id'] == null && params['policyId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: policy_id or policyId') + return handleError(err, callback) + } + + var { method, body, policyId, policy_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) + '/' + '_execute' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.executeRetention = function slmExecuteRetentionApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_slm' + '/' + '_execute_retention' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.getLifecycle = function slmGetLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, policyId, policy_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((policy_id || policyId) != null) { + if (method == null) method = 'GET' + path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) + } else { + if (method == null) method = 'GET' + path = '/' + '_slm' + '/' + 'policy' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.getStats = function slmGetStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_slm' + '/' + 'stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.getStatus = function slmGetStatusApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_slm' + '/' + 'status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.putLifecycle = function slmPutLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['policy_id'] == null && params['policyId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: policy_id or policyId') + return handleError(err, callback) + } + + var { method, body, policyId, policy_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.start = function slmStartApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_slm' + '/' + 'start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.stop = function slmStopApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_slm' + '/' + 'stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(SlmApi.prototype, { + delete_lifecycle: { get () { return this.deleteLifecycle } }, + execute_lifecycle: { get () { return this.executeLifecycle } }, + execute_retention: { get () { return this.executeRetention } }, + get_lifecycle: { get () { return this.getLifecycle } }, + get_stats: { get () { return this.getStats } }, + get_status: { get () { return this.getStatus } }, + put_lifecycle: { get () { return this.putLifecycle } } +}) + +module.exports = SlmApi diff --git a/api/api/snapshot.js b/api/api/snapshot.js new file mode 100644 index 000000000..377fd016b --- /dev/null +++ b/api/api/snapshot.js @@ -0,0 +1,363 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['master_timeout', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_completion', 'verify', 'ignore_unavailable', 'verbose', 'local'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path', waitForCompletion: 'wait_for_completion', ignoreUnavailable: 'ignore_unavailable' } + +function SnapshotApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SnapshotApi.prototype.cleanupRepository = function snapshotCleanupRepositoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_cleanup' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.create = function snapshotCreateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot') + return handleError(err, callback) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.createRepository = function snapshotCreateRepositoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.delete = function snapshotDeleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot') + return handleError(err, callback) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.deleteRepository = function snapshotDeleteRepositoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.get = function snapshotGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot') + return handleError(err, callback) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.getRepository = function snapshotGetRepositoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((repository) != null) { + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + } else { + if (method == null) method = 'GET' + path = '/' + '_snapshot' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.restore = function snapshotRestoreApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot') + return handleError(err, callback) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_restore' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.status = function snapshotStatusApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((repository) != null && (snapshot) != null) { + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_status' + } else if ((repository) != null) { + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_status' + } else { + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + '_status' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.verifyRepository = function snapshotVerifyRepositoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_verify' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(SnapshotApi.prototype, { + cleanup_repository: { get () { return this.cleanupRepository } }, + create_repository: { get () { return this.createRepository } }, + delete_repository: { get () { return this.deleteRepository } }, + get_repository: { get () { return this.getRepository } }, + verify_repository: { get () { return this.verifyRepository } } +}) + +module.exports = SnapshotApi diff --git a/api/api/sql.js b/api/api/sql.js new file mode 100644 index 000000000..db4c2d08f --- /dev/null +++ b/api/api/sql.js @@ -0,0 +1,119 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'format'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function SqlApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SqlApi.prototype.clearCursor = function sqlClearCursorApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_sql' + '/' + 'close' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SqlApi.prototype.query = function sqlQueryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_sql' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SqlApi.prototype.translate = function sqlTranslateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_sql' + '/' + 'translate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(SqlApi.prototype, { + clear_cursor: { get () { return this.clearCursor } } +}) + +module.exports = SqlApi diff --git a/api/api/ssl.js b/api/api/ssl.js new file mode 100644 index 000000000..76f02913e --- /dev/null +++ b/api/api/ssl.js @@ -0,0 +1,55 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function SslApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SslApi.prototype.certificates = function sslCertificatesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ssl' + '/' + 'certificates' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = SslApi diff --git a/api/api/tasks.js b/api/api/tasks.js new file mode 100644 index 000000000..576c36110 --- /dev/null +++ b/api/api/tasks.js @@ -0,0 +1,108 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['nodes', 'actions', 'parent_task_id', 'wait_for_completion', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'timeout', 'detailed', 'group_by'] +const snakeCase = { parentTaskId: 'parent_task_id', waitForCompletion: 'wait_for_completion', errorTrace: 'error_trace', filterPath: 'filter_path', groupBy: 'group_by' } + +function TasksApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +TasksApi.prototype.cancel = function tasksCancelApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, taskId, task_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((task_id || taskId) != null) { + if (method == null) method = 'POST' + path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_cancel' + } else { + if (method == null) method = 'POST' + path = '/' + '_tasks' + '/' + '_cancel' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TasksApi.prototype.get = function tasksGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId') + return handleError(err, callback) + } + + var { method, body, taskId, task_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +TasksApi.prototype.list = function tasksListApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_tasks' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = TasksApi diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 4e3c0886c..126e5203a 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -7,54 +7,23 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildTermvectors (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['term_statistics', 'field_statistics', 'fields', 'offsets', 'positions', 'payloads', 'preference', 'routing', 'realtime', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { termStatistics: 'term_statistics', fieldStatistics: 'field_statistics', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'term_statistics', - 'field_statistics', - 'fields', - 'offsets', - 'positions', - 'payloads', - 'preference', - 'routing', - 'realtime', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function termvectorsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - termStatistics: 'term_statistics', - fieldStatistics: 'field_statistics', - versionType: 'version_type', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) } - /** - * Perform a termvectors request - * Returns information and statistics about terms in the fields of a particular document. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html - */ - return function termvectors (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +<<<<<<< HEAD // check required parameters if (params['index'] == null) { const err = new ConfigurationError('Missing required parameter: index') @@ -99,10 +68,26 @@ function buildTermvectors (opts) { body: body || '', querystring } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) +======= + var path = '' + if ((index) != null && (id) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_termvectors' } +>>>>>>> a064f0f3... Improve child performances (#1314) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildTermvectors +module.exports = termvectorsApi diff --git a/api/api/transform.js b/api/api/transform.js new file mode 100644 index 000000000..e52130b2e --- /dev/null +++ b/api/api/transform.js @@ -0,0 +1,268 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['force', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'from', 'size', 'allow_no_match', 'defer_validation', 'timeout', 'wait_for_completion', 'wait_for_checkpoint'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', allowNoMatch: 'allow_no_match', deferValidation: 'defer_validation', waitForCompletion: 'wait_for_completion', waitForCheckpoint: 'wait_for_checkpoint' } + +function TransformApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +TransformApi.prototype.deleteTransform = function transformDeleteTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.getTransform = function transformGetTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((transform_id || transformId) != null) { + if (method == null) method = 'GET' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + } else { + if (method == null) method = 'GET' + path = '/' + '_transform' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.getTransformStats = function transformGetTransformStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.previewTransform = function transformPreviewTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_transform' + '/' + '_preview' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.putTransform = function transformPutTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.startTransform = function transformStartTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.stopTransform = function transformStopTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.updateTransform = function transformUpdateTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(TransformApi.prototype, { + delete_transform: { get () { return this.deleteTransform } }, + get_transform: { get () { return this.getTransform } }, + get_transform_stats: { get () { return this.getTransformStats } }, + preview_transform: { get () { return this.previewTransform } }, + put_transform: { get () { return this.putTransform } }, + start_transform: { get () { return this.startTransform } }, + stop_transform: { get () { return this.stopTransform } }, + update_transform: { get () { return this.updateTransform } } +}) + +module.exports = TransformApi diff --git a/api/api/update.js b/api/api/update.js index bd5744bba..dd04a5107 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -7,10 +7,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildUpdate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['wait_for_active_shards', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'lang', 'refresh', 'retry_on_conflict', 'routing', 'timeout', 'if_seq_no', 'if_primary_term', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', retryOnConflict: 'retry_on_conflict', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'wait_for_active_shards', '_source', @@ -43,75 +44,46 @@ function buildUpdate (opts) { ifPrimaryTerm: 'if_primary_term', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +function updateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } - /** - * Perform a update request - * Updates a document with a script or partial document. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html - */ - return function update (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, id, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - 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, id, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null && (id) != null) { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_update' - } else { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id) - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + var path = '' + if ((index) != null && (type) != null && (id) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_update' + } else { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id) } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildUpdate +module.exports = updateApi diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 682e44ddd..357894334 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -7,10 +7,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildUpdateByQuery (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['analyzer', 'analyze_wildcard', 'default_operator', 'df', 'from', 'ignore_unavailable', 'allow_no_indices', 'conflicts', 'expand_wildcards', 'lenient', 'pipeline', 'preference', 'q', 'routing', 'scroll', 'search_type', 'search_timeout', 'max_docs', 'sort', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'terminate_after', 'stats', 'version', 'version_type', 'request_cache', 'refresh', 'timeout', 'wait_for_active_shards', 'scroll_size', 'wait_for_completion', 'requests_per_second', 'slices', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', searchTimeout: 'search_timeout', maxDocs: 'max_docs', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', terminateAfter: 'terminate_after', versionType: 'version_type', requestCache: 'request_cache', waitForActiveShards: 'wait_for_active_shards', scrollSize: 'scroll_size', waitForCompletion: 'wait_for_completion', requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'analyzer', 'analyze_wildcard', @@ -78,32 +79,25 @@ function buildUpdateByQuery (opts) { requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +function updateByQueryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } - /** - * Perform a update_by_query request - * Performs an update on every document in the index without changing the source, -for example to pick up a mapping change. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html - */ - return function updateByQuery (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_update_by_query' +<<<<<<< HEAD // check required url components if (params['type'] != null && (params['index'] == null)) { const err = new ConfigurationError('Missing required parameter of the url: index') @@ -145,7 +139,17 @@ for example to pick up a mapping change. options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) +======= + // build request object + const request = { + method, + path, + body: body || '', + querystring +>>>>>>> a064f0f3... Improve child performances (#1314) } + + return this.transport.request(request, options, callback) } -module.exports = buildUpdateByQuery +module.exports = updateByQueryApi diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index d34a0fc2a..0d2e0a44b 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -7,83 +7,39 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildUpdateByQueryRethrottle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['requests_per_second', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'requests_per_second', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function updateByQueryRethrottleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - requestsPerSecond: 'requests_per_second', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId') + return handleError(err, callback) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) } - /** - * Perform a update_by_query_rethrottle request - * Changes the number of requests per second for a particular Update By Query operation. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html - */ - return function updateByQueryRethrottle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, taskId, task_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['task_id'] == null && params['taskId'] == null) { - const err = new ConfigurationError('Missing required parameter: task_id or taskId') - return handleError(err, callback) - } - if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { - const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'POST' + path = '/' + '_update_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - // 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, taskId, task_id, ...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 = '/' + '_update_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildUpdateByQueryRethrottle +module.exports = updateByQueryRethrottleApi diff --git a/api/api/watcher.js b/api/api/watcher.js new file mode 100644 index 000000000..ba1236e00 --- /dev/null +++ b/api/api/watcher.js @@ -0,0 +1,311 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'debug', 'active', 'version', 'if_seq_no', 'if_primary_term', 'metric', 'emit_stacktraces'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', emitStacktraces: 'emit_stacktraces' } + +function WatcherApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +WatcherApi.prototype.ackWatch = function watcherAckWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: watch_id or watchId') + return handleError(err, callback) + } + + // check required url components + if ((params['action_id'] != null || params['actionId'] != null) && ((params['watch_id'] == null && params['watchId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: watch_id') + return handleError(err, callback) + } + + var { method, body, watchId, watch_id, actionId, action_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((watch_id || watchId) != null && (action_id || actionId) != null) { + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_ack' + '/' + encodeURIComponent(action_id || actionId) + } else { + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_ack' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.activateWatch = function watcherActivateWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: watch_id or watchId') + return handleError(err, callback) + } + + var { method, body, watchId, watch_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_activate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.deactivateWatch = function watcherDeactivateWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: watch_id or watchId') + return handleError(err, callback) + } + + var { method, body, watchId, watch_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_deactivate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.deleteWatch = function watcherDeleteWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.executeWatch = function watcherExecuteWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + '/' + '_execute' + } else { + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + '_execute' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.getWatch = function watcherGetWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.putWatch = function watcherPutWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.start = function watcherStartApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_watcher' + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.stats = function watcherStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, metric, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_watcher' + '/' + 'stats' + '/' + encodeURIComponent(metric) + } else { + if (method == null) method = 'GET' + path = '/' + '_watcher' + '/' + 'stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.stop = function watcherStopApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_watcher' + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(WatcherApi.prototype, { + ack_watch: { get () { return this.ackWatch } }, + activate_watch: { get () { return this.activateWatch } }, + deactivate_watch: { get () { return this.deactivateWatch } }, + delete_watch: { get () { return this.deleteWatch } }, + execute_watch: { get () { return this.executeWatch } }, + get_watch: { get () { return this.getWatch } }, + put_watch: { get () { return this.putWatch } } +}) + +module.exports = WatcherApi diff --git a/api/api/xpack.js b/api/api/xpack.js new file mode 100644 index 000000000..47c619fa7 --- /dev/null +++ b/api/api/xpack.js @@ -0,0 +1,76 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['categories', 'accept_enterprise', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'master_timeout'] +const snakeCase = { acceptEnterprise: 'accept_enterprise', errorTrace: 'error_trace', filterPath: 'filter_path', masterTimeout: 'master_timeout' } + +function XpackApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +XpackApi.prototype.info = function xpackInfoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_xpack' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +XpackApi.prototype.usage = function xpackUsageApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_xpack' + '/' + 'usage' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = XpackApi diff --git a/api/index.js b/api/index.js index bf88079ff..013bc26cd 100644 --- a/api/index.js +++ b/api/index.js @@ -4,17 +4,179 @@ 'use strict' -const assert = require('assert') +const bulkApi = require('./api/bulk') +const CatApi = require('./api/cat') +const clearScrollApi = require('./api/clear_scroll') +const ClusterApi = require('./api/cluster') +const countApi = require('./api/count') +const createApi = require('./api/create') +const DanglingIndicesApi = require('./api/dangling_indices') +const deleteApi = require('./api/delete') +const deleteByQueryApi = require('./api/delete_by_query') +const deleteByQueryRethrottleApi = require('./api/delete_by_query_rethrottle') +const deleteScriptApi = require('./api/delete_script') +const existsApi = require('./api/exists') +const existsSourceApi = require('./api/exists_source') +const explainApi = require('./api/explain') +const fieldCapsApi = require('./api/field_caps') +const getApi = require('./api/get') +const getScriptApi = require('./api/get_script') +const getScriptContextApi = require('./api/get_script_context') +const getScriptLanguagesApi = require('./api/get_script_languages') +const getSourceApi = require('./api/get_source') +const indexApi = require('./api/index') +const IndicesApi = require('./api/indices') +const infoApi = require('./api/info') +const IngestApi = require('./api/ingest') +const mgetApi = require('./api/mget') +const msearchApi = require('./api/msearch') +const msearchTemplateApi = require('./api/msearch_template') +const mtermvectorsApi = require('./api/mtermvectors') +const NodesApi = require('./api/nodes') +const pingApi = require('./api/ping') +const putScriptApi = require('./api/put_script') +const rankEvalApi = require('./api/rank_eval') +const reindexApi = require('./api/reindex') +const reindexRethrottleApi = require('./api/reindex_rethrottle') +const renderSearchTemplateApi = require('./api/render_search_template') +const scriptsPainlessExecuteApi = require('./api/scripts_painless_execute') +const scrollApi = require('./api/scroll') +const searchApi = require('./api/search') +const searchShardsApi = require('./api/search_shards') +const searchTemplateApi = require('./api/search_template') +const SnapshotApi = require('./api/snapshot') +const TasksApi = require('./api/tasks') +const termvectorsApi = require('./api/termvectors') +const updateApi = require('./api/update') +const updateByQueryApi = require('./api/update_by_query') +const updateByQueryRethrottleApi = require('./api/update_by_query_rethrottle') +const AsyncSearchApi = require('./api/async_search') +const AutoscalingApi = require('./api/autoscaling') +const CcrApi = require('./api/ccr') +const closePointInTimeApi = require('./api/close_point_in_time') +const EnrichApi = require('./api/enrich') +const EqlApi = require('./api/eql') +const GraphApi = require('./api/graph') +const IlmApi = require('./api/ilm') +const LicenseApi = require('./api/license') +const MigrationApi = require('./api/migration') +const MlApi = require('./api/ml') +const MonitoringApi = require('./api/monitoring') +const openPointInTimeApi = require('./api/open_point_in_time') +const RollupApi = require('./api/rollup') +const SearchableSnapshotsApi = require('./api/searchable_snapshots') +const SecurityApi = require('./api/security') +const SlmApi = require('./api/slm') +const SqlApi = require('./api/sql') +const SslApi = require('./api/ssl') +const TransformApi = require('./api/transform') +const WatcherApi = require('./api/watcher') +const XpackApi = require('./api/xpack') + +const { kConfigurationError } = require('./utils') +const kCat = Symbol('Cat') +const kCluster = Symbol('Cluster') +const kDanglingIndices = Symbol('DanglingIndices') +const kIndices = Symbol('Indices') +const kIngest = Symbol('Ingest') +const kNodes = Symbol('Nodes') +const kSnapshot = Symbol('Snapshot') +const kTasks = Symbol('Tasks') +const kAsyncSearch = Symbol('AsyncSearch') +const kAutoscaling = Symbol('Autoscaling') +const kCcr = Symbol('Ccr') +const kEnrich = Symbol('Enrich') +const kEql = Symbol('Eql') +const kGraph = Symbol('Graph') +const kIlm = Symbol('Ilm') +const kLicense = Symbol('License') +const kMigration = Symbol('Migration') +const kMl = Symbol('Ml') +const kMonitoring = Symbol('Monitoring') +const kRollup = Symbol('Rollup') +const kSearchableSnapshots = Symbol('SearchableSnapshots') +const kSecurity = Symbol('Security') +const kSlm = Symbol('Slm') +const kSql = Symbol('Sql') +const kSsl = Symbol('Ssl') +const kTransform = Symbol('Transform') +const kWatcher = Symbol('Watcher') +const kXpack = Symbol('Xpack') function ESAPI (opts) { - assert(opts.makeRequest, 'Missing makeRequest function') - assert(opts.ConfigurationError, 'Missing ConfigurationError class') - assert(opts.result, 'Missing default result object') + this[kConfigurationError] = opts.ConfigurationError + this[kCat] = null + this[kCluster] = null + this[kDanglingIndices] = null + this[kIndices] = null + this[kIngest] = null + this[kNodes] = null + this[kSnapshot] = null + this[kTasks] = null + this[kAsyncSearch] = null + this[kAutoscaling] = null + this[kCcr] = null + this[kEnrich] = null + this[kEql] = null + this[kGraph] = null + this[kIlm] = null + this[kLicense] = null + this[kMigration] = null + this[kMl] = null + this[kMonitoring] = null + this[kRollup] = null + this[kSearchableSnapshots] = null + this[kSecurity] = null + this[kSlm] = null + this[kSql] = null + this[kSsl] = null + this[kTransform] = null + this[kWatcher] = null + this[kXpack] = null +} - const { result } = opts - opts.handleError = handleError - opts.snakeCaseKeys = snakeCaseKeys +ESAPI.prototype.bulk = bulkApi +ESAPI.prototype.clearScroll = clearScrollApi +ESAPI.prototype.count = countApi +ESAPI.prototype.create = createApi +ESAPI.prototype.delete = deleteApi +ESAPI.prototype.deleteByQuery = deleteByQueryApi +ESAPI.prototype.deleteByQueryRethrottle = deleteByQueryRethrottleApi +ESAPI.prototype.deleteScript = deleteScriptApi +ESAPI.prototype.exists = existsApi +ESAPI.prototype.existsSource = existsSourceApi +ESAPI.prototype.explain = explainApi +ESAPI.prototype.fieldCaps = fieldCapsApi +ESAPI.prototype.get = getApi +ESAPI.prototype.getScript = getScriptApi +ESAPI.prototype.getScriptContext = getScriptContextApi +ESAPI.prototype.getScriptLanguages = getScriptLanguagesApi +ESAPI.prototype.getSource = getSourceApi +ESAPI.prototype.index = indexApi +ESAPI.prototype.info = infoApi +ESAPI.prototype.mget = mgetApi +ESAPI.prototype.msearch = msearchApi +ESAPI.prototype.msearchTemplate = msearchTemplateApi +ESAPI.prototype.mtermvectors = mtermvectorsApi +ESAPI.prototype.ping = pingApi +ESAPI.prototype.putScript = putScriptApi +ESAPI.prototype.rankEval = rankEvalApi +ESAPI.prototype.reindex = reindexApi +ESAPI.prototype.reindexRethrottle = reindexRethrottleApi +ESAPI.prototype.renderSearchTemplate = renderSearchTemplateApi +ESAPI.prototype.scriptsPainlessExecute = scriptsPainlessExecuteApi +ESAPI.prototype.scroll = scrollApi +ESAPI.prototype.search = searchApi +ESAPI.prototype.searchShards = searchShardsApi +ESAPI.prototype.searchTemplate = searchTemplateApi +ESAPI.prototype.termvectors = termvectorsApi +ESAPI.prototype.update = updateApi +ESAPI.prototype.updateByQuery = updateByQueryApi +ESAPI.prototype.updateByQueryRethrottle = updateByQueryRethrottleApi +ESAPI.prototype.closePointInTime = closePointInTimeApi +ESAPI.prototype.openPointInTime = openPointInTimeApi +<<<<<<< HEAD const apis = { async_search: { delete: lazyLoad('async_search.delete', opts), @@ -658,50 +820,258 @@ function ESAPI (opts) { xpack: { info: lazyLoad('xpack.info', opts), usage: lazyLoad('xpack.usage', opts) - } - } - - return apis - - function handleError (err, callback) { - if (callback) { - process.nextTick(callback, err, result) - return { then: noop, catch: noop, abort: noop } - } - return Promise.reject(err) - } - - function snakeCaseKeys (acceptedQuerystring, snakeCase, querystring, warnings) { - var target = {} - var keys = Object.keys(querystring) - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - target[snakeCase[key] || key] = querystring[key] - if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { - warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') +======= +Object.defineProperties(ESAPI.prototype, { + cat: { + get () { + if (this[kCat] === null) { + this[kCat] = new CatApi(this.transport, this[kConfigurationError]) } + return this[kCat] +>>>>>>> a064f0f3... Improve child performances (#1314) } - return target - } -} - -// It's unlikely that a user needs all of our APIs, -// and since require is a sync operation that takes time -// (given the amount of APIs we have), let's lazy load them, -// so a given API file will be required only -// if the user actually needs that API. -// The following implementation takes advantage -// of js closures to have a simple cache with the least overhead. -function lazyLoad (file, opts) { - var fn = null - return function _lazyLoad (params, options, callback) { - if (fn === null) { - fn = require(`./api/${file}.js`)(opts) + }, + clear_scroll: { get () { return this.clearScroll } }, + cluster: { + get () { + if (this[kCluster] === null) { + this[kCluster] = new ClusterApi(this.transport, this[kConfigurationError]) + } + return this[kCluster] + } + }, + danglingIndices: { + get () { + if (this[kDanglingIndices] === null) { + this[kDanglingIndices] = new DanglingIndicesApi(this.transport, this[kConfigurationError]) + } + return this[kDanglingIndices] + } + }, + dangling_indices: { get () { return this.danglingIndices } }, + delete_by_query: { get () { return this.deleteByQuery } }, + delete_by_query_rethrottle: { get () { return this.deleteByQueryRethrottle } }, + delete_script: { get () { return this.deleteScript } }, + exists_source: { get () { return this.existsSource } }, + field_caps: { get () { return this.fieldCaps } }, + get_script: { get () { return this.getScript } }, + get_script_context: { get () { return this.getScriptContext } }, + get_script_languages: { get () { return this.getScriptLanguages } }, + get_source: { get () { return this.getSource } }, + indices: { + get () { + if (this[kIndices] === null) { + this[kIndices] = new IndicesApi(this.transport, this[kConfigurationError]) + } + return this[kIndices] + } + }, + ingest: { + get () { + if (this[kIngest] === null) { + this[kIngest] = new IngestApi(this.transport, this[kConfigurationError]) + } + return this[kIngest] + } + }, + msearch_template: { get () { return this.msearchTemplate } }, + nodes: { + get () { + if (this[kNodes] === null) { + this[kNodes] = new NodesApi(this.transport, this[kConfigurationError]) + } + return this[kNodes] + } + }, + put_script: { get () { return this.putScript } }, + rank_eval: { get () { return this.rankEval } }, + reindex_rethrottle: { get () { return this.reindexRethrottle } }, + render_search_template: { get () { return this.renderSearchTemplate } }, + scripts_painless_execute: { get () { return this.scriptsPainlessExecute } }, + search_shards: { get () { return this.searchShards } }, + search_template: { get () { return this.searchTemplate } }, + snapshot: { + get () { + if (this[kSnapshot] === null) { + this[kSnapshot] = new SnapshotApi(this.transport, this[kConfigurationError]) + } + return this[kSnapshot] + } + }, + tasks: { + get () { + if (this[kTasks] === null) { + this[kTasks] = new TasksApi(this.transport, this[kConfigurationError]) + } + return this[kTasks] + } + }, + update_by_query: { get () { return this.updateByQuery } }, + update_by_query_rethrottle: { get () { return this.updateByQueryRethrottle } }, + asyncSearch: { + get () { + if (this[kAsyncSearch] === null) { + this[kAsyncSearch] = new AsyncSearchApi(this.transport, this[kConfigurationError]) + } + return this[kAsyncSearch] + } + }, + async_search: { get () { return this.asyncSearch } }, + autoscaling: { + get () { + if (this[kAutoscaling] === null) { + this[kAutoscaling] = new AutoscalingApi(this.transport, this[kConfigurationError]) + } + return this[kAutoscaling] + } + }, + ccr: { + get () { + if (this[kCcr] === null) { + this[kCcr] = new CcrApi(this.transport, this[kConfigurationError]) + } + return this[kCcr] + } + }, + close_point_in_time: { get () { return this.closePointInTime } }, + enrich: { + get () { + if (this[kEnrich] === null) { + this[kEnrich] = new EnrichApi(this.transport, this[kConfigurationError]) + } + return this[kEnrich] + } + }, + eql: { + get () { + if (this[kEql] === null) { + this[kEql] = new EqlApi(this.transport, this[kConfigurationError]) + } + return this[kEql] + } + }, + graph: { + get () { + if (this[kGraph] === null) { + this[kGraph] = new GraphApi(this.transport, this[kConfigurationError]) + } + return this[kGraph] + } + }, + ilm: { + get () { + if (this[kIlm] === null) { + this[kIlm] = new IlmApi(this.transport, this[kConfigurationError]) + } + return this[kIlm] + } + }, + license: { + get () { + if (this[kLicense] === null) { + this[kLicense] = new LicenseApi(this.transport, this[kConfigurationError]) + } + return this[kLicense] + } + }, + migration: { + get () { + if (this[kMigration] === null) { + this[kMigration] = new MigrationApi(this.transport, this[kConfigurationError]) + } + return this[kMigration] + } + }, + ml: { + get () { + if (this[kMl] === null) { + this[kMl] = new MlApi(this.transport, this[kConfigurationError]) + } + return this[kMl] + } + }, + monitoring: { + get () { + if (this[kMonitoring] === null) { + this[kMonitoring] = new MonitoringApi(this.transport, this[kConfigurationError]) + } + return this[kMonitoring] + } + }, + open_point_in_time: { get () { return this.openPointInTime } }, + rollup: { + get () { + if (this[kRollup] === null) { + this[kRollup] = new RollupApi(this.transport, this[kConfigurationError]) + } + return this[kRollup] + } + }, + searchableSnapshots: { + get () { + if (this[kSearchableSnapshots] === null) { + this[kSearchableSnapshots] = new SearchableSnapshotsApi(this.transport, this[kConfigurationError]) + } + return this[kSearchableSnapshots] + } + }, + searchable_snapshots: { get () { return this.searchableSnapshots } }, + security: { + get () { + if (this[kSecurity] === null) { + this[kSecurity] = new SecurityApi(this.transport, this[kConfigurationError]) + } + return this[kSecurity] + } + }, + slm: { + get () { + if (this[kSlm] === null) { + this[kSlm] = new SlmApi(this.transport, this[kConfigurationError]) + } + return this[kSlm] + } + }, + sql: { + get () { + if (this[kSql] === null) { + this[kSql] = new SqlApi(this.transport, this[kConfigurationError]) + } + return this[kSql] + } + }, + ssl: { + get () { + if (this[kSsl] === null) { + this[kSsl] = new SslApi(this.transport, this[kConfigurationError]) + } + return this[kSsl] + } + }, + transform: { + get () { + if (this[kTransform] === null) { + this[kTransform] = new TransformApi(this.transport, this[kConfigurationError]) + } + return this[kTransform] + } + }, + watcher: { + get () { + if (this[kWatcher] === null) { + this[kWatcher] = new WatcherApi(this.transport, this[kConfigurationError]) + } + return this[kWatcher] + } + }, + xpack: { + get () { + if (this[kXpack] === null) { + this[kXpack] = new XpackApi(this.transport, this[kConfigurationError]) + } + return this[kXpack] } - return fn(params, options, callback) } -} - -function noop () {} +}) module.exports = ESAPI diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 8a1b4cb11..7d38f7843 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -13,6 +13,81 @@ export interface Generic { source?: string; } +export interface AsyncSearchDelete extends Generic { + id: string; +} + +export interface AsyncSearchGet extends Generic { + id: string; + wait_for_completion_timeout?: string; + keep_alive?: string; + typed_keys?: boolean; +} + +export interface AsyncSearchSubmit extends Generic { + index?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + wait_for_completion_timeout?: string; + keep_on_completion?: boolean; + keep_alive?: string; + batched_reduce_size?: number; + request_cache?: boolean; + analyzer?: string; + analyze_wildcard?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + explain?: boolean; + stored_fields?: string | string[]; + docvalue_fields?: string | string[]; + from?: number; + ignore_unavailable?: boolean; + ignore_throttled?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + lenient?: boolean; + preference?: string; + q?: string; + routing?: string | string[]; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + size?: number; + sort?: string | string[]; + _source?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; + terminate_after?: number; + stats?: string | string[]; + suggest_field?: string; + suggest_mode?: 'missing' | 'popular' | 'always'; + suggest_size?: number; + suggest_text?: string; + timeout?: string; + track_scores?: boolean; + track_total_hits?: boolean | number; + allow_partial_search_results?: boolean; + typed_keys?: boolean; + version?: boolean; + seq_no_primary_term?: boolean; + max_concurrent_shard_requests?: number; + body?: T; +} + +export interface AutoscalingDeleteAutoscalingPolicy extends Generic { + name: string; +} + +export interface AutoscalingGetAutoscalingDecision extends Generic { +} + +export interface AutoscalingGetAutoscalingPolicy extends Generic { + name: string; +} + +export interface AutoscalingPutAutoscalingPolicy extends Generic { + name: string; + body: T; +} + export interface Bulk extends Generic { index?: string; type?: string; @@ -113,6 +188,57 @@ export interface CatMaster extends Generic { v?: boolean; } +export interface CatMlDataFrameAnalytics extends Generic { + id?: string; + allow_no_match?: boolean; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos'; + v?: boolean; +} + +export interface CatMlDatafeeds extends Generic { + datafeed_id?: string; + allow_no_match?: boolean; + allow_no_datafeeds?: boolean; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos'; + v?: boolean; +} + +export interface CatMlJobs extends Generic { + job_id?: string; + allow_no_match?: boolean; + allow_no_jobs?: boolean; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos'; + v?: boolean; +} + +export interface CatMlTrainedModels extends Generic { + model_id?: string; + allow_no_match?: boolean; + from?: number; + size?: number; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos'; + v?: boolean; +} + export interface CatNodeattrs extends Generic { format?: string; local?: boolean; @@ -251,11 +377,84 @@ export interface CatThreadPool extends Generic { v?: boolean; } +export interface CatTransforms extends Generic { + transform_id?: string; + from?: number; + size?: number; + allow_no_match?: boolean; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos'; + v?: boolean; +} + +export interface CcrDeleteAutoFollowPattern extends Generic { + name: string; +} + +export interface CcrFollow extends Generic { + index: string; + wait_for_active_shards?: string; + body: T; +} + +export interface CcrFollowInfo extends Generic { + index: string | string[]; +} + +export interface CcrFollowStats extends Generic { + index: string | string[]; +} + +export interface CcrForgetFollower extends Generic { + index: string; + body: T; +} + +export interface CcrGetAutoFollowPattern extends Generic { + name?: string; +} + +export interface CcrPauseAutoFollowPattern extends Generic { + name: string; +} + +export interface CcrPauseFollow extends Generic { + index: string; +} + +export interface CcrPutAutoFollowPattern extends Generic { + name: string; + body: T; +} + +export interface CcrResumeAutoFollowPattern extends Generic { + name: string; +} + +export interface CcrResumeFollow extends Generic { + index: string; + body?: T; +} + +export interface CcrStats extends Generic { +} + +export interface CcrUnfollow extends Generic { + index: string; +} + export interface ClearScroll extends Generic { scroll_id?: string | string[]; body?: T; } +export interface ClosePointInTime extends Generic { + body?: T; +} + export interface ClusterAllocationExplain extends Generic { include_yes_decisions?: boolean; include_disk_info?: boolean; @@ -346,8 +545,8 @@ export interface ClusterReroute extends Generic { } export interface ClusterState extends Generic { - index?: string | string[]; metric?: string | string[]; + index?: string | string[]; local?: boolean; master_timeout?: string; flat_settings?: boolean; @@ -481,6 +680,45 @@ export interface DeleteScript extends Generic { master_timeout?: string; } +export interface EnrichDeletePolicy extends Generic { + name: string; +} + +export interface EnrichExecutePolicy extends Generic { + name: string; + wait_for_completion?: boolean; +} + +export interface EnrichGetPolicy extends Generic { + name?: string | string[]; +} + +export interface EnrichPutPolicy extends Generic { + name: string; + body: T; +} + +export interface EnrichStats extends Generic { +} + +export interface EqlDelete extends Generic { + id: string; +} + +export interface EqlGet extends Generic { + id: string; + wait_for_completion_timeout?: string; + keep_alive?: string; +} + +export interface EqlSearch extends Generic { + index: string; + wait_for_completion_timeout?: string; + keep_on_completion?: boolean; + keep_alive?: string; + body: T; +} + export interface Exists extends Generic { id: string; index: string; @@ -593,6 +831,7 @@ export interface GetSource extends Generic { version_type?: 'internal' | 'external' | 'external_gte' | 'force'; } +<<<<<<< HEAD export interface Index extends Generic { id?: string; index: string; @@ -600,6 +839,71 @@ export interface Index extends Generic { wait_for_active_shards?: string; op_type?: 'index' | 'create'; refresh?: 'wait_for' | boolean; +======= +export interface GraphExplore extends Generic { + index: string | string[]; +>>>>>>> a064f0f3... Improve child performances (#1314) + routing?: string; + timeout?: string; +<<<<<<< HEAD + version?: number; + version_type?: 'internal' | 'external' | 'external_gte'; + if_seq_no?: number; + if_primary_term?: number; + pipeline?: string; + body: T; +======= + body?: T; +>>>>>>> 3db1bed4... Improve child performances (#1314) +} + +export interface IlmDeleteLifecycle extends Generic { + policy: string; +} + +export interface IlmExplainLifecycle extends Generic { + index: string; + only_managed?: boolean; + only_errors?: boolean; +} + +export interface IlmGetLifecycle extends Generic { + policy?: string; +} + +export interface IlmGetStatus extends Generic { +} + +export interface IlmMoveToStep extends Generic { + index: string; + body?: T; +} + +export interface IlmPutLifecycle extends Generic { + policy: string; + body?: T; +} + +export interface IlmRemovePolicy extends Generic { + index: string; +} + +export interface IlmRetry extends Generic { + index: string; +} + +export interface IlmStart extends Generic { +} + +export interface IlmStop extends Generic { +} + +export interface Index extends Generic { + id?: string; + index: string; + wait_for_active_shards?: string; + op_type?: 'index' | 'create'; + refresh?: 'wait_for' | boolean; routing?: string; timeout?: string; version?: number; @@ -607,6 +911,7 @@ export interface Index extends Generic { if_seq_no?: number; if_primary_term?: number; pipeline?: string; + require_alias?: boolean; body: T; } @@ -664,6 +969,14 @@ export interface IndicesCreate extends Generic { body?: T; } +export interface IndicesCreateDataStream extends Generic { + name: string; +} + +export interface IndicesDataStreamsStats extends Generic { + name?: string | string[]; +} + export interface IndicesDelete extends Generic { index: string | string[]; timeout?: string; @@ -680,6 +993,10 @@ export interface IndicesDeleteAlias extends Generic { master_timeout?: string; } +export interface IndicesDeleteDataStream extends Generic { + name: string | string[]; +} + export interface IndicesDeleteIndexTemplate extends Generic { name: string; timeout?: string; @@ -760,6 +1077,16 @@ export interface IndicesForcemerge extends Generic { only_expunge_deletes?: boolean; } +export interface IndicesFreeze extends Generic { + index: string; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + wait_for_active_shards?: string; +} + export interface IndicesGet extends Generic { index: string | string[]; include_type_name?: boolean; @@ -781,6 +1108,10 @@ export interface IndicesGetAlias extends Generic { local?: boolean; } +export interface IndicesGetDataStream extends Generic { + name?: string | string[]; +} + export interface IndicesGetFieldMapping extends Generic { fields: string | string[]; index?: string | string[]; @@ -911,6 +1242,13 @@ export interface IndicesRefresh extends Generic { expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; } +export interface IndicesReloadSearchAnalyzers extends Generic { + index: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; +} + export interface IndicesResolveIndex extends Generic { name: string | string[]; expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; @@ -994,6 +1332,16 @@ export interface IndicesStats extends Generic { forbid_closed_indices?: boolean; } +export interface IndicesUnfreeze extends Generic { + index: string; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + wait_for_active_shards?: string; +} + export interface IndicesUpdateAliases extends Generic { timeout?: string; master_timeout?: string; @@ -1057,6 +1405,34 @@ export interface IngestSimulate extends Generic { body: T; } +export interface LicenseDelete extends Generic { +} + +export interface LicenseGet extends Generic { + local?: boolean; + accept_enterprise?: boolean; +} + +export interface LicenseGetBasicStatus extends Generic { +} + +export interface LicenseGetTrialStatus extends Generic { +} + +export interface LicensePost extends Generic { + acknowledge?: boolean; + body?: T; +} + +export interface LicensePostStartBasic extends Generic { + acknowledge?: boolean; +} + +export interface LicensePostStartTrial extends Generic { + type?: string; + acknowledge?: boolean; +} + export interface Mget extends Generic { index?: string; type?: string; @@ -1073,6 +1449,7 @@ export interface Mget extends Generic { body: T; } +<<<<<<< HEAD export interface Msearch extends Generic { index?: string | string[]; type?: string | string[]; @@ -1113,62 +1490,84 @@ export interface Mtermvectors extends Generic { version?: number; version_type?: 'internal' | 'external' | 'external_gte' | 'force'; body?: T; +======= +export interface MigrationDeprecations extends Generic { + index?: string; } -export interface NodesHotThreads extends Generic { - node_id?: string | string[]; - interval?: string; - snapshots?: number; - threads?: number; - ignore_idle_threads?: boolean; - type?: 'cpu' | 'wait' | 'block'; - timeout?: string; -} - -export interface NodesInfo extends Generic { - node_id?: string | string[]; - metric?: string | string[]; - flat_settings?: boolean; - timeout?: string; -} - -export interface NodesReloadSecureSettings extends Generic { - node_id?: string | string[]; +export interface MlCloseJob extends Generic { + job_id: string; + allow_no_match?: boolean; + allow_no_jobs?: boolean; + force?: boolean; timeout?: string; body?: T; } -export interface NodesStats extends Generic { - node_id?: string | string[]; - metric?: string | string[]; - index_metric?: string | string[]; - completion_fields?: string | string[]; - fielddata_fields?: string | string[]; - fields?: string | string[]; - groups?: boolean; - level?: 'indices' | 'node' | 'shards'; - types?: string | string[]; - timeout?: string; - include_segment_file_sizes?: boolean; +export interface MlDeleteCalendar extends Generic { + calendar_id: string; +>>>>>>> a064f0f3... Improve child performances (#1314) } -export interface NodesUsage extends Generic { - node_id?: string | string[]; - metric?: string | string[]; - timeout?: string; +export interface MlDeleteCalendarEvent extends Generic { + calendar_id: string; + event_id: string; } -export interface Ping extends Generic { +export interface MlDeleteCalendarJob extends Generic { + calendar_id: string; + job_id: string; } -export interface PutScript extends Generic { +export interface MlDeleteDataFrameAnalytics extends Generic { id: string; - context?: string; + force?: boolean; timeout?: string; - master_timeout?: string; +} + +export interface MlDeleteDatafeed extends Generic { + datafeed_id: string; + force?: boolean; +} + +export interface MlDeleteExpiredData extends Generic { + job_id?: string; + requests_per_second?: number; + timeout?: string; + body?: T; +} + +export interface MlDeleteFilter extends Generic { + filter_id: string; +} + +export interface MlDeleteForecast extends Generic { + job_id: string; + forecast_id?: string; + allow_no_forecasts?: boolean; + timeout?: string; +} + +export interface MlDeleteJob extends Generic { + job_id: string; + force?: boolean; + wait_for_completion?: boolean; +} + +export interface MlDeleteModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; +} + +export interface MlDeleteTrainedModel extends Generic { + model_id: string; +} + +export interface MlEstimateModelMemory extends Generic { body: T; } +<<<<<<< HEAD export interface RankEval extends Generic { index?: string | string[]; ignore_unavailable?: boolean; @@ -1895,6 +2294,8 @@ export interface MlEstimateModelMemory extends Generic { body: T; } +======= +>>>>>>> a064f0f3... Improve child performances (#1314) export interface MlEvaluateDataFrame extends Generic { body: T; } @@ -2072,7 +2473,7 @@ export interface MlGetRecords extends Generic { export interface MlGetTrainedModels extends Generic { model_id?: string; allow_no_match?: boolean; - include_model_definition?: boolean; + include?: string; decompress_definition?: boolean; from?: number; size?: number; @@ -2236,6 +2637,144 @@ export interface MonitoringBulk extends Generic { body: T; } +<<<<<<< HEAD +export interface RollupDeleteJob extends Generic { + id: string; +======= +export interface Msearch extends Generic { + index?: string | string[]; + search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; + max_concurrent_searches?: number; + typed_keys?: boolean; + pre_filter_shard_size?: number; + max_concurrent_shard_requests?: number; + rest_total_hits_as_int?: boolean; + ccs_minimize_roundtrips?: boolean; + body: T; +>>>>>>> 3db1bed4... Improve child performances (#1314) +} + +export interface MsearchTemplate extends Generic { + index?: string | string[]; + search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; + typed_keys?: boolean; + max_concurrent_searches?: number; + rest_total_hits_as_int?: boolean; + ccs_minimize_roundtrips?: boolean; + body: T; +} + +export interface Mtermvectors extends Generic { + index?: string; + ids?: string | string[]; + term_statistics?: boolean; + field_statistics?: boolean; + fields?: string | string[]; + offsets?: boolean; + positions?: boolean; + payloads?: boolean; + preference?: string; + routing?: string; + realtime?: boolean; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte'; + body?: T; +} + +export interface NodesHotThreads extends Generic { + node_id?: string | string[]; + interval?: string; + snapshots?: number; + threads?: number; + ignore_idle_threads?: boolean; + type?: 'cpu' | 'wait' | 'block'; + timeout?: string; +} + +export interface NodesInfo extends Generic { + node_id?: string | string[]; + metric?: string | string[]; + flat_settings?: boolean; + timeout?: string; +} + +export interface NodesReloadSecureSettings extends Generic { + node_id?: string | string[]; + timeout?: string; + body?: T; +} + +export interface NodesStats extends Generic { + node_id?: string | string[]; + metric?: string | string[]; + index_metric?: string | string[]; + completion_fields?: string | string[]; + fielddata_fields?: string | string[]; + fields?: string | string[]; + groups?: boolean; + level?: 'indices' | 'node' | 'shards'; + types?: string | string[]; + timeout?: string; + include_segment_file_sizes?: boolean; +} + +export interface NodesUsage extends Generic { + node_id?: string | string[]; + metric?: string | string[]; + timeout?: string; +} + +export interface OpenPointInTime extends Generic { + index?: string | string[]; + preference?: string; + routing?: string; + ignore_unavailable?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + keep_alive?: string; +} + +export interface Ping extends Generic { +} + +export interface PutScript extends Generic { + id: string; + context?: string; + timeout?: string; + master_timeout?: string; + body: T; +} + +export interface RankEval extends Generic { + index?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + body: T; +} + +export interface Reindex extends Generic { + refresh?: boolean; + timeout?: string; + wait_for_active_shards?: string; + wait_for_completion?: boolean; + requests_per_second?: number; + scroll?: string; + slices?: number|string; + max_docs?: number; + body: T; +} + +export interface ReindexRethrottle extends Generic { + task_id: string; + requests_per_second: number; +} + +export interface RenderSearchTemplate extends Generic { + id?: string; + body?: T; +} + export interface RollupDeleteJob extends Generic { id: string; } @@ -2275,6 +2814,94 @@ export interface RollupStopJob extends Generic { timeout?: string; } +export interface ScriptsPainlessExecute extends Generic { + body?: T; +} + +export interface Scroll extends Generic { + scroll_id?: string; + scroll?: string; + rest_total_hits_as_int?: boolean; + body?: T; +} + +export interface Search extends Generic { + index?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + analyzer?: string; + analyze_wildcard?: boolean; + ccs_minimize_roundtrips?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + explain?: boolean; + stored_fields?: string | string[]; + docvalue_fields?: string | string[]; + from?: number; + ignore_unavailable?: boolean; + ignore_throttled?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + lenient?: boolean; + preference?: string; + q?: string; + routing?: string | string[]; + scroll?: string; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + size?: number; + sort?: string | string[]; + _source?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; + terminate_after?: number; + stats?: string | string[]; + suggest_field?: string; + suggest_mode?: 'missing' | 'popular' | 'always'; + suggest_size?: number; + suggest_text?: string; + timeout?: string; + track_scores?: boolean; + track_total_hits?: boolean | number; + allow_partial_search_results?: boolean; + typed_keys?: boolean; + version?: boolean; + seq_no_primary_term?: boolean; + request_cache?: boolean; + batched_reduce_size?: number; + max_concurrent_shard_requests?: number; + pre_filter_shard_size?: number; + rest_total_hits_as_int?: boolean; + body?: T; +} + +export interface SearchShards extends Generic { + index?: string | string[]; + preference?: string; + routing?: string; + local?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; +} + +export interface SearchTemplate extends Generic { + index?: string | string[]; + ignore_unavailable?: boolean; + ignore_throttled?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + preference?: string; + routing?: string | string[]; + scroll?: string; + search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; + explain?: boolean; + profile?: boolean; + typed_keys?: boolean; + rest_total_hits_as_int?: boolean; + ccs_minimize_roundtrips?: boolean; + body: T; +} + export interface SearchableSnapshotsClearCache extends Generic { index?: string | string[]; ignore_unavailable?: boolean; @@ -2459,6 +3086,75 @@ export interface SlmStart extends Generic { export interface SlmStop extends Generic { } +export interface SnapshotCleanupRepository extends Generic { + repository: string; + master_timeout?: string; + timeout?: string; +} + +export interface SnapshotCreate extends Generic { + repository: string; + snapshot: string; + master_timeout?: string; + wait_for_completion?: boolean; + body?: T; +} + +export interface SnapshotCreateRepository extends Generic { + repository: string; + master_timeout?: string; + timeout?: string; + verify?: boolean; + body: T; +} + +export interface SnapshotDelete extends Generic { + repository: string; + snapshot: string | string[]; + master_timeout?: string; +} + +export interface SnapshotDeleteRepository extends Generic { + repository: string | string[]; + master_timeout?: string; + timeout?: string; +} + +export interface SnapshotGet extends Generic { + repository: string; + snapshot: string | string[]; + master_timeout?: string; + ignore_unavailable?: boolean; + verbose?: boolean; +} + +export interface SnapshotGetRepository extends Generic { + repository?: string | string[]; + master_timeout?: string; + local?: boolean; +} + +export interface SnapshotRestore extends Generic { + repository: string; + snapshot: string; + master_timeout?: string; + wait_for_completion?: boolean; + body?: T; +} + +export interface SnapshotStatus extends Generic { + repository?: string; + snapshot?: string | string[]; + master_timeout?: string; + ignore_unavailable?: boolean; +} + +export interface SnapshotVerifyRepository extends Generic { + repository: string; + master_timeout?: string; + timeout?: string; +} + export interface SqlClearCursor extends Generic { body: T; } @@ -2475,6 +3171,47 @@ export interface SqlTranslate extends Generic { export interface SslCertificates extends Generic { } +export interface TasksCancel extends Generic { + task_id?: string; + nodes?: string | string[]; + actions?: string | string[]; + parent_task_id?: string; + wait_for_completion?: boolean; +} + +export interface TasksGet extends Generic { + task_id: string; + wait_for_completion?: boolean; + timeout?: string; +} + +export interface TasksList extends Generic { + nodes?: string | string[]; + actions?: string | string[]; + detailed?: boolean; + parent_task_id?: string; + wait_for_completion?: boolean; + group_by?: 'nodes' | 'parents' | 'none'; + timeout?: string; +} + +export interface Termvectors extends Generic { + index: string; + id?: string; + term_statistics?: boolean; + field_statistics?: boolean; + fields?: string | string[]; + offsets?: boolean; + positions?: boolean; + payloads?: boolean; + preference?: string; + routing?: string; + realtime?: boolean; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte'; + body?: T; +} + export interface TransformDeleteTransform extends Generic { transform_id: string; force?: boolean; @@ -2524,6 +3261,73 @@ export interface TransformUpdateTransform extends Generic { body: T; } +export interface Update extends Generic { + id: string; + index: string; + type?: string; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + wait_for_active_shards?: string; + _source?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; + lang?: string; + refresh?: 'wait_for' | boolean; + retry_on_conflict?: number; + routing?: string; + timeout?: string; + if_seq_no?: number; + if_primary_term?: number; + require_alias?: boolean; + body: T; +} + +export interface UpdateByQuery extends Generic { + index: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + analyzer?: string; + analyze_wildcard?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + from?: number; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + conflicts?: 'abort' | 'proceed'; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + lenient?: boolean; + pipeline?: string; + preference?: string; + q?: string; + routing?: string | string[]; + scroll?: string; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + search_timeout?: string; + max_docs?: number; + sort?: string | string[]; + _source?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; + terminate_after?: number; + stats?: string | string[]; + version?: boolean; + version_type?: boolean; + request_cache?: boolean; + refresh?: boolean; + timeout?: string; + wait_for_active_shards?: string; + scroll_size?: number; + wait_for_completion?: boolean; + requests_per_second?: number; + slices?: number|string; + body?: T; +} + +export interface UpdateByQueryRethrottle extends Generic { + task_id: string; + requests_per_second: number; +} + export interface WatcherAckWatch extends Generic { watch_id: string; action_id?: string | string[]; diff --git a/api/utils.js b/api/utils.js new file mode 100644 index 000000000..1982d68da --- /dev/null +++ b/api/utils.js @@ -0,0 +1,58 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +const result = { body: null, statusCode: null, headers: null, warnings: null } +const kConfigurationError = Symbol('configuration error') + +function handleError (err, callback) { + if (callback) { + process.nextTick(callback, err, result) + return { then: noop, catch: noop, abort: noop } + } + return Promise.reject(err) +} + +function snakeCaseKeys (acceptedQuerystring, snakeCase, querystring) { + var target = {} + var keys = Object.keys(querystring) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + target[snakeCase[key] || key] = querystring[key] + } + return target +} + +function normalizeArguments (params, options, callback) { + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + return [params, options, callback] +} + +function noop () {} + +module.exports = { handleError, snakeCaseKeys, normalizeArguments, noop, kConfigurationError } diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 2664f1468..46fb6bfd9 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -95,6 +95,7 @@ link:{ref}/common-options.html[Documentation] |`list` - A comma-separated list of filters used to reduce the response. |=== +<<<<<<< HEAD === bulk [source,ts] @@ -761,6 +762,1325 @@ link:{ref}/cat-repositories.html[Documentation] + |=== +=== cat.segments +======= +=== asyncSearch.delete +>>>>>>> a064f0f3... Improve child performances (#1314) + +[source,ts] +---- +client.asyncSearch.delete({ + id: string +}) +---- +link:{ref}/async-search.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The async search ID + +|=== + +=== asyncSearch.get + +[source,ts] +---- +client.asyncSearch.get({ + id: string, + wait_for_completion_timeout: string, + keep_alive: string, + typed_keys: boolean +}) +---- +link:{ref}/async-search.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The async search ID + +|`wait_for_completion_timeout` or `waitForCompletionTimeout` +|`string` - Specify the time that the request should block waiting for the final response + +|`keep_alive` or `keepAlive` +|`string` - Specify the time interval in which the results (partial or final) for this search will be available + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|=== + +=== asyncSearch.submit + +[source,ts] +---- +client.asyncSearch.submit({ + index: string | string[], + wait_for_completion_timeout: string, + keep_on_completion: boolean, + keep_alive: string, + batched_reduce_size: number, + request_cache: boolean, + analyzer: string, + analyze_wildcard: boolean, + default_operator: 'AND' | 'OR', + df: string, + explain: boolean, + stored_fields: string | string[], + docvalue_fields: string | string[], + from: number, + ignore_unavailable: boolean, + ignore_throttled: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + preference: string, + q: string, + routing: string | string[], + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + size: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + suggest_field: string, + suggest_mode: 'missing' | 'popular' | 'always', + suggest_size: number, + suggest_text: string, + timeout: string, + track_scores: boolean, + track_total_hits: boolean|long, + allow_partial_search_results: boolean, + typed_keys: boolean, + version: boolean, + seq_no_primary_term: boolean, + max_concurrent_shard_requests: number, + body: object +}) +---- +link:{ref}/async-search.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`wait_for_completion_timeout` or `waitForCompletionTimeout` +|`string` - Specify the time that the request should block waiting for the final response + +_Default:_ `1s` + +|`keep_on_completion` or `keepOnCompletion` +|`boolean` - Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) + +|`keep_alive` or `keepAlive` +|`string` - Update the time interval in which the results (partial or final) for this search will be available + +_Default:_ `5d` + +|`batched_reduce_size` or `batchedReduceSize` +|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as the granularity at which progress results will be made available. + +_Default:_ `5` + +|`request_cache` or `requestCache` +|`boolean` - Specify if request cache should be used for this request or not, defaults to true + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + +_Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`explain` +|`boolean` - Specify whether to return detailed information about score computation as part of a hit + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return as part of a hit + +|`docvalue_fields` or `docvalueFields` +|`string \| string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`ignore_throttled` or `ignoreThrottled` +|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`q` +|`string` - Query in the Lucene query string syntax + +|`routing` +|`string \| string[]` - A comma-separated list of specific routing values + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type + +|`size` +|`number` - Number of hits to return (default: 10) + +|`sort` +|`string \| string[]` - A comma-separated list of : pairs + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - A list of fields to extract and return from the _source field + +|`terminate_after` or `terminateAfter` +|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + +|`stats` +|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes + +|`suggest_field` or `suggestField` +|`string` - Specify which field to use for suggestions + +|`suggest_mode` or `suggestMode` +|`'missing' \| 'popular' \| 'always'` - Specify suggest mode + +_Default:_ `missing` + +|`suggest_size` or `suggestSize` +|`number` - How many suggestions to return in response + +|`suggest_text` or `suggestText` +|`string` - The source text for which the suggestions should be returned + +<<<<<<< HEAD +[source,ts] +---- +client.cat.threadPool({ + thread_pool_patterns: string | string[], + format: string, + size: '' | 'k' | 'm' | 'g' | 't' | 'p', + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-thread-pool.html[Documentation] + +[cols=2*] +|=== +|`thread_pool_patterns` or `threadPoolPatterns` +|`string \| string[]` - A comma-separated list of regular-expressions to filter the thread pools in the output +======= +|`timeout` +|`string` - Explicit operation timeout +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`track_scores` or `trackScores` +|`boolean` - Whether to calculate and return scores even if they are not used for sorting + +<<<<<<< HEAD +|`size` +|`'' \| 'k' \| 'm' \| 'g' \| 't' \| 'p'` - The multiplier in which to display values + + +WARNING: This parameter has been deprecated. +======= +|`track_total_hits` or `trackTotalHits` +|`boolean\|long` - Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`allow_partial_search_results` or `allowPartialSearchResults` +|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + +_Default:_ `true` + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`seq_no_primary_term` or `seqNoPrimaryTerm` +|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit + +|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` +|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + +_Default:_ `5` + +|`body` +|`object` - The search definition using the Query DSL + +|=== + +=== autoscaling.deleteAutoscalingPolicy +*Stability:* experimental +[source,ts] +---- +client.autoscaling.deleteAutoscalingPolicy({ + name: string +}) +---- +link:{ref}/autoscaling-delete-autoscaling-policy.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - the name of the autoscaling policy + +|=== + +=== autoscaling.getAutoscalingDecision +*Stability:* experimental +[source,ts] +---- +client.autoscaling.getAutoscalingDecision() +---- +link:{ref}/autoscaling-get-autoscaling-decision.html[Documentation] + + + +=== autoscaling.getAutoscalingPolicy +*Stability:* experimental +[source,ts] +---- +client.autoscaling.getAutoscalingPolicy({ + name: string +}) +---- +link:{ref}/autoscaling-get-autoscaling-policy.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - the name of the autoscaling policy + +|=== + +=== autoscaling.putAutoscalingPolicy +*Stability:* experimental +[source,ts] +---- +client.autoscaling.putAutoscalingPolicy({ + name: string, + body: object +}) +---- +link:{ref}/autoscaling-put-autoscaling-policy.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - the name of the autoscaling policy + +|`body` +|`object` - the specification of the autoscaling policy + +|=== + +=== bulk + +[source,ts] +---- +client.bulk({ + index: string, + type: string, + wait_for_active_shards: string, + refresh: 'true' | 'false' | 'wait_for', + routing: string, + timeout: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + pipeline: string, + require_alias: boolean, + body: object +}) +---- +link:{ref}/docs-bulk.html[Documentation] + +{jsclient}/bulk_examples.html[Code Example] + +[cols=2*] +|=== +|`index` +|`string` - Default index for items which don't provide one + +|`type` +|`string` - Default document type for items which don't provide one + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`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. + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - Default list of fields to extract and return from the _source field, can be overridden on each sub-request + +|`pipeline` +|`string` - The pipeline id to preprocess incoming documents with + +|`require_alias` or `requireAlias` +|`boolean` - Sets require_alias for all incoming documents. Defaults to unset (false) + +|`body` +|`object` - The operation definition and data (action-data pairs), separated by newlines + +|=== + +=== cat.aliases + +[source,ts] +---- +client.cat.aliases({ + name: string | string[], + format: string, + local: boolean, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +}) +---- +link:{ref}/cat-alias.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - A comma-separated list of alias names to return + +|`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) + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `all` + +|=== + +=== cat.allocation + +[source,ts] +---- +client.cat.allocation({ + node_id: 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[], + v: boolean +}) +---- +link:{ref}/cat-allocation.html[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`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 + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.count + +[source,ts] +---- +client.cat.count({ + index: string | string[], + format: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-count.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.fielddata + +[source,ts] +---- +client.cat.fielddata({ + fields: string | string[], + format: string, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-fielddata.html[Documentation] + +[cols=2*] +|=== +|`fields` +|`string \| string[]` - A comma-separated list of fields to return the fielddata size + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.health + +[source,ts] +---- +client.cat.health({ + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + ts: boolean, + v: boolean +}) +---- +link:{ref}/cat-health.html[Documentation] + +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`ts` +|`boolean` - Set to false to disable timestamping + +_Default:_ `true` + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.help + +[source,ts] +---- +client.cat.help({ + help: boolean, + s: string | string[] +}) +---- +link:{ref}/cat.html[Documentation] + +[cols=2*] +|=== +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|=== + +=== cat.indices + +[source,ts] +---- +client.cat.indices({ + index: string | string[], + format: string, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + local: boolean, + master_timeout: string, + h: string | string[], + health: 'green' | 'yellow' | 'red', + help: boolean, + pri: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean, + include_unloaded_segments: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +}) +---- +link:{ref}/cat-indices.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`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 + +|`health` +|`'green' \| 'yellow' \| 'red'` - A health status ("green", "yellow", or "red" to filter only indices matching the specified health status + +|`help` +|`boolean` - Return help information + +|`pri` +|`boolean` - Set to true to return stats only for primary shards + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|`include_unloaded_segments` or `includeUnloadedSegments` +|`boolean` - If set to true segment stats will include stats for segments that are not currently loaded into memory + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `all` + +|=== + +=== cat.master + +[source,ts] +---- +client.cat.master({ + format: string, + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-master.html[Documentation] + +[cols=2*] +|=== +|`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 + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.mlDataFrameAnalytics + +[source,ts] +---- +client.cat.mlDataFrameAnalytics({ + id: string, + allow_no_match: boolean, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +}) +---- +link:{ref}/cat-dfanalytics.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The ID of the data frame analytics to fetch + +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no configs. (This includes `_all` string or when no configs have been specified) + +|`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 + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.mlDatafeeds + +[source,ts] +---- +client.cat.mlDatafeeds({ + datafeed_id: string, + allow_no_match: boolean, + allow_no_datafeeds: boolean, + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +}) +---- +link:{ref}/cat-datafeeds.html[Documentation] + +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeeds stats to fetch + +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + + +WARNING: This parameter has been deprecated. + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.mlJobs + +[source,ts] +---- +client.cat.mlJobs({ + job_id: string, + allow_no_match: boolean, + allow_no_jobs: boolean, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +}) +---- +link:{ref}/cat-anomaly-detectors.html[Documentation] + +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the jobs stats to fetch + +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + + +WARNING: This parameter has been deprecated. + +|`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 + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.mlTrainedModels + +[source,ts] +---- +<<<<<<< HEAD +client.count({ + index: string | string[], + type: string | string[], + ignore_unavailable: boolean, + ignore_throttled: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + min_score: number, + preference: string, + routing: string | string[], + q: string, + analyzer: string, + analyze_wildcard: boolean, + default_operator: 'AND' | 'OR', + df: string, + lenient: boolean, + terminate_after: number, + body: object +======= +client.cat.mlTrainedModels({ + model_id: string, + allow_no_match: boolean, + from: number, + size: number, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/cat-trained-model.html[Documentation] + +[cols=2*] +|=== +|`model_id` or `modelId` +|`string` - The ID of the trained models stats to fetch + +<<<<<<< HEAD +|`type` +|`string \| string[]` - A comma-separated list of types to restrict the results + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) +======= +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + +_Default:_ `true` +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`from` +|`number` - skips a number of trained models + +|`size` +|`number` - specifies a max number of trained models to get + +_Default:_ `100` + +|`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 + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.nodeattrs + +[source,ts] +---- +client.cat.nodeattrs({ + format: string, + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-nodeattrs.html[Documentation] + +[cols=2*] +|=== +|`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 + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.nodes + +[source,ts] +---- +client.cat.nodes({ + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + format: string, + full_id: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +}) +---- +link:{ref}/cat-nodes.html[Documentation] + +[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 + +|`full_id` or `fullId` +|`boolean` - Return the full node ID instead of the shortened version (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 + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.pendingTasks + +[source,ts] +---- +client.cat.pendingTasks({ + format: string, + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +}) +---- +link:{ref}/cat-pending-tasks.html[Documentation] + +[cols=2*] +|=== +|`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 + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.plugins + +[source,ts] +---- +client.cat.plugins({ + format: string, + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-plugins.html[Documentation] + +[cols=2*] +|=== +|`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 + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.recovery + +[source,ts] +---- +<<<<<<< HEAD +client.delete({ + id: string, + index: string, + type: string, + wait_for_active_shards: string, + refresh: 'true' | 'false' | 'wait_for', + routing: string, + timeout: string, + if_seq_no: number, + if_primary_term: number, + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force' +======= +client.cat.recovery({ + index: string | string[], + format: string, + active_only: boolean, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + detailed: boolean, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/cat-recovery.html[Documentation] + +[cols=2*] +|=== +|`index` +|`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 + +|`detailed` +|`boolean` - If `true`, the response includes detailed information about shard recoveries + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= +|`v` +|`boolean` - Verbose mode. Display column headers +>>>>>>> a064f0f3... Improve child performances (#1314) + +|=== + +=== cat.repositories + +[source,ts] +---- +<<<<<<< HEAD +client.deleteByQuery({ + index: string | string[], + type: string | string[], + analyzer: string, + analyze_wildcard: boolean, + default_operator: 'AND' | 'OR', + df: string, + from: number, + ignore_unavailable: boolean, + allow_no_indices: boolean, + conflicts: 'abort' | 'proceed', + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + preference: string, + q: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + search_timeout: string, + size: number, + max_docs: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + version: boolean, + request_cache: boolean, + refresh: boolean, + timeout: string, + wait_for_active_shards: string, + scroll_size: number, + wait_for_completion: boolean, + requests_per_second: number, + slices: number|string, + body: object +======= +client.cat.repositories({ + format: string, + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/cat-repositories.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`type` +|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + +_Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) +======= +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + === cat.segments [source,ts] @@ -784,8 +2104,16 @@ link:{ref}/cat-segments.html[Documentation] + |`format` |`string` - a short version of the Accept header, e.g. json, yaml +<<<<<<< HEAD +|`size` +|`number` - Deprecated, please use `max_docs` instead + +|`max_docs` or `maxDocs` +|`number` - Maximum number of documents to process (default: all documents) +======= |`bytes` |`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values +>>>>>>> a064f0f3... Improve child performances (#1314) |`h` |`string \| string[]` - Comma-separated list of column names to display @@ -827,8 +2155,13 @@ link:{ref}/cat-shards.html[Documentation] + |`format` |`string` - a short version of the Accept header, e.g. json, yaml +<<<<<<< HEAD +|`refresh` +|`boolean` - Should the effected indexes be refreshed? +======= |`bytes` |`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values +>>>>>>> a064f0f3... Improve child performances (#1314) |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) @@ -957,6 +2290,22 @@ link:{ref}/tasks.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.exists({ + id: string, + index: string, + type: string, + stored_fields: string | string[], + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force' +======= client.cat.templates({ name: string, format: string, @@ -966,13 +2315,36 @@ client.cat.templates({ help: boolean, s: string | string[], v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/cat-templates.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`id` +|`string` - The document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + + +WARNING: This parameter has been deprecated. + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return in the response + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode +======= |`name` |`string` - A pattern that returned template names must match +>>>>>>> a064f0f3... Improve child performances (#1314) |`format` |`string` - a short version of the Accept header, e.g. json, yaml @@ -992,8 +2364,13 @@ link:{ref}/cat-templates.html[Documentation] + |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= |`v` |`boolean` - Verbose mode. Display column headers +>>>>>>> a064f0f3... Improve child performances (#1314) |=== @@ -1001,16 +2378,32 @@ link:{ref}/cat-templates.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.existsSource({ + id: string, + index: string, + type: string, + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force' +======= client.cat.threadPool({ thread_pool_patterns: string | string[], format: string, - size: '' | 'k' | 'm' | 'g' | 't' | 'p', + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', local: boolean, master_timeout: string, h: string | string[], help: boolean, s: string | string[], v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/cat-thread-pool.html[Documentation] + @@ -1022,10 +2415,8 @@ link:{ref}/cat-thread-pool.html[Documentation] + |`format` |`string` - a short version of the Accept header, e.g. json, yaml -|`size` -|`'' \| 'k' \| 'm' \| 'g' \| 't' \| 'p'` - The multiplier in which to display values + - -WARNING: This parameter has been deprecated. +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) @@ -1042,8 +2433,388 @@ WARNING: This parameter has been deprecated. |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= |`v` |`boolean` - Verbose mode. Display column headers +>>>>>>> a064f0f3... Improve child performances (#1314) + +|=== + +=== cat.transforms + +[source,ts] +---- +<<<<<<< HEAD +client.explain({ + id: string, + index: string, + type: string, + analyze_wildcard: boolean, + analyzer: string, + default_operator: 'AND' | 'OR', + df: string, + stored_fields: string | string[], + lenient: boolean, + preference: string, + q: string, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + body: object +======= +client.cat.transforms({ + transform_id: string, + from: number, + size: number, + allow_no_match: boolean, + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/cat-transforms.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`id` +|`string` - The document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + + +WARNING: This parameter has been deprecated. + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) +======= +|`transform_id` or `transformId` +|`string` - The id of the transform for which to get stats. '_all' or '*' implies all transforms +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`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) + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== ccr.deleteAutoFollowPattern + +[source,ts] +---- +client.ccr.deleteAutoFollowPattern({ + name: string +}) +---- +link:{ref}/ccr-delete-auto-follow-pattern.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern. + +|=== + +=== ccr.follow + +[source,ts] +---- +client.ccr.follow({ + index: string, + wait_for_active_shards: string, + body: object +}) +---- +link:{ref}/ccr-put-follow.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the follower index + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +_Default:_ `0` + +|`body` +|`object` - The name of the leader index and other optional ccr related parameters + +|=== + +=== ccr.followInfo + +[source,ts] +---- +client.ccr.followInfo({ + index: string | string[] +}) +---- +link:{ref}/ccr-get-follow-info.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices + +|=== + +=== ccr.followStats + +[source,ts] +---- +<<<<<<< HEAD +client.get({ + id: string, + index: string, + type: string, + stored_fields: string | string[], + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force' +======= +client.ccr.followStats({ + index: string | string[] +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/ccr-get-follow-stats.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices + +<<<<<<< HEAD +|`type` +|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + + +WARNING: This parameter has been deprecated. + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return in the response +======= +|=== +>>>>>>> a064f0f3... Improve child performances (#1314) + +=== ccr.forgetFollower + +[source,ts] +---- +client.ccr.forgetFollower({ + index: string, + body: object +}) +---- +link:{ref}/ccr-post-forget-follower.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - the name of the leader index for which specified follower retention leases should be removed + +|`body` +|`object` - the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index + +|=== + +=== ccr.getAutoFollowPattern + +[source,ts] +---- +client.ccr.getAutoFollowPattern({ + name: string +}) +---- +link:{ref}/ccr-get-auto-follow-pattern.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern. + +|=== + +=== ccr.pauseAutoFollowPattern + +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= +[source,ts] +---- +client.ccr.pauseAutoFollowPattern({ + name: string +}) +---- +link:{ref}/ccr-pause-auto-follow-pattern.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern that should pause discovering new indices to follow. +>>>>>>> a064f0f3... Improve child performances (#1314) + +|=== + +=== ccr.pauseFollow + +[source,ts] +---- +client.ccr.pauseFollow({ + index: string +}) +---- +link:{ref}/ccr-post-pause-follow.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the follower index that should pause following its leader index. + +|=== + +=== ccr.putAutoFollowPattern + +[source,ts] +---- +client.ccr.putAutoFollowPattern({ + name: string, + body: object +}) +---- +link:{ref}/ccr-put-auto-follow-pattern.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern. + +|`body` +|`object` - The specification of the auto follow pattern + +|=== + +=== ccr.resumeAutoFollowPattern + +[source,ts] +---- +client.ccr.resumeAutoFollowPattern({ + name: string +}) +---- +link:{ref}/ccr-resume-auto-follow-pattern.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern to resume discovering new indices to follow. + +|=== + +=== ccr.resumeFollow + +[source,ts] +---- +client.ccr.resumeFollow({ + index: string, +<<<<<<< HEAD + type: string, + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force' +======= + body: object +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/ccr-post-resume-follow.html[Documentation] + +[cols=2*] +|=== +|`index` +<<<<<<< HEAD +|`string` - The name of the index + +|`type` +|`string` - The type of the document; deprecated and optional starting with 7.0 + + +WARNING: This parameter has been deprecated. + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode +======= +|`string` - The name of the follow index to resume following. +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`body` +|`object` - The name of the leader index and other optional ccr related parameters + +|=== + +=== ccr.stats + +[source,ts] +---- +client.ccr.stats() +---- +link:{ref}/ccr-get-stats.html[Documentation] + + + +=== ccr.unfollow + +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= +[source,ts] +---- +client.ccr.unfollow({ + index: string +}) +---- +link:{ref}/ccr-post-unfollow.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the follower index that should be turned into a regular index. +>>>>>>> a064f0f3... Improve child performances (#1314) |=== @@ -1051,16 +2822,56 @@ WARNING: This parameter has been deprecated. [source,ts] ---- +<<<<<<< HEAD +client.index({ + id: string, + index: string, + type: string, + wait_for_active_shards: string, + op_type: 'index' | 'create', + refresh: 'true' | 'false' | 'wait_for', + routing: string, + timeout: string, + version: number, + version_type: 'internal' | 'external' | 'external_gte', + if_seq_no: number, + if_primary_term: number, + pipeline: string, +<<<<<<< HEAD +======= + require_alias: boolean, +======= client.clearScroll({ scroll_id: string | string[], +>>>>>>> a064f0f3... Improve child performances (#1314) +>>>>>>> 3db1bed4... Improve child performances (#1314) body: object }) ---- link:{ref}/clear-scroll-api.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`id` +|`string` - Document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + + +WARNING: This parameter has been deprecated. + +|`wait_for_active_shards` or `waitForActiveShards` +|`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. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID +======= |`scroll_id` or `scrollId` |`string \| string[]` - A comma-separated list of scroll IDs to clear + +>>>>>>> a064f0f3... Improve child performances (#1314) WARNING: This parameter has been deprecated. @@ -1069,6 +2880,22 @@ WARNING: This parameter has been deprecated. |=== +=== closePointInTime + +[source,ts] +---- +client.closePointInTime({ + body: object +}) +---- +link:{ref}/point-in-time-api.html[Documentation] + +[cols=2*] +|=== +|`body` +|`object` - a point-in-time id to close + +|=== + === cluster.allocationExplain [source,ts] @@ -1085,9 +2912,12 @@ link:{ref}/cluster-allocation-explain.html[Documentation] + |`include_yes_decisions` or `includeYesDecisions` |`boolean` - Return 'YES' decisions in explanation (default: false) +<<<<<<< HEAD +======= |`include_disk_info` or `includeDiskInfo` |`boolean` - Return information about disk usage and shard sizes (default: false) +>>>>>>> 3db1bed4... Improve child performances (#1314) |`body` |`object` - The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' @@ -1276,16 +3106,40 @@ _Default:_ `cluster` [source,ts] ---- +<<<<<<< HEAD +client.indices.create({ + index: string, + include_type_name: boolean, + wait_for_active_shards: string, + timeout: string, + master_timeout: string, + body: object +======= client.cluster.pendingTasks({ local: boolean, master_timeout: string +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/cluster-pending.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`index` +|`string` - The name of the index + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be expected in the body of the mappings. + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Set the number of active shards to wait for before the operation returns. + +|`timeout` +|`string` - Explicit operation timeout +======= |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) +>>>>>>> a064f0f3... Improve child performances (#1314) |`master_timeout` or `masterTimeout` |`string` - Specify timeout for connection to master @@ -1431,8 +3285,8 @@ link:{ref}/cluster-reroute.html[Documentation] + [source,ts] ---- client.cluster.state({ - index: string | string[], metric: string | string[], + index: string | string[], local: boolean, master_timeout: string, flat_settings: boolean, @@ -1446,12 +3300,12 @@ client.cluster.state({ link:{ref}/cluster-state.html[Documentation] + [cols=2*] |=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - |`metric` |`string \| string[]` - Limit the information returned to the specified metrics +|`index` +|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) @@ -1509,7 +3363,6 @@ link:{ref}/cluster-stats.html[Documentation] + ---- client.count({ index: string | string[], - type: string | string[], ignore_unavailable: boolean, ignore_throttled: boolean, allow_no_indices: boolean, @@ -1533,9 +3386,6 @@ link:{ref}/search-count.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of indices to restrict the results -|`type` -|`string \| string[]` - A comma-separated list of types to restrict the results - |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -1585,7 +3435,40 @@ _Default:_ `OR` |=== +<<<<<<< HEAD +=== indices.flushSynced + +[source,ts] +---- +client.indices.flushSynced({ + index: string | string[], + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'none' | 'all' +}) +---- +link:{ref}/indices-synced-flush-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string for all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|=== + +=== indices.forcemerge +======= === create +>>>>>>> a064f0f3... Improve child performances (#1314) [source,ts] ---- @@ -1647,18 +3530,51 @@ WARNING: This parameter has been deprecated. [source,ts] ---- +<<<<<<< HEAD +client.indices.get({ + index: string | string[], + include_type_name: boolean, + local: boolean, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + flat_settings: boolean, + include_defaults: boolean, +======= client.danglingIndices.deleteDanglingIndex({ index_uuid: string, accept_data_loss: boolean, timeout: string, +>>>>>>> a064f0f3... Improve child performances (#1314) master_timeout: string }) ---- link:{ref}/modules-gateway-dangling-indices.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`index` +|`string \| string[]` - A comma-separated list of index names + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether to add the type name to the response (default: false) + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Ignore unavailable indexes (default: false) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Ignore if a wildcard expression resolves to no concrete indices (default: false) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + +_Default:_ `open` +======= |`index_uuid` or `indexUuid` |`string` - The UUID of the dangling index +>>>>>>> a064f0f3... Improve child performances (#1314) |`accept_data_loss` or `acceptDataLoss` |`boolean` - Must be set to true in order to delete the dangling index @@ -1712,6 +3628,18 @@ link:{ref}/modules-gateway-dangling-indices.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.indices.getFieldMapping({ + fields: string | string[], + index: string | string[], + type: string | string[], + include_type_name: boolean, + include_defaults: boolean, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + local: boolean +======= client.delete({ id: string, index: string, @@ -1723,7 +3651,8 @@ client.delete({ if_seq_no: number, if_primary_term: number, version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' + version_type: 'internal' | 'external' | 'external_gte' +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/docs-delete.html[Documentation] + @@ -1736,7 +3665,19 @@ link:{ref}/docs-delete.html[Documentation] + |`string` - The name of the index |`type` +<<<<<<< HEAD +|`string \| string[]` - A comma-separated list of document types + + +WARNING: This parameter has been deprecated. + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be returned in the body of the mappings. + +|`include_defaults` or `includeDefaults` +|`boolean` - Whether the default mapping values should be returned as well +======= |`string` - The type of the document + +>>>>>>> a064f0f3... Improve child performances (#1314) WARNING: This parameter has been deprecated. @@ -1762,7 +3703,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 |=== @@ -1772,7 +3713,6 @@ WARNING: This parameter has been deprecated. ---- client.deleteByQuery({ index: string | string[], - type: string | string[], analyzer: string, analyze_wildcard: boolean, default_operator: 'AND' | 'OR', @@ -1789,7 +3729,6 @@ client.deleteByQuery({ scroll: string, search_type: 'query_then_fetch' | 'dfs_query_then_fetch', search_timeout: string, - size: number, max_docs: number, sort: string | string[], _source: string | string[], @@ -1815,9 +3754,6 @@ link:{ref}/docs-delete-by-query.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - |`analyzer` |`string` - The analyzer to use for the query string @@ -1831,8 +3767,37 @@ _Default:_ `OR` |`df` |`string` - The field to use as default where no field prefix is given in the query string +<<<<<<< HEAD +[source,ts] +---- +client.indices.getMapping({ + index: string | string[], + type: string | string[], + include_type_name: boolean, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + master_timeout: string, + local: boolean +}) +---- +link:{ref}/indices-get-mapping.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names +======= |`from` |`number` - Starting offset (default: 0) +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`type` +|`string \| string[]` - A comma-separated list of document types + + +WARNING: This parameter has been deprecated. + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether to add the type name to the response (default: false) |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -1869,9 +3834,6 @@ _Default:_ `open` |`search_timeout` or `searchTimeout` |`string` - Explicit timeout for each search request. Defaults to no timeout. -|`size` -|`number` - Deprecated, please use `max_docs` instead - |`max_docs` or `maxDocs` |`number` - Maximum number of documents to process (default: all documents) @@ -1899,12 +3861,36 @@ _Default:_ `open` |`request_cache` or `requestCache` |`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting +<<<<<<< HEAD +[source,ts] +---- +client.indices.getTemplate({ + name: string | string[], + include_type_name: boolean, + flat_settings: boolean, + master_timeout: string, + local: boolean +}) +---- +link:{ref}/indices-templates.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - The comma separated names of the index templates + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be returned in the body of the mappings. + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) +======= |`refresh` -|`boolean` - Should the effected indexes be refreshed? +|`boolean` - Should the affected indexes be refreshed? |`timeout` |`string` - Time each individual bulk request should wait for shards that are unavailable. + _Default:_ `1m` +>>>>>>> a064f0f3... Improve child performances (#1314) |`wait_for_active_shards` or `waitForActiveShards` |`string` - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @@ -1973,6 +3959,211 @@ link:{ref}/modules-scripting.html[Documentation] + |=== +=== enrich.deletePolicy + +[source,ts] +---- +client.enrich.deletePolicy({ + name: string +}) +---- +link:{ref}/delete-enrich-policy-api.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the enrich policy + +|=== + +=== enrich.executePolicy + +[source,ts] +---- +client.enrich.executePolicy({ + name: string, + wait_for_completion: boolean +}) +---- +link:{ref}/execute-enrich-policy-api.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the enrich policy + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request should block until the execution is complete. + +_Default:_ `true` + +|=== + +=== enrich.getPolicy + +[source,ts] +---- +client.enrich.getPolicy({ + name: string | string[] +}) +---- +link:{ref}/get-enrich-policy-api.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - A comma-separated list of enrich policy names + +|=== + +=== enrich.putPolicy + +[source,ts] +---- +<<<<<<< HEAD +client.indices.putMapping({ + index: string | string[], + type: string, + include_type_name: boolean, + timeout: string, + master_timeout: string, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + write_index_only: boolean, +======= +client.enrich.putPolicy({ + name: string, +>>>>>>> a064f0f3... Improve child performances (#1314) + body: object +}) +---- +link:{ref}/put-enrich-policy-api.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`index` +|`string \| string[]` - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. + +|`type` +|`string` - The name of the document type + + +WARNING: This parameter has been deprecated. + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be expected in the body of the mappings. + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master +======= +|`name` +|`string` - The name of the enrich policy +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`body` +|`object` - The enrich policy to register + +|=== + +=== enrich.stats + +[source,ts] +---- +client.enrich.stats() +---- +link:{ref}/enrich-stats-api.html[Documentation] + + + +=== eql.delete +*Stability:* beta +[source,ts] +---- +client.eql.delete({ + id: string +}) +---- +link:{ref}/eql-search-api.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The async search ID + +|=== + +=== eql.get +*Stability:* beta +[source,ts] +---- +client.eql.get({ + id: string, + wait_for_completion_timeout: string, + keep_alive: string +}) +---- +link:{ref}/eql-search-api.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The async search ID + +|`wait_for_completion_timeout` or `waitForCompletionTimeout` +|`string` - Specify the time that the request should block waiting for the final response + +|`keep_alive` or `keepAlive` +|`string` - Update the time interval in which the results (partial or final) for this search will be available + +_Default:_ `5d` + +|=== + +=== eql.search +*Stability:* beta +[source,ts] +---- +<<<<<<< HEAD +client.indices.putTemplate({ + name: string, + include_type_name: boolean, + order: number, + create: boolean, + master_timeout: string, +======= +client.eql.search({ + index: string, + wait_for_completion_timeout: string, + keep_on_completion: boolean, + keep_alive: string, +>>>>>>> a064f0f3... Improve child performances (#1314) + body: object +}) +---- +link:{ref}/eql-search-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index to scope the operation + +<<<<<<< HEAD +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be returned in the body of the mappings. + +|`order` +|`number` - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) +======= +|`wait_for_completion_timeout` or `waitForCompletionTimeout` +|`string` - Specify the time that the request should block waiting for the final response +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`keep_on_completion` or `keepOnCompletion` +|`boolean` - Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) + +|`keep_alive` or `keepAlive` +|`string` - Update the time interval in which the results (partial or final) for this search will be available + +_Default:_ `5d` + +|`body` +|`object` - Eql request body. Use the `query` to limit the query scope. + +|=== + === exists [source,ts] @@ -1980,7 +4171,6 @@ link:{ref}/modules-scripting.html[Documentation] + client.exists({ id: string, index: string, - type: string, stored_fields: string | string[], preference: string, realtime: boolean, @@ -1990,7 +4180,7 @@ client.exists({ _source_excludes: string | string[], _source_includes: string | string[], version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' + version_type: 'internal' | 'external' | 'external_gte' }) ---- link:{ref}/docs-get.html[Documentation] + @@ -2003,11 +4193,6 @@ link:{ref}/docs-get.html[Documentation] + |`index` |`string` - The name of the index -|`type` -|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + - -WARNING: This parameter has been deprecated. - |`stored_fields` or `storedFields` |`string \| string[]` - A comma-separated list of stored fields to return in the response @@ -2036,7 +4221,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 |=== @@ -2056,7 +4241,7 @@ client.existsSource({ _source_excludes: string | string[], _source_includes: string | string[], version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' + version_type: 'internal' | 'external' | 'external_gte' }) ---- link:{ref}/docs-get.html[Documentation] + @@ -2098,7 +4283,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 |=== @@ -2106,10 +4291,19 @@ WARNING: This parameter has been deprecated. [source,ts] ---- +<<<<<<< HEAD +client.indices.rollover({ + alias: string, + new_index: string, + include_type_name: boolean, + timeout: string, + dry_run: boolean, + master_timeout: string, + wait_for_active_shards: string, +======= client.explain({ id: string, index: string, - type: string, analyze_wildcard: boolean, analyzer: string, default_operator: 'AND' | 'OR', @@ -2122,6 +4316,7 @@ client.explain({ _source: string | string[], _source_excludes: string | string[], _source_includes: string | string[], +>>>>>>> a064f0f3... Improve child performances (#1314) body: object }) ---- @@ -2134,13 +4329,16 @@ link:{ref}/search-explain.html[Documentation] + |`index` |`string` - The name of the index -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. +<<<<<<< HEAD +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be included in the body of the mappings. +|`timeout` +|`string` - Explicit operation timeout +======= |`analyze_wildcard` or `analyzeWildcard` |`boolean` - Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) +>>>>>>> a064f0f3... Improve child performances (#1314) |`analyzer` |`string` - The analyzer for the query string query @@ -2229,7 +4427,14 @@ _Default:_ `open` client.get({ id: string, index: string, - type: string, +<<<<<<< HEAD + target: string, + copy_settings: boolean, + timeout: string, + master_timeout: string, + wait_for_active_shards: string, + body: object +======= stored_fields: string | string[], preference: string, realtime: boolean, @@ -2239,7 +4444,8 @@ client.get({ _source_excludes: string | string[], _source_includes: string | string[], version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' + version_type: 'internal' | 'external' | 'external_gte' +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/docs-get.html[Documentation] + @@ -2249,13 +4455,16 @@ link:{ref}/docs-get.html[Documentation] + |`id` |`string` - The document ID +<<<<<<< HEAD +|`copy_settings` or `copySettings` +|`boolean` - whether or not to copy settings from the source index (defaults to false) + +|`timeout` +|`string` - Explicit operation timeout +======= |`index` |`string` - The name of the index - -|`type` -|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + - -WARNING: This parameter has been deprecated. +>>>>>>> a064f0f3... Improve child performances (#1314) |`stored_fields` or `storedFields` |`string \| string[]` - A comma-separated list of stored fields to return in the response @@ -2285,7 +4494,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 |=== @@ -2313,9 +4522,39 @@ link:{ref}/modules-scripting.html[Documentation] + *Stability:* experimental [source,ts] ---- +<<<<<<< HEAD +client.indices.split({ + index: string, + target: string, + copy_settings: boolean, + timeout: string, + master_timeout: string, + wait_for_active_shards: string, + body: object +}) +---- +link:{ref}/indices-split-index.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the source index to split + +|`target` +|`string` - The name of the target index to split into + +|`copy_settings` or `copySettings` +|`boolean` - whether or not to copy settings from the source index (defaults to false) + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master +======= client.getScriptContext() ---- link:https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html[Documentation] + +>>>>>>> a064f0f3... Improve child performances (#1314) === getScriptLanguages @@ -2334,7 +4573,6 @@ link:{ref}/modules-scripting.html[Documentation] + client.getSource({ id: string, index: string, - type: string, preference: string, realtime: boolean, refresh: boolean, @@ -2343,7 +4581,7 @@ client.getSource({ _source_excludes: string | string[], _source_includes: string | string[], version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' + version_type: 'internal' | 'external' | 'external_gte' }) ---- link:{ref}/docs-get.html[Documentation] + @@ -2355,11 +4593,6 @@ link:{ref}/docs-get.html[Documentation] + |`index` |`string` - The name of the index -|`type` -|`string` - The type of the document; deprecated and optional starting with 7.0 + - -WARNING: This parameter has been deprecated. - |`preference` |`string` - Specify the node or shard the operation should be performed on (default: random) @@ -2385,10 +4618,193 @@ 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 |=== +=== graph.explore + +[source,ts] +---- +client.graph.explore({ + index: string | string[], + routing: string, + timeout: string, + body: object +}) +---- +link:{ref}/graph-explore-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`body` +|`object` - Graph Query DSL + +|=== + +=== ilm.deleteLifecycle + +[source,ts] +---- +client.ilm.deleteLifecycle({ + policy: string +}) +---- +link:{ref}/ilm-delete-lifecycle.html[Documentation] + +[cols=2*] +|=== +|`policy` +|`string` - The name of the index lifecycle policy + +|=== + +=== ilm.explainLifecycle + +[source,ts] +---- +client.ilm.explainLifecycle({ + index: string, + only_managed: boolean, + only_errors: boolean +}) +---- +link:{ref}/ilm-explain-lifecycle.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index to explain + +|`only_managed` or `onlyManaged` +|`boolean` - filters the indices included in the response to ones managed by ILM + +|`only_errors` or `onlyErrors` +|`boolean` - filters the indices included in the response to ones in an ILM error state, implies only_managed + +|=== + +=== ilm.getLifecycle + +[source,ts] +---- +client.ilm.getLifecycle({ + policy: string +}) +---- +link:{ref}/ilm-get-lifecycle.html[Documentation] + +[cols=2*] +|=== +|`policy` +|`string` - The name of the index lifecycle policy + +|=== + +=== ilm.getStatus + +[source,ts] +---- +client.ilm.getStatus() +---- +link:{ref}/ilm-get-status.html[Documentation] + + + +=== ilm.moveToStep + +[source,ts] +---- +client.ilm.moveToStep({ + index: string, + body: object +}) +---- +link:{ref}/ilm-move-to-step.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index whose lifecycle step is to change + +|`body` +|`object` - The new lifecycle step to move to + +|=== + +=== ilm.putLifecycle + +[source,ts] +---- +client.ilm.putLifecycle({ + policy: string, + body: object +}) +---- +link:{ref}/ilm-put-lifecycle.html[Documentation] + +[cols=2*] +|=== +|`policy` +|`string` - The name of the index lifecycle policy + +|`body` +|`object` - The lifecycle policy definition to register + +|=== + +=== ilm.removePolicy + +[source,ts] +---- +client.ilm.removePolicy({ + index: string +}) +---- +link:{ref}/ilm-remove-policy.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index to remove policy on + +|=== + +=== ilm.retry + +[source,ts] +---- +client.ilm.retry({ + index: string +}) +---- +link:{ref}/ilm-retry-policy.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the indices (comma-separated) whose failed lifecycle step is to be retry + +|=== + +=== ilm.start + +[source,ts] +---- +client.ilm.start() +---- +link:{ref}/ilm-start.html[Documentation] + + + +=== ilm.stop + +[source,ts] +---- +client.ilm.stop() +---- +link:{ref}/ilm-stop.html[Documentation] + + + === index [source,ts] @@ -2396,7 +4812,6 @@ WARNING: This parameter has been deprecated. client.index({ id: string, index: string, - type: string, wait_for_active_shards: string, op_type: 'index' | 'create', refresh: 'true' | 'false' | 'wait_for', @@ -2407,6 +4822,7 @@ client.index({ if_seq_no: number, if_primary_term: number, pipeline: string, + require_alias: boolean, body: object }) ---- @@ -2419,11 +4835,6 @@ link:{ref}/docs-index_.html[Documentation] + |`index` |`string` - The name of the index -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - |`wait_for_active_shards` or `waitForActiveShards` |`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) @@ -2454,6 +4865,9 @@ WARNING: This parameter has been deprecated. |`pipeline` |`string` - The pipeline id to preprocess incoming documents with +|`require_alias` or `requireAlias` +|`boolean` - When true, requires destination to be an alias. Default is false + |`body` |`object` - The document @@ -2463,6 +4877,20 @@ WARNING: This parameter has been deprecated. [source,ts] ---- +<<<<<<< HEAD +client.mget({ + index: string, + type: string, + stored_fields: string | string[], + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + body: object +======= client.indices.addBlock({ index: string | string[], block: string, @@ -2471,6 +4899,7 @@ client.indices.addBlock({ ignore_unavailable: boolean, allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/index-modules-blocks.html[Documentation] + @@ -2479,8 +4908,18 @@ link:{ref}/index-modules-blocks.html[Documentation] + |`index` |`string \| string[]` - A comma separated list of indices to add a block to +<<<<<<< HEAD +|`type` +|`string` - The type of the document + + +WARNING: This parameter has been deprecated. + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return in the response +======= |`block` |`string` - The block to add (one of read, write, read_only or metadata) +>>>>>>> a064f0f3... Improve child performances (#1314) |`timeout` |`string` - Explicit operation timeout @@ -2516,7 +4955,11 @@ link:{ref}/indices-analyze.html[Documentation] + |`string` - The name of the index to scope the operation |`body` +<<<<<<< HEAD +|`object` - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. +======= |`object` - Define analyzer/tokenizer parameters and the text on which the analysis should be performed +>>>>>>> a064f0f3... Improve child performances (#1314) |=== @@ -2526,6 +4969,17 @@ link:{ref}/indices-analyze.html[Documentation] + ---- client.indices.clearCache({ index: string | string[], +<<<<<<< HEAD + type: string | string[], + search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', + max_concurrent_searches: number, + typed_keys: boolean, + pre_filter_shard_size: number, + max_concurrent_shard_requests: number, + rest_total_hits_as_int: boolean, + ccs_minimize_roundtrips: boolean, + body: object +======= fielddata: boolean, fields: string | string[], query: boolean, @@ -2533,13 +4987,24 @@ client.indices.clearCache({ allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', request: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/indices-clearcache.html[Documentation] + [cols=2*] |=== |`index` +<<<<<<< HEAD +|`string \| string[]` - A comma-separated list of index names to use as default + +|`type` +|`string \| string[]` - A comma-separated list of document types to use as default + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type +======= |`string \| string[]` - A comma-separated list of index name to limit the operation +>>>>>>> a064f0f3... Improve child performances (#1314) |`fielddata` |`boolean` - Clear field data @@ -2569,12 +5034,23 @@ _Default:_ `open` [source,ts] ---- +<<<<<<< HEAD +client.msearchTemplate({ + index: string | string[], + type: string | string[], + search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', + typed_keys: boolean, + max_concurrent_searches: number, + rest_total_hits_as_int: boolean, + ccs_minimize_roundtrips: boolean, +======= client.indices.clone({ index: string, target: string, timeout: string, master_timeout: string, wait_for_active_shards: string, +>>>>>>> a064f0f3... Improve child performances (#1314) body: object }) ---- @@ -2582,7 +5058,17 @@ link:{ref}/indices-clone-index.html[Documentation] + [cols=2*] |=== |`index` +<<<<<<< HEAD +|`string \| string[]` - A comma-separated list of index names to use as default + +|`type` +|`string \| string[]` - A comma-separated list of document types to use as default + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type +======= |`string` - The name of the source index to clone +>>>>>>> a064f0f3... Improve child performances (#1314) |`target` |`string` - The name of the target index to clone into @@ -2605,6 +5091,24 @@ link:{ref}/indices-clone-index.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.mtermvectors({ + index: string, + type: string, + ids: string | string[], + term_statistics: boolean, + field_statistics: boolean, + fields: string | string[], + offsets: boolean, + positions: boolean, + payloads: boolean, + preference: string, + routing: string, + realtime: boolean, + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force', + body: object +======= client.indices.close({ index: string | string[], timeout: string, @@ -2613,13 +5117,46 @@ client.indices.close({ allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', wait_for_active_shards: string +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/indices-open-close.html[Documentation] + [cols=2*] |=== |`index` +<<<<<<< HEAD +|`string` - The index in which the document resides. + +|`type` +|`string` - The type of the document. + +|`ids` +|`string \| string[]` - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body + +|`term_statistics` or `termStatistics` +|`boolean` - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`field_statistics` or `fieldStatistics` +|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`fields` +|`string \| string[]` - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`offsets` +|`boolean` - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`positions` +|`boolean` - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`payloads` +|`boolean` - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` +======= |`string \| string[]` - A comma separated list of indices to close +>>>>>>> a064f0f3... Improve child performances (#1314) |`timeout` |`string` - Explicit operation timeout @@ -2633,9 +5170,14 @@ link:{ref}/indices-open-close.html[Documentation] + |`allow_no_indices` or `allowNoIndices` |`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= |`expand_wildcards` or `expandWildcards` |`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + _Default:_ `open` +>>>>>>> a064f0f3... Improve child performances (#1314) |`wait_for_active_shards` or `waitForActiveShards` |`string` - Sets the number of active shards to wait for before the operation returns. @@ -2648,7 +5190,6 @@ _Default:_ `open` ---- client.indices.create({ index: string, - include_type_name: boolean, wait_for_active_shards: string, timeout: string, master_timeout: string, @@ -2661,9 +5202,6 @@ link:{ref}/indices-create-index.html[Documentation] + |`index` |`string` - The name of the index -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be expected in the body of the mappings. - |`wait_for_active_shards` or `waitForActiveShards` |`string` - Set the number of active shards to wait for before the operation returns. @@ -2678,6 +5216,38 @@ link:{ref}/indices-create-index.html[Documentation] + |=== +=== indices.createDataStream + +[source,ts] +---- +client.indices.createDataStream({ + name: string +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the data stream + +|=== + +=== indices.dataStreamsStats + +[source,ts] +---- +client.indices.dataStreamsStats({ + name: string | string[] +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - A comma-separated list of data stream names; use `_all` or empty string to perform the operation on all data streams + +|=== + === indices.delete [source,ts] @@ -2743,6 +5313,22 @@ link:{ref}/indices-aliases.html[Documentation] + |=== +=== indices.deleteDataStream + +[source,ts] +---- +client.indices.deleteDataStream({ + name: string | string[] +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - A comma-separated list of data streams to delete; use `*` to delete all data streams + +|=== + === indices.deleteIndexTemplate *Stability:* experimental [source,ts] @@ -2968,11 +5554,58 @@ _Default:_ `open` ---- client.indices.flush({ index: string | string[], +<<<<<<< HEAD + type: string | string[], + analyzer: string, + analyze_wildcard: boolean, + ccs_minimize_roundtrips: boolean, + default_operator: 'AND' | 'OR', + df: string, + explain: boolean, + stored_fields: string | string[], + docvalue_fields: string | string[], + from: number, +======= force: boolean, wait_if_ongoing: boolean, +>>>>>>> a064f0f3... Improve child performances (#1314) ignore_unavailable: boolean, allow_no_indices: boolean, +<<<<<<< HEAD + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + preference: string, + q: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + size: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + suggest_field: string, + suggest_mode: 'missing' | 'popular' | 'always', + suggest_size: number, + suggest_text: string, + timeout: string, + track_scores: boolean, + track_total_hits: boolean, + allow_partial_search_results: boolean, + typed_keys: boolean, + version: boolean, + seq_no_primary_term: boolean, + request_cache: boolean, + batched_reduce_size: number, + max_concurrent_shard_requests: number, + pre_filter_shard_size: number, + rest_total_hits_as_int: boolean, + body: object +======= expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/indices-flush.html[Documentation] + @@ -2981,8 +5614,16 @@ link:{ref}/indices-flush.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names; use `_all` or empty string for all indices +<<<<<<< HEAD +|`type` +|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`analyzer` +|`string` - The analyzer to use for the query string +======= |`force` |`boolean` - Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) +>>>>>>> a064f0f3... Improve child performances (#1314) |`wait_if_ongoing` or `waitIfOngoing` |`boolean` - If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. @@ -2999,35 +5640,6 @@ _Default:_ `open` |=== -=== indices.flushSynced - -[source,ts] ----- -client.indices.flushSynced({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'none' | 'all' -}) ----- -link:{ref}/indices-synced-flush-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string for all indices - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - === indices.forcemerge [source,ts] @@ -3069,13 +5681,53 @@ _Default:_ `open` |=== +=== indices.freeze + +[source,ts] +---- +client.indices.freeze({ + index: string, + timeout: string, + master_timeout: string, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + wait_for_active_shards: string +}) +---- +link:{ref}/freeze-index-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index to freeze + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `closed` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of active shards to wait for before the operation returns. + +|=== + === indices.get [source,ts] ---- client.indices.get({ index: string | string[], - include_type_name: boolean, local: boolean, ignore_unavailable: boolean, allow_no_indices: boolean, @@ -3091,9 +5743,6 @@ link:{ref}/indices-get-index.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names -|`include_type_name` or `includeTypeName` -|`boolean` - Whether to add the type name to the response (default: false) - |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) @@ -3116,7 +5765,12 @@ _Default:_ `open` |`master_timeout` or `masterTimeout` |`string` - Specify timeout for connection to master +<<<<<<< HEAD +|`track_total_hits` or `trackTotalHits` +|`boolean` - Indicate if the number of documents that match the query should be tracked +======= |=== +>>>>>>> a064f0f3... Improve child performances (#1314) === indices.getAlias @@ -3155,6 +5809,22 @@ _Default:_ `all` |=== +=== indices.getDataStream + +[source,ts] +---- +client.indices.getDataStream({ + name: string | string[] +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - A comma-separated list of data streams to get; use `*` to get all data streams + +|=== + === indices.getFieldMapping [source,ts] @@ -3162,8 +5832,6 @@ _Default:_ `all` client.indices.getFieldMapping({ fields: string | string[], index: string | string[], - type: string | string[], - include_type_name: boolean, include_defaults: boolean, ignore_unavailable: boolean, allow_no_indices: boolean, @@ -3180,14 +5848,6 @@ link:{ref}/indices-get-field-mapping.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names -|`type` -|`string \| string[]` - A comma-separated list of document types + - -WARNING: This parameter has been deprecated. - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be returned in the body of the mappings. - |`include_defaults` or `includeDefaults` |`boolean` - Whether the default mapping values should be returned as well @@ -3241,7 +5901,6 @@ link:{ref}/indices-templates.html[Documentation] + client.indices.getMapping({ index: string | string[], type: string | string[], - include_type_name: boolean, ignore_unavailable: boolean, allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', @@ -3256,12 +5915,7 @@ link:{ref}/indices-get-mapping.html[Documentation] + |`string \| string[]` - A comma-separated list of index names |`type` -|`string \| string[]` - A comma-separated list of document types + - -WARNING: This parameter has been deprecated. - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether to add the type name to the response (default: false) +|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -3338,7 +5992,6 @@ _Default:_ `all` ---- client.indices.getTemplate({ name: string | string[], - include_type_name: boolean, flat_settings: boolean, master_timeout: string, local: boolean @@ -3350,9 +6003,6 @@ link:{ref}/indices-templates.html[Documentation] + |`name` |`string \| string[]` - The comma separated names of the index templates -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be returned in the body of the mappings. - |`flat_settings` or `flatSettings` |`boolean` - Return settings in flat format (default: false) @@ -3438,12 +6088,19 @@ _Default:_ `closed` [source,ts] ---- +<<<<<<< HEAD +client.snapshot.delete({ + repository: string, + snapshot: string, + master_timeout: string +======= client.indices.putAlias({ index: string | string[], name: string, timeout: string, master_timeout: string, body: object +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/indices-aliases.html[Documentation] + @@ -3452,11 +6109,16 @@ link:{ref}/indices-aliases.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. +<<<<<<< HEAD +|`snapshot` +|`string` - A snapshot name +======= |`name` |`string` - The name of the alias to be created or updated |`timeout` |`string` - Explicit timestamp for the document +>>>>>>> a064f0f3... Improve child performances (#1314) |`master_timeout` or `masterTimeout` |`string` - Specify timeout for connection to master @@ -3504,8 +6166,6 @@ link:{ref}/indices-templates.html[Documentation] + ---- client.indices.putMapping({ index: string | string[], - type: string, - include_type_name: boolean, timeout: string, master_timeout: string, ignore_unavailable: boolean, @@ -3521,14 +6181,6 @@ link:{ref}/indices-put-mapping.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. -|`type` -|`string` - The name of the document type + - -WARNING: This parameter has been deprecated. - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be expected in the body of the mappings. - |`timeout` |`string` - Explicit operation timeout @@ -3608,7 +6260,6 @@ _Default:_ `open` ---- client.indices.putTemplate({ name: string, - include_type_name: boolean, order: number, create: boolean, master_timeout: string, @@ -3621,9 +6272,6 @@ link:{ref}/indices-templates.html[Documentation] + |`name` |`string` - The name of the template -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be returned in the body of the mappings. - |`order` |`number` - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) @@ -3691,6 +6339,35 @@ _Default:_ `open` |=== +=== indices.reloadSearchAnalyzers + +[source,ts] +---- +client.indices.reloadSearchAnalyzers({ + index: string | string[], + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +}) +---- +link:{ref}/indices-reload-analyzers.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to reload analyzers for + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|=== + === indices.resolveIndex *Stability:* experimental [source,ts] @@ -3719,7 +6396,6 @@ _Default:_ `open` client.indices.rollover({ alias: string, new_index: string, - include_type_name: boolean, timeout: string, dry_run: boolean, master_timeout: string, @@ -3736,9 +6412,6 @@ link:{ref}/indices-rollover-index.html[Documentation] + |`new_index` or `newIndex` |`string` - The name of the rollover index -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be included in the body of the mappings. - |`timeout` |`string` - Explicit operation timeout @@ -3760,19 +6433,55 @@ link:{ref}/indices-rollover-index.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.termvectors({ + index: string, + id: string, + type: string, + term_statistics: boolean, + field_statistics: boolean, + fields: string | string[], + offsets: boolean, + positions: boolean, + payloads: boolean, + preference: string, + routing: string, + realtime: boolean, + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force', + body: object +======= client.indices.segments({ index: string | string[], ignore_unavailable: boolean, allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', verbose: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/indices-segments.html[Documentation] + [cols=2*] |=== |`index` +<<<<<<< HEAD +|`string` - The index in which the document resides. + +|`id` +|`string` - The id of the document, when not specified a doc param should be supplied. + +|`type` +|`string` - The type of the document. + +|`term_statistics` or `termStatistics` +|`boolean` - Specifies if total term frequency and document frequency should be returned. + +|`field_statistics` or `fieldStatistics` +|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + +_Default:_ `true` +======= |`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +>>>>>>> a064f0f3... Improve child performances (#1314) |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -3810,8 +6519,13 @@ link:{ref}/indices-shards-stores.html[Documentation] + |`status` |`string \| string[]` - A comma-separated list of statuses used to filter on shards to get store information for +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) +>>>>>>> a064f0f3... Improve child performances (#1314) |`allow_no_indices` or `allowNoIndices` |`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -3829,10 +6543,14 @@ _Default:_ `open` client.indices.shrink({ index: string, target: string, - copy_settings: boolean, timeout: string, +<<<<<<< HEAD + if_seq_no: number, + if_primary_term: number, +======= master_timeout: string, wait_for_active_shards: string, +>>>>>>> 3db1bed4... Improve child performances (#1314) body: object }) ---- @@ -3845,9 +6563,6 @@ link:{ref}/indices-shrink-index.html[Documentation] + |`target` |`string` - The name of the target index to shrink into -|`copy_settings` or `copySettings` -|`boolean` - whether or not to copy settings from the source index (defaults to false) - |`timeout` |`string` - Explicit operation timeout @@ -3860,17 +6575,76 @@ link:{ref}/indices-shrink-index.html[Documentation] + |`body` |`object` - The configuration for the target index (`settings` and `aliases`) +<<<<<<< HEAD +|`timeout` +|`string` - Explicit operation timeout + +|`if_seq_no` or `ifSeqNo` +|`number` - only perform the update operation if the last operation that has changed the document has the specified sequence number + +|`if_primary_term` or `ifPrimaryTerm` +|`number` - only perform the update operation if the last operation that has changed the document has the specified primary term + +|`body` +|`object` - The request definition requires either `script` or partial `doc` + |=== +=== updateByQuery +======= +|=== +>>>>>>> 3db1bed4... Improve child performances (#1314) + === indices.simulateIndexTemplate *Stability:* experimental [source,ts] ---- +<<<<<<< HEAD +client.updateByQuery({ + index: string | string[], + type: string | string[], + analyzer: string, + analyze_wildcard: boolean, + default_operator: 'AND' | 'OR', + df: string, + from: number, + ignore_unavailable: boolean, + allow_no_indices: boolean, + conflicts: 'abort' | 'proceed', + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + pipeline: string, + preference: string, + q: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + search_timeout: string, + size: number, + max_docs: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + version: boolean, + version_type: boolean, + request_cache: boolean, + refresh: boolean, + timeout: string, + wait_for_active_shards: string, + scroll_size: number, + wait_for_completion: boolean, + requests_per_second: number, + slices: number|string, +======= client.indices.simulateIndexTemplate({ name: string, create: boolean, cause: string, master_timeout: string, +>>>>>>> a064f0f3... Improve child performances (#1314) body: object }) ---- @@ -3880,8 +6654,16 @@ link:{ref}/indices-templates.html[Documentation] + |`name` |`string` - The name of the index (it must be a concrete index name) +<<<<<<< HEAD +|`type` +|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`analyzer` +|`string` - The analyzer to use for the query string +======= |`create` |`boolean` - Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one +>>>>>>> a064f0f3... Improve child performances (#1314) |`cause` |`string` - User defined reason for dry-run creating the new template for simulation purposes @@ -3933,7 +6715,6 @@ link:{ref}/indices-templates.html[Documentation] + client.indices.split({ index: string, target: string, - copy_settings: boolean, timeout: string, master_timeout: string, wait_for_active_shards: string, @@ -3949,9 +6730,6 @@ link:{ref}/indices-split-index.html[Documentation] + |`target` |`string` - The name of the target index to split into -|`copy_settings` or `copySettings` -|`boolean` - whether or not to copy settings from the source index (defaults to false) - |`timeout` |`string` - Explicit operation timeout @@ -3961,8 +6739,16 @@ link:{ref}/indices-split-index.html[Documentation] + |`wait_for_active_shards` or `waitForActiveShards` |`string` - Set the number of active shards to wait for on the shrunken index before the operation returns. +<<<<<<< HEAD +|`size` +|`number` - Deprecated, please use `max_docs` instead + +|`max_docs` or `maxDocs` +|`number` - Maximum number of documents to process (default: all documents) +======= |`body` |`object` - The configuration for the target index (`settings` and `aliases`) +>>>>>>> a064f0f3... Improve child performances (#1314) |=== @@ -4029,6 +6815,47 @@ _Default:_ `true` |=== +=== indices.unfreeze + +[source,ts] +---- +client.indices.unfreeze({ + index: string, + timeout: string, + master_timeout: string, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + wait_for_active_shards: string +}) +---- +link:{ref}/unfreeze-index-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index to unfreeze + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `closed` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of active shards to wait for before the operation returns. + +|=== + === indices.updateAliases [source,ts] @@ -4102,6 +6929,29 @@ client.indices.validateQuery({ allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', q: string, +<<<<<<< HEAD + routing: string | string[], + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + size: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + suggest_field: string, + suggest_mode: 'missing' | 'popular' | 'always', + suggest_size: number, + suggest_text: string, + timeout: string, + track_scores: boolean, + track_total_hits: boolean, + allow_partial_search_results: boolean, + typed_keys: boolean, + version: boolean, + seq_no_primary_term: boolean, + max_concurrent_shard_requests: number, +======= analyzer: string, analyze_wildcard: boolean, default_operator: 'AND' | 'OR', @@ -4109,6 +6959,7 @@ client.indices.validateQuery({ lenient: boolean, rewrite: boolean, all_shards: boolean, +>>>>>>> a064f0f3... Improve child performances (#1314) body: object }) ---- @@ -4197,6 +7048,35 @@ link:{ref}/delete-pipeline-api.html[Documentation] + |`timeout` |`string` - Explicit operation timeout +<<<<<<< HEAD +|`track_scores` or `trackScores` +|`boolean` - Whether to calculate and return scores even if they are not used for sorting + +|`track_total_hits` or `trackTotalHits` +|`boolean` - Indicate if the number of documents that match the query should be tracked + +|`allow_partial_search_results` or `allowPartialSearchResults` +|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + +_Default:_ `true` + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`seq_no_primary_term` or `seqNoPrimaryTerm` +|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit + +|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` +|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + +_Default:_ `5` + +|`body` +|`object` - The search definition using the Query DSL + +======= +>>>>>>> a064f0f3... Improve child performances (#1314) |=== === ingest.getPipeline @@ -4280,2955 +7160,6 @@ link:{ref}/simulate-pipeline-api.html[Documentation] + |=== -=== mget - -[source,ts] ----- -client.mget({ - index: string, - type: string, - stored_fields: string | string[], - preference: string, - realtime: boolean, - refresh: boolean, - routing: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - body: object -}) ----- -link:{ref}/docs-multi-get.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return in the response - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`realtime` -|`boolean` - Specify whether to perform the operation in realtime or search mode - -|`refresh` -|`boolean` - Refresh the shard containing the document before performing the operation - -|`routing` -|`string` - Specific routing value - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`body` -|`object` - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. - -|=== - -=== msearch - -[source,ts] ----- -client.msearch({ - index: string | string[], - type: string | string[], - search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', - max_concurrent_searches: number, - typed_keys: boolean, - pre_filter_shard_size: number, - max_concurrent_shard_requests: number, - rest_total_hits_as_int: boolean, - ccs_minimize_roundtrips: boolean, - body: object -}) ----- -link:{ref}/search-multi-search.html[Documentation] + -{jsclient}/msearch_examples.html[Code Example] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to use as default - -|`type` -|`string \| string[]` - A comma-separated list of document types to use as default - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type - -|`max_concurrent_searches` or `maxConcurrentSearches` -|`number` - Controls the maximum number of concurrent searches the multi search api will execute - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`pre_filter_shard_size` or `preFilterShardSize` -|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. - -|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` -|`number` - The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + -_Default:_ `5` - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`body` -|`object` - The request definitions (metadata-search request definition pairs), separated by newlines - -|=== - -=== msearchTemplate - -[source,ts] ----- -client.msearchTemplate({ - index: string | string[], - type: string | string[], - search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', - typed_keys: boolean, - max_concurrent_searches: number, - rest_total_hits_as_int: boolean, - ccs_minimize_roundtrips: boolean, - body: object -}) ----- -link:{ref}/search-multi-search.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to use as default - -|`type` -|`string \| string[]` - A comma-separated list of document types to use as default - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`max_concurrent_searches` or `maxConcurrentSearches` -|`number` - Controls the maximum number of concurrent searches the multi search api will execute - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`body` -|`object` - The request definitions (metadata-search request definition pairs), separated by newlines - -|=== - -=== mtermvectors - -[source,ts] ----- -client.mtermvectors({ - index: string, - type: string, - ids: string | string[], - term_statistics: boolean, - field_statistics: boolean, - fields: string | string[], - offsets: boolean, - positions: boolean, - payloads: boolean, - preference: string, - routing: string, - realtime: boolean, - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force', - body: object -}) ----- -link:{ref}/docs-multi-termvectors.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The index in which the document resides. - -|`type` -|`string` - The type of the document. - -|`ids` -|`string \| string[]` - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body - -|`term_statistics` or `termStatistics` -|`boolean` - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`field_statistics` or `fieldStatistics` -|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`fields` -|`string \| string[]` - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`offsets` -|`boolean` - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`positions` -|`boolean` - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`payloads` -|`boolean` - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`routing` -|`string` - Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`realtime` -|`boolean` - Specifies if requests are real-time as opposed to near-real-time (default: true). - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|`body` -|`object` - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. - -|=== - -=== nodes.hotThreads - -[source,ts] ----- -client.nodes.hotThreads({ - node_id: string | string[], - interval: string, - snapshots: number, - threads: number, - ignore_idle_threads: boolean, - type: 'cpu' | 'wait' | 'block', - timeout: string -}) ----- -link:{ref}/cluster-nodes-hot-threads.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`interval` -|`string` - The interval for the second sampling of threads - -|`snapshots` -|`number` - Number of samples of thread stacktrace (default: 10) - -|`threads` -|`number` - Specify the number of threads to provide information for (default: 3) - -|`ignore_idle_threads` or `ignoreIdleThreads` -|`boolean` - Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) - -|`type` -|`'cpu' \| 'wait' \| 'block'` - The type to sample (default: cpu) - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== nodes.info - -[source,ts] ----- -client.nodes.info({ - node_id: string | string[], - metric: string | string[], - flat_settings: boolean, - timeout: string -}) ----- -link:{ref}/cluster-nodes-info.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`metric` -|`string \| string[]` - A comma-separated list of metrics you wish returned. Leave empty to return all. - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== nodes.reloadSecureSettings - -[source,ts] ----- -client.nodes.reloadSecureSettings({ - node_id: string | string[], - timeout: string, - body: object -}) ----- -link:{ref}/secure-settings.html#reloadable-secure-settings[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. - -|`timeout` -|`string` - Explicit operation timeout - -|`body` -|`object` - An object containing the password for the elasticsearch keystore - -|=== - -=== nodes.stats - -[source,ts] ----- -client.nodes.stats({ - node_id: string | string[], - metric: string | string[], - index_metric: string | string[], - completion_fields: string | string[], - fielddata_fields: string | string[], - fields: string | string[], - groups: boolean, - level: 'indices' | 'node' | 'shards', - types: string | string[], - timeout: string, - include_segment_file_sizes: boolean -}) ----- -link:{ref}/cluster-nodes-stats.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`metric` -|`string \| string[]` - Limit the information returned to the specified metrics - -|`index_metric` or `indexMetric` -|`string \| string[]` - Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. - -|`completion_fields` or `completionFields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) - -|`fielddata_fields` or `fielddataFields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` index metric (supports wildcards) - -|`fields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) - -|`groups` -|`boolean` - A comma-separated list of search groups for `search` index metric - -|`level` -|`'indices' \| 'node' \| 'shards'` - Return indices stats aggregated at index, node or shard level + -_Default:_ `node` - -|`types` -|`string \| string[]` - A comma-separated list of document types for the `indexing` index metric - -|`timeout` -|`string` - Explicit operation timeout - -|`include_segment_file_sizes` or `includeSegmentFileSizes` -|`boolean` - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) - -|=== - -=== nodes.usage - -[source,ts] ----- -client.nodes.usage({ - node_id: string | string[], - metric: string | string[], - timeout: string -}) ----- -link:{ref}/cluster-nodes-usage.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`metric` -|`string \| string[]` - Limit the information returned to the specified metrics - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== ping - -[source,ts] ----- -client.ping() ----- -link:{ref}/index.html[Documentation] + - - -=== putScript - -[source,ts] ----- -client.putScript({ - id: string, - context: string, - timeout: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/modules-scripting.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Script ID - -|`context` -|`string` - Script context - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - The document - -|=== - -=== rankEval -*Stability:* experimental -[source,ts] ----- -client.rankEval({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - body: object -}) ----- -link:{ref}/search-rank-eval.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`body` -|`object` - The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. - -|=== - -=== reindex - -[source,ts] ----- -client.reindex({ - refresh: boolean, - timeout: string, - wait_for_active_shards: string, - wait_for_completion: boolean, - requests_per_second: number, - scroll: string, - slices: number|string, - max_docs: number, - body: object -}) ----- -link:{ref}/docs-reindex.html[Documentation] + -{jsclient}/reindex_examples.html[Code Example] + -[cols=2*] -|=== -|`refresh` -|`boolean` - Should the affected indexes be refreshed? - -|`timeout` -|`string` - Time each individual bulk request should wait for shards that are unavailable. + -_Default:_ `1m` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request should block until the reindex is complete. + -_Default:_ `true` - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. - -|`scroll` -|`string` - Control how long to keep the search context alive + -_Default:_ `5m` - -|`slices` -|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + -_Default:_ `1` - -|`max_docs` or `maxDocs` -|`number` - Maximum number of documents to process (default: all documents) - -|`body` -|`object` - The search definition using the Query DSL and the prototype for the index request. - -|=== - -=== reindexRethrottle - -[source,ts] ----- -client.reindexRethrottle({ - task_id: string, - requests_per_second: number -}) ----- -link:{ref}/docs-reindex.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - The task id to rethrottle - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. - -|=== - -=== renderSearchTemplate - -[source,ts] ----- -client.renderSearchTemplate({ - id: string, - body: object -}) ----- -link:{ref}/search-template.html#_validating_templates[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The id of the stored search template - -|`body` -|`object` - The search definition template and its params - -|=== - -=== scriptsPainlessExecute -*Stability:* experimental -[source,ts] ----- -client.scriptsPainlessExecute({ - body: object -}) ----- -link:https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The script to execute - -|=== - -=== scroll - -[source,ts] ----- -client.scroll({ - scroll_id: string, - scroll: string, - rest_total_hits_as_int: boolean, - body: object -}) ----- -link:{ref}/search-request-body.html#request-body-search-scroll[Documentation] + -{jsclient}/scroll_examples.html[Code Example] + -[cols=2*] -|=== -|`scroll_id` or `scrollId` -|`string` - The scroll ID + - -WARNING: This parameter has been deprecated. - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`body` -|`object` - The scroll ID if not passed by URL or query parameter. - -|=== - -=== search - -[source,ts] ----- -client.search({ - index: string | string[], - type: string | string[], - analyzer: string, - analyze_wildcard: boolean, - ccs_minimize_roundtrips: boolean, - default_operator: 'AND' | 'OR', - df: string, - explain: boolean, - stored_fields: string | string[], - docvalue_fields: string | string[], - from: number, - ignore_unavailable: boolean, - ignore_throttled: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - lenient: boolean, - preference: string, - q: string, - routing: string | string[], - scroll: string, - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - size: number, - sort: string | string[], - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - terminate_after: number, - stats: string | string[], - suggest_field: string, - suggest_mode: 'missing' | 'popular' | 'always', - suggest_size: number, - suggest_text: string, - timeout: string, - track_scores: boolean, - track_total_hits: boolean, - allow_partial_search_results: boolean, - typed_keys: boolean, - version: boolean, - seq_no_primary_term: boolean, - request_cache: boolean, - batched_reduce_size: number, - max_concurrent_shard_requests: number, - pre_filter_shard_size: number, - rest_total_hits_as_int: boolean, - body: object -}) ----- -link:{ref}/search-search.html[Documentation] + -{jsclient}/search_examples.html[Code Example] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`explain` -|`boolean` - Specify whether to return detailed information about score computation as part of a hit - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return as part of a hit - -|`docvalue_fields` or `docvalueFields` -|`string \| string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit - -|`from` -|`number` - Starting offset (default: 0) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`size` -|`number` - Number of hits to return (default: 10) - -|`sort` -|`string \| string[]` - A comma-separated list of : pairs - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`terminate_after` or `terminateAfter` -|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - -|`stats` -|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes - -|`suggest_field` or `suggestField` -|`string` - Specify which field to use for suggestions - -|`suggest_mode` or `suggestMode` -|`'missing' \| 'popular' \| 'always'` - Specify suggest mode + -_Default:_ `missing` - -|`suggest_size` or `suggestSize` -|`number` - How many suggestions to return in response - -|`suggest_text` or `suggestText` -|`string` - The source text for which the suggestions should be returned - -|`timeout` -|`string` - Explicit operation timeout - -|`track_scores` or `trackScores` -|`boolean` - Whether to calculate and return scores even if they are not used for sorting - -|`track_total_hits` or `trackTotalHits` -|`boolean` - Indicate if the number of documents that match the query should be tracked - -|`allow_partial_search_results` or `allowPartialSearchResults` -|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + -_Default:_ `true` - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`version` -|`boolean` - Specify whether to return document version as part of a hit - -|`seq_no_primary_term` or `seqNoPrimaryTerm` -|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit - -|`request_cache` or `requestCache` -|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting - -|`batched_reduce_size` or `batchedReduceSize` -|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + -_Default:_ `512` - -|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` -|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + -_Default:_ `5` - -|`pre_filter_shard_size` or `preFilterShardSize` -|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`body` -|`object` - The search definition using the Query DSL - -|=== - -=== searchShards - -[source,ts] ----- -client.searchShards({ - index: string | string[], - preference: string, - routing: string, - local: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/search-shards.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`routing` -|`string` - Specific routing value - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -=== searchTemplate - -[source,ts] ----- -client.searchTemplate({ - index: string | string[], - type: string | string[], - ignore_unavailable: boolean, - ignore_throttled: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - preference: string, - routing: string | string[], - scroll: string, - search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', - explain: boolean, - profile: boolean, - typed_keys: boolean, - rest_total_hits_as_int: boolean, - ccs_minimize_roundtrips: boolean, - body: object -}) ----- -link:{ref}/search-template.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type - -|`explain` -|`boolean` - Specify whether to return detailed information about score computation as part of a hit - -|`profile` -|`boolean` - Specify whether to profile the query execution - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`body` -|`object` - The search definition template and its params - -|=== - -=== snapshot.cleanupRepository - -[source,ts] ----- -client.snapshot.cleanupRepository({ - repository: string, - master_timeout: string, - timeout: string -}) ----- -link:{ref}/clean-up-snapshot-repo-api.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== snapshot.create - -[source,ts] ----- -client.snapshot.create({ - repository: string, - snapshot: string, - master_timeout: string, - wait_for_completion: boolean, - body: object -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string` - A snapshot name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should this request wait until the operation has completed before returning - -|`body` -|`object` - The snapshot definition - -|=== - -=== snapshot.createRepository - -[source,ts] ----- -client.snapshot.createRepository({ - repository: string, - master_timeout: string, - timeout: string, - verify: boolean, - body: object -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|`verify` -|`boolean` - Whether to verify the repository after creation - -|`body` -|`object` - The repository definition - -|=== - -=== snapshot.delete - -[source,ts] ----- -client.snapshot.delete({ - repository: string, - snapshot: string, - master_timeout: string -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string` - A snapshot name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|=== - -=== snapshot.deleteRepository - -[source,ts] ----- -client.snapshot.deleteRepository({ - repository: string | string[], - master_timeout: string, - timeout: string -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string \| string[]` - Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported. - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== snapshot.get - -[source,ts] ----- -client.snapshot.get({ - repository: string, - snapshot: string | string[], - master_timeout: string, - ignore_unavailable: boolean, - verbose: boolean -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string \| string[]` - A comma-separated list of snapshot names - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - -|`verbose` -|`boolean` - Whether to show verbose snapshot info or only show the basic info found in the repository index blob - -|=== - -=== snapshot.getRepository - -[source,ts] ----- -client.snapshot.getRepository({ - repository: string | string[], - master_timeout: string, - local: boolean -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string \| string[]` - A comma-separated list of repository names - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -=== snapshot.restore - -[source,ts] ----- -client.snapshot.restore({ - repository: string, - snapshot: string, - master_timeout: string, - wait_for_completion: boolean, - body: object -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string` - A snapshot name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should this request wait until the operation has completed before returning - -|`body` -|`object` - Details of what to restore - -|=== - -=== snapshot.status - -[source,ts] ----- -client.snapshot.status({ - repository: string, - snapshot: string | string[], - master_timeout: string, - ignore_unavailable: boolean -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string \| string[]` - A comma-separated list of snapshot names - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - -|=== - -=== snapshot.verifyRepository - -[source,ts] ----- -client.snapshot.verifyRepository({ - repository: string, - master_timeout: string, - timeout: string -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== tasks.cancel - -[source,ts] ----- -client.tasks.cancel({ - task_id: string, - nodes: string | string[], - actions: string | string[], - parent_task_id: string, - wait_for_completion: boolean -}) ----- -link:{ref}/tasks.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - Cancel the task with specified task id (node_id:task_number) - -|`nodes` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`actions` -|`string \| string[]` - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. - -|`parent_task_id` or `parentTaskId` -|`string` - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false - -|=== - -=== tasks.get - -[source,ts] ----- -client.tasks.get({ - task_id: string, - wait_for_completion: boolean, - timeout: string -}) ----- -link:{ref}/tasks.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - Return the task with specified id (node_id:task_number) - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Wait for the matching tasks to complete (default: false) - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== tasks.list - -[source,ts] ----- -client.tasks.list({ - nodes: string | string[], - actions: string | string[], - detailed: boolean, - parent_task_id: string, - wait_for_completion: boolean, - group_by: 'nodes' | 'parents' | 'none', - timeout: string -}) ----- -link:{ref}/tasks.html[Documentation] + -[cols=2*] -|=== -|`nodes` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`actions` -|`string \| string[]` - A comma-separated list of actions that should be returned. Leave empty to return all. - -|`detailed` -|`boolean` - Return detailed task information (default: false) - -|`parent_task_id` or `parentTaskId` -|`string` - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Wait for the matching tasks to complete (default: false) - -|`group_by` or `groupBy` -|`'nodes' \| 'parents' \| 'none'` - Group tasks by nodes or parent/child relationships + -_Default:_ `nodes` - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== termvectors - -[source,ts] ----- -client.termvectors({ - index: string, - id: string, - type: string, - term_statistics: boolean, - field_statistics: boolean, - fields: string | string[], - offsets: boolean, - positions: boolean, - payloads: boolean, - preference: string, - routing: string, - realtime: boolean, - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force', - body: object -}) ----- -link:{ref}/docs-termvectors.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The index in which the document resides. - -|`id` -|`string` - The id of the document, when not specified a doc param should be supplied. - -|`type` -|`string` - The type of the document. - -|`term_statistics` or `termStatistics` -|`boolean` - Specifies if total term frequency and document frequency should be returned. - -|`field_statistics` or `fieldStatistics` -|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + -_Default:_ `true` - -|`fields` -|`string \| string[]` - A comma-separated list of fields to return. - -|`offsets` -|`boolean` - Specifies if term offsets should be returned. + -_Default:_ `true` - -|`positions` -|`boolean` - Specifies if term positions should be returned. + -_Default:_ `true` - -|`payloads` -|`boolean` - Specifies if term payloads should be returned. + -_Default:_ `true` - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random). - -|`routing` -|`string` - Specific routing value. - -|`realtime` -|`boolean` - Specifies if request is real-time as opposed to near-real-time (default: true). - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|`body` -|`object` - Define parameters and or supply a document to get termvectors for. See documentation. - -|=== - -=== update - -[source,ts] ----- -client.update({ - id: string, - index: string, - type: string, - wait_for_active_shards: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - lang: string, - refresh: 'true' | 'false' | 'wait_for', - retry_on_conflict: number, - routing: string, - timeout: string, - if_seq_no: number, - if_primary_term: number, - body: object -}) ----- -link:{ref}/docs-update.html[Documentation] + -{jsclient}/update_examples.html[Code Example] + -[cols=2*] -|=== -|`id` -|`string` - Document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the update 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) - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`lang` -|`string` - The script language (default: painless) - -|`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. - -|`retry_on_conflict` or `retryOnConflict` -|`number` - Specify how many times should the operation be retried when a conflict occurs (default: 0) - -|`routing` -|`string` - Specific routing value - -|`timeout` -|`string` - Explicit operation timeout - -|`if_seq_no` or `ifSeqNo` -|`number` - only perform the update operation if the last operation that has changed the document has the specified sequence number - -|`if_primary_term` or `ifPrimaryTerm` -|`number` - only perform the update operation if the last operation that has changed the document has the specified primary term - -|`body` -|`object` - The request definition requires either `script` or partial `doc` - -|=== - -=== updateByQuery - -[source,ts] ----- -client.updateByQuery({ - index: string | string[], - type: string | string[], - analyzer: string, - analyze_wildcard: boolean, - default_operator: 'AND' | 'OR', - df: string, - from: number, - ignore_unavailable: boolean, - allow_no_indices: boolean, - conflicts: 'abort' | 'proceed', - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - lenient: boolean, - pipeline: string, - preference: string, - q: string, - routing: string | string[], - scroll: string, - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - search_timeout: string, - size: number, - max_docs: number, - sort: string | string[], - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - terminate_after: number, - stats: string | string[], - version: boolean, - version_type: boolean, - request_cache: boolean, - refresh: boolean, - timeout: string, - wait_for_active_shards: string, - scroll_size: number, - wait_for_completion: boolean, - requests_per_second: number, - slices: number|string, - body: object -}) ----- -link:{ref}/docs-update-by-query.html[Documentation] + -{jsclient}/update_by_query_examples.html[Code Example] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`from` -|`number` - Starting offset (default: 0) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`conflicts` -|`'abort' \| 'proceed'` - What to do when the update by query hits version conflicts? + -_Default:_ `abort` - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`pipeline` -|`string` - Ingest pipeline to set on index requests made by this action. (default: none) - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`search_timeout` or `searchTimeout` -|`string` - Explicit timeout for each search request. Defaults to no timeout. - -|`size` -|`number` - Deprecated, please use `max_docs` instead - -|`max_docs` or `maxDocs` -|`number` - Maximum number of documents to process (default: all documents) - -|`sort` -|`string \| string[]` - A comma-separated list of : pairs - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`terminate_after` or `terminateAfter` -|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - -|`stats` -|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes - -|`version` -|`boolean` - Specify whether to return document version as part of a hit - -|`version_type` or `versionType` -|`boolean` - Should the document increment the version number (internal) on hit or not (reindex) - -|`request_cache` or `requestCache` -|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting - -|`refresh` -|`boolean` - Should the affected indexes be refreshed? - -|`timeout` -|`string` - Time each individual bulk request should wait for shards that are unavailable. + -_Default:_ `1m` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`scroll_size` or `scrollSize` -|`number` - Size on the scroll request powering the update by query + -_Default:_ `100` - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request should block until the update by query operation is complete. + -_Default:_ `true` - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. - -|`slices` -|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + -_Default:_ `1` - -|`body` -|`object` - The search definition using the Query DSL - -|=== - -=== updateByQueryRethrottle - -[source,ts] ----- -client.updateByQueryRethrottle({ - task_id: string, - requests_per_second: number -}) ----- -link:{ref}/docs-update-by-query.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - The task id to rethrottle - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. - -|=== - -=== asyncSearch.delete - -[source,ts] ----- -client.asyncSearch.delete({ - id: string -}) ----- -link:{ref}/async-search.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|=== - -=== asyncSearch.get - -[source,ts] ----- -client.asyncSearch.get({ - id: string, - wait_for_completion_timeout: string, - keep_alive: string, - typed_keys: boolean -}) ----- -link:{ref}/async-search.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response - -|`keep_alive` or `keepAlive` -|`string` - Specify the time interval in which the results (partial or final) for this search will be available - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|=== - -=== asyncSearch.submit - -[source,ts] ----- -client.asyncSearch.submit({ - index: string | string[], - wait_for_completion_timeout: string, - keep_on_completion: boolean, - keep_alive: string, - batched_reduce_size: number, - request_cache: boolean, - analyzer: string, - analyze_wildcard: boolean, - default_operator: 'AND' | 'OR', - df: string, - explain: boolean, - stored_fields: string | string[], - docvalue_fields: string | string[], - from: number, - ignore_unavailable: boolean, - ignore_throttled: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - lenient: boolean, - preference: string, - q: string, - routing: string | string[], - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - size: number, - sort: string | string[], - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - terminate_after: number, - stats: string | string[], - suggest_field: string, - suggest_mode: 'missing' | 'popular' | 'always', - suggest_size: number, - suggest_text: string, - timeout: string, - track_scores: boolean, - track_total_hits: boolean, - allow_partial_search_results: boolean, - typed_keys: boolean, - version: boolean, - seq_no_primary_term: boolean, - max_concurrent_shard_requests: number, - body: object -}) ----- -link:{ref}/async-search.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response + -_Default:_ `1s` - -|`keep_on_completion` or `keepOnCompletion` -|`boolean` - Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) - -|`keep_alive` or `keepAlive` -|`string` - Update the time interval in which the results (partial or final) for this search will be available + -_Default:_ `5d` - -|`batched_reduce_size` or `batchedReduceSize` -|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as the granularity at which progress results will be made available. + -_Default:_ `5` - -|`request_cache` or `requestCache` -|`boolean` - Specify if request cache should be used for this request or not, defaults to true - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`explain` -|`boolean` - Specify whether to return detailed information about score computation as part of a hit - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return as part of a hit - -|`docvalue_fields` or `docvalueFields` -|`string \| string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit - -|`from` -|`number` - Starting offset (default: 0) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`size` -|`number` - Number of hits to return (default: 10) - -|`sort` -|`string \| string[]` - A comma-separated list of : pairs - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`terminate_after` or `terminateAfter` -|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - -|`stats` -|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes - -|`suggest_field` or `suggestField` -|`string` - Specify which field to use for suggestions - -|`suggest_mode` or `suggestMode` -|`'missing' \| 'popular' \| 'always'` - Specify suggest mode + -_Default:_ `missing` - -|`suggest_size` or `suggestSize` -|`number` - How many suggestions to return in response - -|`suggest_text` or `suggestText` -|`string` - The source text for which the suggestions should be returned - -|`timeout` -|`string` - Explicit operation timeout - -|`track_scores` or `trackScores` -|`boolean` - Whether to calculate and return scores even if they are not used for sorting - -|`track_total_hits` or `trackTotalHits` -|`boolean` - Indicate if the number of documents that match the query should be tracked - -|`allow_partial_search_results` or `allowPartialSearchResults` -|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + -_Default:_ `true` - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`version` -|`boolean` - Specify whether to return document version as part of a hit - -|`seq_no_primary_term` or `seqNoPrimaryTerm` -|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit - -|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` -|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + -_Default:_ `5` - -|`body` -|`object` - The search definition using the Query DSL - -|=== - -=== autoscaling.deleteAutoscalingPolicy -*Stability:* experimental -[source,ts] ----- -client.autoscaling.deleteAutoscalingPolicy({ - name: string -}) ----- -link:{ref}/autoscaling-delete-autoscaling-policy.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - the name of the autoscaling policy - -|=== - -=== autoscaling.getAutoscalingDecision -*Stability:* experimental -[source,ts] ----- -client.autoscaling.getAutoscalingDecision() ----- -link:{ref}/autoscaling-get-autoscaling-decision.html[Documentation] + - - -=== autoscaling.getAutoscalingPolicy -*Stability:* experimental -[source,ts] ----- -client.autoscaling.getAutoscalingPolicy({ - name: string -}) ----- -link:{ref}/autoscaling-get-autoscaling-policy.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - the name of the autoscaling policy - -|=== - -=== autoscaling.putAutoscalingPolicy -*Stability:* experimental -[source,ts] ----- -client.autoscaling.putAutoscalingPolicy({ - name: string, - body: object -}) ----- -link:{ref}/autoscaling-put-autoscaling-policy.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - the name of the autoscaling policy - -|`body` -|`object` - the specification of the autoscaling policy - -|=== - -=== cat.mlDataFrameAnalytics - -[source,ts] ----- -client.cat.mlDataFrameAnalytics({ - id: string, - allow_no_match: boolean, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no configs. (This includes `_all` string or when no configs have been specified) - -|`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 - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -=== cat.mlDatafeeds - -[source,ts] ----- -client.cat.mlDatafeeds({ - datafeed_id: string, - allow_no_datafeeds: boolean, - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-datafeeds.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeeds stats to fetch - -|`allow_no_datafeeds` or `allowNoDatafeeds` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -=== cat.mlJobs - -[source,ts] ----- -client.cat.mlJobs({ - job_id: string, - allow_no_jobs: boolean, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-anomaly-detectors.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the jobs stats to fetch - -|`allow_no_jobs` or `allowNoJobs` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - -|`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 - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -=== cat.mlTrainedModels - -[source,ts] ----- -client.cat.mlTrainedModels({ - model_id: string, - allow_no_match: boolean, - from: number, - size: number, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-trained-model.html[Documentation] + -[cols=2*] -|=== -|`model_id` or `modelId` -|`string` - The ID of the trained models stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + -_Default:_ `true` - -|`from` -|`number` - skips a number of trained models - -|`size` -|`number` - specifies a max number of trained models to get + -_Default:_ `100` - -|`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 - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -=== cat.transforms - -[source,ts] ----- -client.cat.transforms({ - transform_id: string, - from: number, - size: number, - allow_no_match: boolean, - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-transforms.html[Documentation] + -[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 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) - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -=== ccr.deleteAutoFollowPattern - -[source,ts] ----- -client.ccr.deleteAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-delete-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern. - -|=== - -=== ccr.follow - -[source,ts] ----- -client.ccr.follow({ - index: string, - wait_for_active_shards: string, - body: object -}) ----- -link:{ref}/ccr-put-follow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follower index - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + -_Default:_ `0` - -|`body` -|`object` - The name of the leader index and other optional ccr related parameters - -|=== - -=== ccr.followInfo - -[source,ts] ----- -client.ccr.followInfo({ - index: string | string[] -}) ----- -link:{ref}/ccr-get-follow-info.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices - -|=== - -=== ccr.followStats - -[source,ts] ----- -client.ccr.followStats({ - index: string | string[] -}) ----- -link:{ref}/ccr-get-follow-stats.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices - -|=== - -=== ccr.forgetFollower - -[source,ts] ----- -client.ccr.forgetFollower({ - index: string, - body: object -}) ----- -link:{ref}/ccr-post-forget-follower.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - the name of the leader index for which specified follower retention leases should be removed - -|`body` -|`object` - the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index - -|=== - -=== ccr.getAutoFollowPattern - -[source,ts] ----- -client.ccr.getAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-get-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern. - -|=== - -=== ccr.pauseAutoFollowPattern - -[source,ts] ----- -client.ccr.pauseAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-pause-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern that should pause discovering new indices to follow. - -|=== - -=== ccr.pauseFollow - -[source,ts] ----- -client.ccr.pauseFollow({ - index: string -}) ----- -link:{ref}/ccr-post-pause-follow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follower index that should pause following its leader index. - -|=== - -=== ccr.putAutoFollowPattern - -[source,ts] ----- -client.ccr.putAutoFollowPattern({ - name: string, - body: object -}) ----- -link:{ref}/ccr-put-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern. - -|`body` -|`object` - The specification of the auto follow pattern - -|=== - -=== ccr.resumeAutoFollowPattern - -[source,ts] ----- -client.ccr.resumeAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-resume-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern to resume discovering new indices to follow. - -|=== - -=== ccr.resumeFollow - -[source,ts] ----- -client.ccr.resumeFollow({ - index: string, - body: object -}) ----- -link:{ref}/ccr-post-resume-follow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follow index to resume following. - -|`body` -|`object` - The name of the leader index and other optional ccr related parameters - -|=== - -=== ccr.stats - -[source,ts] ----- -client.ccr.stats() ----- -link:{ref}/ccr-get-stats.html[Documentation] + - - -=== ccr.unfollow - -[source,ts] ----- -client.ccr.unfollow({ - index: string -}) ----- -link:{ref}/ccr-post-unfollow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follower index that should be turned into a regular index. - -|=== - -=== enrich.deletePolicy - -[source,ts] ----- -client.enrich.deletePolicy({ - name: string -}) ----- -link:{ref}/delete-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the enrich policy - -|=== - -=== enrich.executePolicy - -[source,ts] ----- -client.enrich.executePolicy({ - name: string, - wait_for_completion: boolean -}) ----- -link:{ref}/execute-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the enrich policy - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request should block until the execution is complete. + -_Default:_ `true` - -|=== - -=== enrich.getPolicy - -[source,ts] ----- -client.enrich.getPolicy({ - name: string | string[] -}) ----- -link:{ref}/get-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of enrich policy names - -|=== - -=== enrich.putPolicy - -[source,ts] ----- -client.enrich.putPolicy({ - name: string, - body: object -}) ----- -link:{ref}/put-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the enrich policy - -|`body` -|`object` - The enrich policy to register - -|=== - -=== enrich.stats - -[source,ts] ----- -client.enrich.stats() ----- -link:{ref}/enrich-stats-api.html[Documentation] + - - -=== eql.delete -*Stability:* beta -[source,ts] ----- -client.eql.delete({ - id: string -}) ----- -link:{ref}/eql-search-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|=== - -=== eql.get -*Stability:* beta -[source,ts] ----- -client.eql.get({ - id: string, - wait_for_completion_timeout: string, - keep_alive: string -}) ----- -link:{ref}/eql-search-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response - -|`keep_alive` or `keepAlive` -|`string` - Update the time interval in which the results (partial or final) for this search will be available + -_Default:_ `5d` - -|=== - -=== eql.search -*Stability:* beta -[source,ts] ----- -client.eql.search({ - index: string, - wait_for_completion_timeout: string, - keep_on_completion: boolean, - keep_alive: string, - body: object -}) ----- -link:{ref}/eql-search-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to scope the operation - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response - -|`keep_on_completion` or `keepOnCompletion` -|`boolean` - Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) - -|`keep_alive` or `keepAlive` -|`string` - Update the time interval in which the results (partial or final) for this search will be available + -_Default:_ `5d` - -|`body` -|`object` - Eql request body. Use the `query` to limit the query scope. - -|=== - -=== graph.explore - -[source,ts] ----- -client.graph.explore({ - index: string | string[], - type: string | string[], - routing: string, - timeout: string, - body: object -}) ----- -link:{ref}/graph-explore-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + - -WARNING: This parameter has been deprecated. - -|`routing` -|`string` - Specific routing value - -|`timeout` -|`string` - Explicit operation timeout - -|`body` -|`object` - Graph Query DSL - -|=== - -=== ilm.deleteLifecycle - -[source,ts] ----- -client.ilm.deleteLifecycle({ - policy: string -}) ----- -link:{ref}/ilm-delete-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`policy` -|`string` - The name of the index lifecycle policy - -|=== - -=== ilm.explainLifecycle - -[source,ts] ----- -client.ilm.explainLifecycle({ - index: string, - only_managed: boolean, - only_errors: boolean -}) ----- -link:{ref}/ilm-explain-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to explain - -|`only_managed` or `onlyManaged` -|`boolean` - filters the indices included in the response to ones managed by ILM - -|`only_errors` or `onlyErrors` -|`boolean` - filters the indices included in the response to ones in an ILM error state, implies only_managed - -|=== - -=== ilm.getLifecycle - -[source,ts] ----- -client.ilm.getLifecycle({ - policy: string -}) ----- -link:{ref}/ilm-get-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`policy` -|`string` - The name of the index lifecycle policy - -|=== - -=== ilm.getStatus - -[source,ts] ----- -client.ilm.getStatus() ----- -link:{ref}/ilm-get-status.html[Documentation] + - - -=== ilm.moveToStep - -[source,ts] ----- -client.ilm.moveToStep({ - index: string, - body: object -}) ----- -link:{ref}/ilm-move-to-step.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index whose lifecycle step is to change - -|`body` -|`object` - The new lifecycle step to move to - -|=== - -=== ilm.putLifecycle - -[source,ts] ----- -client.ilm.putLifecycle({ - policy: string, - body: object -}) ----- -link:{ref}/ilm-put-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`policy` -|`string` - The name of the index lifecycle policy - -|`body` -|`object` - The lifecycle policy definition to register - -|=== - -=== ilm.removePolicy - -[source,ts] ----- -client.ilm.removePolicy({ - index: string -}) ----- -link:{ref}/ilm-remove-policy.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to remove policy on - -|=== - -=== ilm.retry - -[source,ts] ----- -client.ilm.retry({ - index: string -}) ----- -link:{ref}/ilm-retry-policy.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the indices (comma-separated) whose failed lifecycle step is to be retry - -|=== - -=== ilm.start - -[source,ts] ----- -client.ilm.start() ----- -link:{ref}/ilm-start.html[Documentation] + - - -=== ilm.stop - -[source,ts] ----- -client.ilm.stop() ----- -link:{ref}/ilm-stop.html[Documentation] + - - -=== indices.createDataStream - -[source,ts] ----- -client.indices.createDataStream({ - name: string -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the data stream - -|=== - -=== indices.dataStreamsStats - -[source,ts] ----- -client.indices.dataStreamsStats({ - name: string | string[] -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of data stream names; use `_all` or empty string to perform the operation on all data streams - -|=== - -=== indices.deleteDataStream - -[source,ts] ----- -client.indices.deleteDataStream({ - name: string | string[] -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of data streams to delete; use `*` to delete all data streams - -|=== - -=== indices.freeze - -[source,ts] ----- -client.indices.freeze({ - index: string, - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - wait_for_active_shards: string -}) ----- -link:{ref}/freeze-index-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to freeze - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `closed` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of active shards to wait for before the operation returns. - -|=== - -=== indices.getDataStream - -[source,ts] ----- -client.indices.getDataStream({ - name: string | string[] -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of data streams to get; use `*` to get all data streams - -|=== - -=== indices.reloadSearchAnalyzers - -[source,ts] ----- -client.indices.reloadSearchAnalyzers({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/indices-reload-analyzers.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to reload analyzers for - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -=== indices.unfreeze - -[source,ts] ----- -client.indices.unfreeze({ - index: string, - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - wait_for_active_shards: string -}) ----- -link:{ref}/unfreeze-index-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to unfreeze - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `closed` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of active shards to wait for before the operation returns. - -|=== - === license.delete [source,ts] @@ -7254,7 +7185,9 @@ link:{ref}/get-license.html[Documentation] + |`boolean` - Return local information, do not retrieve the state from master node (default: false) |`accept_enterprise` or `acceptEnterprise` -|`boolean` - If the active license is an enterprise license, return type as 'enterprise' (default: false) +|`boolean` - Supported for backwards compatibility with 7.x. If this param is used it must be set to true + + +WARNING: This parameter has been deprecated. |=== @@ -7280,14 +7213,33 @@ link:{ref}/get-trial-status.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.cat.mlDatafeeds({ + datafeed_id: string, + allow_no_datafeeds: boolean, + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +======= client.license.post({ acknowledge: boolean, body: object +>>>>>>> 3db1bed4... Improve child performances (#1314) }) ---- link:{ref}/update-license.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeeds stats to fetch + +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) +======= |`acknowledge` |`boolean` - whether the user has acknowledged acknowledge messages (default: false) @@ -7295,6 +7247,7 @@ link:{ref}/update-license.html[Documentation] + |`object` - licenses to be installed |=== +>>>>>>> 3db1bed4... Improve child performances (#1314) === license.postStartBasic @@ -7332,6 +7285,79 @@ link:{ref}/start-trial.html[Documentation] + |=== +=== mget + +[source,ts] +---- +<<<<<<< HEAD +client.cat.mlJobs({ + job_id: string, + allow_no_jobs: boolean, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +======= +client.mget({ + index: string, + stored_fields: string | string[], + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + body: object +>>>>>>> 3db1bed4... Improve child performances (#1314) +}) +---- +link:{ref}/docs-multi-get.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`job_id` or `jobId` +|`string` - The ID of the jobs stats to fetch + +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) +======= +|`index` +|`string` - The name of the index + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return in the response + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) +>>>>>>> 3db1bed4... Improve child performances (#1314) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode + +|`refresh` +|`boolean` - Refresh the shard containing the document before performing the operation + +|`routing` +|`string` - Specific routing value + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - A list of fields to extract and return from the _source field + +|`body` +|`object` - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL. + +|=== + === migration.deprecations [source,ts] @@ -7354,6 +7380,7 @@ link:{ref}/migration-api-deprecation.html[Documentation] + ---- client.ml.closeJob({ job_id: string, + allow_no_match: boolean, allow_no_jobs: boolean, force: boolean, timeout: string, @@ -7366,9 +7393,14 @@ link:{ref}/ml-close-job.html[Documentation] + |`job_id` or `jobId` |`string` - The name of the job to close -|`allow_no_jobs` or `allowNoJobs` +|`allow_no_match` or `allowNoMatch` |`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + + +WARNING: This parameter has been deprecated. + |`force` |`boolean` - True if the job should be forcefully closed @@ -7629,6 +7661,8 @@ link:{ref}/ml-apis.html[Documentation] + |=== +<<<<<<< HEAD +======= === ml.evaluateDataFrame *Stability:* experimental [source,ts] @@ -7645,6 +7679,11 @@ link:{ref}/evaluate-dfanalytics.html[Documentation] + |=== +<<<<<<< HEAD +>>>>>>> 3db1bed4... Improve child performances (#1314) +=== enrich.deletePolicy + +======= === ml.explainDataFrameAnalytics *Stability:* experimental [source,ts] @@ -7970,6 +8009,7 @@ link:{ref}/ml-get-category.html[Documentation] + === ml.getDataFrameAnalytics *Stability:* experimental +>>>>>>> a064f0f3... Improve child performances (#1314) [source,ts] ---- client.ml.getDataFrameAnalytics({ @@ -8006,7 +8046,8 @@ client.ml.getDataFrameAnalyticsStats({ id: string, allow_no_match: boolean, from: number, - size: number + size: number, + verbose: boolean }) ---- link:{ref}/get-dfanalytics-stats.html[Documentation] + @@ -8026,6 +8067,9 @@ _Default:_ `true` |`number` - specifies a max number of analytics to get + _Default:_ `100` +|`verbose` +|`boolean` - whether the stats response should be verbose + |=== === ml.getDatafeedStats @@ -8034,6 +8078,7 @@ _Default:_ `100` ---- client.ml.getDatafeedStats({ datafeed_id: string, + allow_no_match: boolean, allow_no_datafeeds: boolean }) ---- @@ -8043,9 +8088,14 @@ link:{ref}/ml-get-datafeed-stats.html[Documentation] + |`datafeed_id` or `datafeedId` |`string` - The ID of the datafeeds stats to fetch -|`allow_no_datafeeds` or `allowNoDatafeeds` +|`allow_no_match` or `allowNoMatch` |`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + + +WARNING: This parameter has been deprecated. + |=== === ml.getDatafeeds @@ -8054,6 +8104,7 @@ link:{ref}/ml-get-datafeed-stats.html[Documentation] + ---- client.ml.getDatafeeds({ datafeed_id: string, + allow_no_match: boolean, allow_no_datafeeds: boolean }) ---- @@ -8063,9 +8114,14 @@ link:{ref}/ml-get-datafeed.html[Documentation] + |`datafeed_id` or `datafeedId` |`string` - The ID of the datafeeds to fetch -|`allow_no_datafeeds` or `allowNoDatafeeds` +|`allow_no_match` or `allowNoMatch` |`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + + +WARNING: This parameter has been deprecated. + |=== === ml.getFilters @@ -8148,9 +8204,19 @@ link:{ref}/ml-get-influencer.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.graph.explore({ + index: string | string[], + type: string | string[], + routing: string, + timeout: string, + body: object +======= client.ml.getJobStats({ job_id: string, + allow_no_match: boolean, allow_no_jobs: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/ml-get-job-stats.html[Documentation] + @@ -8159,8 +8225,23 @@ link:{ref}/ml-get-job-stats.html[Documentation] + |`job_id` or `jobId` |`string` - The ID of the jobs stats to fetch -|`allow_no_jobs` or `allowNoJobs` +<<<<<<< HEAD +|`type` +|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + + +WARNING: This parameter has been deprecated. + +|`routing` +|`string` - Specific routing value +======= +|`allow_no_match` or `allowNoMatch` |`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + + +WARNING: This parameter has been deprecated. |=== @@ -8170,6 +8251,7 @@ link:{ref}/ml-get-job-stats.html[Documentation] + ---- client.ml.getJobs({ job_id: string, + allow_no_match: boolean, allow_no_jobs: boolean }) ---- @@ -8179,9 +8261,14 @@ link:{ref}/ml-get-job.html[Documentation] + |`job_id` or `jobId` |`string` - The ID of the jobs to fetch -|`allow_no_jobs` or `allowNoJobs` +|`allow_no_match` or `allowNoMatch` |`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + + +WARNING: This parameter has been deprecated. + |=== === ml.getModelSnapshots @@ -8244,6 +8331,7 @@ client.ml.getOverallBuckets({ exclude_interim: boolean, start: string, end: string, + allow_no_match: boolean, allow_no_jobs: boolean, body: object }) @@ -8272,9 +8360,14 @@ link:{ref}/ml-get-overall-buckets.html[Documentation] + |`end` |`string` - Returns overall buckets with timestamps earlier than this time -|`allow_no_jobs` or `allowNoJobs` +|`allow_no_match` or `allowNoMatch` |`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + + +WARNING: This parameter has been deprecated. + |`body` |`object` - Overall bucket selection details if not provided in URI @@ -8339,7 +8432,7 @@ link:{ref}/ml-get-record.html[Documentation] + client.ml.getTrainedModels({ model_id: string, allow_no_match: boolean, - include_model_definition: boolean, + include: string, decompress_definition: boolean, from: number, size: number, @@ -8357,8 +8450,8 @@ link:{ref}/get-inference.html[Documentation] + |`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + _Default:_ `true` -|`include_model_definition` or `includeModelDefinition` -|`boolean` - Should the full model definition be included in the results. These definitions can be large. So be cautious when including them. Defaults to false. +|`include` +|`string` - A comma-separate list of fields to optionally include. Valid options are 'definition' and 'total_feature_importance'. Default is none. |`decompress_definition` or `decompressDefinition` |`boolean` - Should the model definition be decompressed into valid JSON or returned in a custom compressed format. Defaults to true. + @@ -8460,8 +8553,14 @@ link:{ref}/ml-post-calendar-event.html[Documentation] + ---- client.ml.postData({ job_id: string, +<<<<<<< HEAD + allow_no_jobs: boolean, + force: boolean, + timeout: string, +======= reset_start: string, reset_end: string, +>>>>>>> 3db1bed4... Improve child performances (#1314) body: object }) ---- @@ -8469,7 +8568,14 @@ link:{ref}/ml-post-data.html[Documentation] + [cols=2*] |=== |`job_id` or `jobId` +<<<<<<< HEAD +|`string` - The name of the job to close + +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) +======= |`string` - The name of the job receiving the data +>>>>>>> 3db1bed4... Improve child performances (#1314) |`reset_start` or `resetStart` |`string` - Optional parameter to specify the start of the bucket resetting range @@ -8550,8 +8656,35 @@ client.ml.putDataFrameAnalytics({ link:{ref}/put-dfanalytics.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`accept_enterprise` or `acceptEnterprise` +|`boolean` - If the active license is an enterprise license, return type as 'enterprise' (default: false) + +|=== + +=== license.getBasicStatus + +[source,ts] +---- +client.license.getBasicStatus() +---- +link:{ref}/get-basic-status.html[Documentation] + + + +=== license.getTrialStatus + +[source,ts] +---- +client.license.getTrialStatus() +---- +link:{ref}/get-trial-status.html[Documentation] + +======= |`id` |`string` - The ID of the data frame analytics to create +>>>>>>> a064f0f3... Improve child performances (#1314) |`body` |`object` - The data frame analytics configuration @@ -8796,9 +8929,11 @@ link:{ref}/stop-dfanalytics.html[Documentation] + ---- client.ml.stopDatafeed({ datafeed_id: string, + allow_no_match: boolean, allow_no_datafeeds: boolean, force: boolean, - timeout: string + timeout: string, + body: object }) ---- link:{ref}/ml-stop-datafeed.html[Documentation] + @@ -8807,15 +8942,23 @@ link:{ref}/ml-stop-datafeed.html[Documentation] + |`datafeed_id` or `datafeedId` |`string` - The ID of the datafeed to stop -|`allow_no_datafeeds` or `allowNoDatafeeds` +|`allow_no_match` or `allowNoMatch` |`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + + +WARNING: This parameter has been deprecated. + |`force` |`boolean` - True if the datafeed should be forcefully stopped. |`timeout` |`string` - Controls the time to wait until a datafeed has stopped. Default to 20 seconds +|`body` +|`object` - The URL params optionally sent in the body + |=== === ml.updateDataFrameAnalytics @@ -9004,6 +9147,635 @@ WARNING: This parameter has been deprecated. |=== +=== msearch + +[source,ts] +---- +<<<<<<< HEAD +client.ml.getDataFrameAnalyticsStats({ + id: string, + allow_no_match: boolean, + from: number, + size: number +======= +client.msearch({ + index: string | string[], + search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', + max_concurrent_searches: number, + typed_keys: boolean, + pre_filter_shard_size: number, + max_concurrent_shard_requests: number, + rest_total_hits_as_int: boolean, + ccs_minimize_roundtrips: boolean, + body: object +>>>>>>> 3db1bed4... Improve child performances (#1314) +}) +---- +link:{ref}/search-multi-search.html[Documentation] + +{jsclient}/msearch_examples.html[Code Example] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to use as default + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type + +<<<<<<< HEAD +|=== +======= +|`max_concurrent_searches` or `maxConcurrentSearches` +|`number` - Controls the maximum number of concurrent searches the multi search api will execute + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response +>>>>>>> 3db1bed4... Improve child performances (#1314) + +|`pre_filter_shard_size` or `preFilterShardSize` +|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + +<<<<<<< HEAD +[source,ts] +---- +client.ml.getDatafeedStats({ + datafeed_id: string, + allow_no_datafeeds: boolean +}) +---- +link:{ref}/ml-get-datafeed-stats.html[Documentation] + +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeeds stats to fetch + +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) +======= +|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` +|`number` - The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + +_Default:_ `5` + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + +_Default:_ `true` + +|`body` +|`object` - The request definitions (metadata-search request definition pairs), separated by newlines +>>>>>>> 3db1bed4... Improve child performances (#1314) + +|=== + +=== msearchTemplate + +[source,ts] +---- +<<<<<<< HEAD +client.ml.getDatafeeds({ + datafeed_id: string, + allow_no_datafeeds: boolean +======= +client.msearchTemplate({ + index: string | string[], + search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', + typed_keys: boolean, + max_concurrent_searches: number, + rest_total_hits_as_int: boolean, + ccs_minimize_roundtrips: boolean, + body: object +>>>>>>> 3db1bed4... Improve child performances (#1314) +}) +---- +link:{ref}/search-multi-search.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeeds to fetch + +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) +======= +|`index` +|`string \| string[]` - A comma-separated list of index names to use as default + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type +>>>>>>> 3db1bed4... Improve child performances (#1314) + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`max_concurrent_searches` or `maxConcurrentSearches` +|`number` - Controls the maximum number of concurrent searches the multi search api will execute + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + +_Default:_ `true` + +|`body` +|`object` - The request definitions (metadata-search request definition pairs), separated by newlines + +|=== + +=== mtermvectors + +[source,ts] +---- +client.mtermvectors({ + index: string, + ids: string | string[], + term_statistics: boolean, + field_statistics: boolean, + fields: string | string[], + offsets: boolean, + positions: boolean, + payloads: boolean, + preference: string, + routing: string, + realtime: boolean, + version: number, + version_type: 'internal' | 'external' | 'external_gte', + body: object +}) +---- +link:{ref}/docs-multi-termvectors.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The index in which the document resides. + +|`ids` +|`string \| string[]` - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body + +|`term_statistics` or `termStatistics` +|`boolean` - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`field_statistics` or `fieldStatistics` +|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`fields` +|`string \| string[]` - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`offsets` +|`boolean` - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`positions` +|`boolean` - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`payloads` +|`boolean` - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`routing` +|`string` - Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`realtime` +|`boolean` - Specifies if requests are real-time as opposed to near-real-time (default: true). + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte'` - Specific version type + +|`body` +|`object` - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. + +|=== + +=== nodes.hotThreads + +[source,ts] +---- +<<<<<<< HEAD +client.ml.getJobStats({ + job_id: string, + allow_no_jobs: boolean +======= +client.nodes.hotThreads({ + node_id: string | string[], + interval: string, + snapshots: number, + threads: number, + ignore_idle_threads: boolean, + type: 'cpu' | 'wait' | 'block', + timeout: string +>>>>>>> 3db1bed4... Improve child performances (#1314) +}) +---- +link:{ref}/cluster-nodes-hot-threads.html[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +<<<<<<< HEAD +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) +======= +|`interval` +|`string` - The interval for the second sampling of threads + +|`snapshots` +|`number` - Number of samples of thread stacktrace (default: 10) + +|`threads` +|`number` - Specify the number of threads to provide information for (default: 3) + +|`ignore_idle_threads` or `ignoreIdleThreads` +|`boolean` - Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) + +|`type` +|`'cpu' \| 'wait' \| 'block'` - The type to sample (default: cpu) + +|`timeout` +|`string` - Explicit operation timeout +>>>>>>> 3db1bed4... Improve child performances (#1314) + +|=== + +=== nodes.info + +[source,ts] +---- +<<<<<<< HEAD +client.ml.getJobs({ + job_id: string, + allow_no_jobs: boolean +======= +client.nodes.info({ + node_id: string | string[], + metric: string | string[], + flat_settings: boolean, + timeout: string +>>>>>>> 3db1bed4... Improve child performances (#1314) +}) +---- +link:{ref}/cluster-nodes-info.html[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +<<<<<<< HEAD +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) +======= +|`metric` +|`string \| string[]` - A comma-separated list of metrics you wish returned. Leave empty to return all. + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`timeout` +|`string` - Explicit operation timeout +>>>>>>> 3db1bed4... Improve child performances (#1314) + +|=== + +=== nodes.reloadSecureSettings + +[source,ts] +---- +client.nodes.reloadSecureSettings({ + node_id: string | string[], + timeout: string, + body: object +}) +---- +link:{ref}/secure-settings.html#reloadable-secure-settings[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. + +|`timeout` +|`string` - Explicit operation timeout + +|`body` +|`object` - An object containing the password for the elasticsearch keystore + +|=== + +=== nodes.stats + +[source,ts] +---- +<<<<<<< HEAD +client.ml.getOverallBuckets({ + job_id: string, + top_n: number, + bucket_span: string, + overall_score: number, + exclude_interim: boolean, + start: string, + end: string, + allow_no_jobs: boolean, + body: object +======= +client.nodes.stats({ + node_id: string | string[], + metric: string | string[], + index_metric: string | string[], + completion_fields: string | string[], + fielddata_fields: string | string[], + fields: string | string[], + groups: boolean, + level: 'indices' | 'node' | 'shards', + types: string | string[], + timeout: string, + include_segment_file_sizes: boolean +>>>>>>> 3db1bed4... Improve child performances (#1314) +}) +---- +link:{ref}/cluster-nodes-stats.html[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`metric` +|`string \| string[]` - Limit the information returned to the specified metrics + +|`index_metric` or `indexMetric` +|`string \| string[]` - Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. + +|`completion_fields` or `completionFields` +|`string \| string[]` - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) + +|`fielddata_fields` or `fielddataFields` +|`string \| string[]` - A comma-separated list of fields for `fielddata` index metric (supports wildcards) + +|`fields` +|`string \| string[]` - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + +|`groups` +|`boolean` - A comma-separated list of search groups for `search` index metric + +<<<<<<< HEAD +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) +======= +|`level` +|`'indices' \| 'node' \| 'shards'` - Return indices stats aggregated at index, node or shard level + +_Default:_ `node` + +|`types` +|`string \| string[]` - A comma-separated list of document types for the `indexing` index metric + +|`timeout` +|`string` - Explicit operation timeout +>>>>>>> 3db1bed4... Improve child performances (#1314) + +|`include_segment_file_sizes` or `includeSegmentFileSizes` +|`boolean` - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + +|=== + +=== nodes.usage + +[source,ts] +---- +client.nodes.usage({ + node_id: string | string[], + metric: string | string[], + timeout: string +}) +---- +link:{ref}/cluster-nodes-usage.html[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`metric` +|`string \| string[]` - Limit the information returned to the specified metrics + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== openPointInTime + +[source,ts] +---- +client.openPointInTime({ + index: string | string[], + preference: string, + routing: string, + ignore_unavailable: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + keep_alive: string +}) +---- +link:{ref}/point-in-time-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to open point in time; use `_all` or empty string to perform the operation on all indices + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`routing` +|`string` - Specific routing value + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`keep_alive` or `keepAlive` +|`string` - Specific the time to live for the point in time + +|=== + +=== ping + +[source,ts] +---- +client.ping() +---- +link:{ref}/index.html[Documentation] + + + +=== putScript + +[source,ts] +---- +client.putScript({ + id: string, + context: string, + timeout: string, + master_timeout: string, + body: object +}) +---- +link:{ref}/modules-scripting.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - Script ID + +|`context` +|`string` - Script context + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`body` +|`object` - The document + +|=== + +=== rankEval +*Stability:* experimental +[source,ts] +---- +client.rankEval({ + index: string | string[], + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + body: object +}) +---- +link:{ref}/search-rank-eval.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type + +|`body` +|`object` - The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. + +|=== + +=== reindex + +[source,ts] +---- +client.reindex({ + refresh: boolean, + timeout: string, + wait_for_active_shards: string, + wait_for_completion: boolean, + requests_per_second: number, + scroll: string, + slices: number|string, + max_docs: number, + body: object +}) +---- +link:{ref}/docs-reindex.html[Documentation] + +{jsclient}/reindex_examples.html[Code Example] + +[cols=2*] +|=== +|`refresh` +|`boolean` - Should the affected indexes be refreshed? + +|`timeout` +|`string` - Time each individual bulk request should wait for shards that are unavailable. + +_Default:_ `1m` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request should block until the reindex is complete. + +_Default:_ `true` + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. + +|`scroll` +|`string` - Control how long to keep the search context alive + +_Default:_ `5m` + +|`slices` +|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + +_Default:_ `1` + +|`max_docs` or `maxDocs` +|`number` - Maximum number of documents to process (default: all documents) + +|`body` +|`object` - The search definition using the Query DSL and the prototype for the index request. + +|=== + +=== reindexRethrottle + +[source,ts] +---- +client.reindexRethrottle({ + task_id: string, + requests_per_second: number +}) +---- +link:{ref}/docs-reindex.html[Documentation] + +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - The task id to rethrottle + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + +|=== + +=== renderSearchTemplate + +[source,ts] +---- +client.renderSearchTemplate({ + id: string, + body: object +}) +---- +link:{ref}/search-template.html#_validating_templates[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The id of the stored search template + +|`body` +|`object` - The search definition template and its params + +|=== + === rollup.deleteJob *Stability:* experimental [source,ts] @@ -9162,6 +9934,372 @@ link:{ref}/rollup-stop-job.html[Documentation] + |=== +=== scriptsPainlessExecute +*Stability:* experimental +[source,ts] +---- +client.scriptsPainlessExecute({ + body: object +}) +---- +link:https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html[Documentation] + +[cols=2*] +|=== +|`body` +|`object` - The script to execute + +|=== + +=== scroll + +[source,ts] +---- +client.scroll({ + scroll_id: string, + scroll: string, + rest_total_hits_as_int: boolean, + body: object +}) +---- +link:{ref}/search-request-body.html#request-body-search-scroll[Documentation] + +{jsclient}/scroll_examples.html[Code Example] + +[cols=2*] +|=== +|`scroll_id` or `scrollId` +|`string` - The scroll ID + + +WARNING: This parameter has been deprecated. + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`body` +|`object` - The scroll ID if not passed by URL or query parameter. + +|=== + +=== search + +[source,ts] +---- +<<<<<<< HEAD +client.ml.stopDatafeed({ + datafeed_id: string, + allow_no_datafeeds: boolean, + force: boolean, + timeout: string +======= +client.search({ + index: string | string[], + analyzer: string, + analyze_wildcard: boolean, + ccs_minimize_roundtrips: boolean, + default_operator: 'AND' | 'OR', + df: string, + explain: boolean, + stored_fields: string | string[], + docvalue_fields: string | string[], + from: number, + ignore_unavailable: boolean, + ignore_throttled: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + preference: string, + q: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + size: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + suggest_field: string, + suggest_mode: 'missing' | 'popular' | 'always', + suggest_size: number, + suggest_text: string, + timeout: string, + track_scores: boolean, + track_total_hits: boolean|long, + allow_partial_search_results: boolean, + typed_keys: boolean, + version: boolean, + seq_no_primary_term: boolean, + request_cache: boolean, + batched_reduce_size: number, + max_concurrent_shard_requests: number, + pre_filter_shard_size: number, + rest_total_hits_as_int: boolean, + body: object +}) +---- +link:{ref}/search-search.html[Documentation] + +{jsclient}/search_examples.html[Code Example] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + +_Default:_ `true` + +|`default_operator` or `defaultOperator` +|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + +_Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`explain` +|`boolean` - Specify whether to return detailed information about score computation as part of a hit + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return as part of a hit + +|`docvalue_fields` or `docvalueFields` +|`string \| string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`ignore_throttled` or `ignoreThrottled` +|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`q` +|`string` - Query in the Lucene query string syntax + +|`routing` +|`string \| string[]` - A comma-separated list of specific routing values + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type + +|`size` +|`number` - Number of hits to return (default: 10) + +|`sort` +|`string \| string[]` - A comma-separated list of : pairs + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - A list of fields to extract and return from the _source field + +|`terminate_after` or `terminateAfter` +|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + +|`stats` +|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes + +|`suggest_field` or `suggestField` +|`string` - Specify which field to use for suggestions + +|`suggest_mode` or `suggestMode` +|`'missing' \| 'popular' \| 'always'` - Specify suggest mode + +_Default:_ `missing` + +|`suggest_size` or `suggestSize` +|`number` - How many suggestions to return in response + +|`suggest_text` or `suggestText` +|`string` - The source text for which the suggestions should be returned + +|`timeout` +|`string` - Explicit operation timeout + +|`track_scores` or `trackScores` +|`boolean` - Whether to calculate and return scores even if they are not used for sorting + +|`track_total_hits` or `trackTotalHits` +|`boolean\|long` - Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. + +|`allow_partial_search_results` or `allowPartialSearchResults` +|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + +_Default:_ `true` + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`seq_no_primary_term` or `seqNoPrimaryTerm` +|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit + +|`request_cache` or `requestCache` +|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting + +|`batched_reduce_size` or `batchedReduceSize` +|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + +_Default:_ `512` + +|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` +|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + +_Default:_ `5` + +|`pre_filter_shard_size` or `preFilterShardSize` +|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`body` +|`object` - The search definition using the Query DSL + +|=== + +=== searchShards + +[source,ts] +---- +client.searchShards({ + index: string | string[], + preference: string, + routing: string, + local: boolean, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +}) +---- +link:{ref}/search-shards.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`routing` +|`string` - Specific routing value + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|=== + +=== searchTemplate + +[source,ts] +---- +client.searchTemplate({ + index: string | string[], + ignore_unavailable: boolean, + ignore_throttled: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + preference: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', + explain: boolean, + profile: boolean, + typed_keys: boolean, + rest_total_hits_as_int: boolean, + ccs_minimize_roundtrips: boolean, + body: object +>>>>>>> 3db1bed4... Improve child performances (#1314) +}) +---- +link:{ref}/search-template.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`ignore_throttled` or `ignoreThrottled` +|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`routing` +|`string \| string[]` - A comma-separated list of specific routing values + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type + +|`explain` +|`boolean` - Specify whether to return detailed information about score computation as part of a hit + +|`profile` +|`boolean` - Specify whether to profile the query execution + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + +_Default:_ `true` + +|`body` +|`object` - The search definition template and its params + +|=== + === searchableSnapshots.clearCache *Stability:* experimental [source,ts] @@ -9173,12 +10311,16 @@ client.searchableSnapshots.clearCache({ expand_wildcards: 'open' | 'closed' | 'none' | 'all' }) ---- -link:{ref}/searchable-snapshots-api-clear-cache.html[Documentation] + +link:{ref}/searchable-snapshots-apis.html[Documentation] + [cols=2*] |=== |`index` |`string \| string[]` - A comma-separated list of index names +<<<<<<< HEAD +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) +======= |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -9188,6 +10330,7 @@ link:{ref}/searchable-snapshots-api-clear-cache.html[Documentation] + |`expand_wildcards` or `expandWildcards` |`'open' \| 'closed' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + _Default:_ `open` +>>>>>>> 3db1bed4... Improve child performances (#1314) |=== @@ -9218,9 +10361,12 @@ link:{ref}/searchable-snapshots-api-mount-snapshot.html[Documentation] + |`wait_for_completion` or `waitForCompletion` |`boolean` - Should this request wait until the operation has completed before returning +<<<<<<< HEAD +======= |`body` |`object` - The restore configuration for mounting the snapshot as searchable +>>>>>>> 3db1bed4... Improve child performances (#1314) |=== === searchableSnapshots.repositoryStats @@ -9231,7 +10377,7 @@ client.searchableSnapshots.repositoryStats({ repository: string }) ---- -link:{ref}/searchable-snapshots-repository-stats.html[Documentation] + +link:{ref}/searchable-snapshots-apis.html[Documentation] + [cols=2*] |=== |`repository` @@ -9247,7 +10393,7 @@ client.searchableSnapshots.stats({ index: string | string[] }) ---- -link:{ref}/searchable-snapshots-api-stats.html[Documentation] + +link:{ref}/searchable-snapshots-apis.html[Documentation] + [cols=2*] |=== |`index` @@ -9516,6 +10662,10 @@ link:{ref}/security-api-get-api-key.html[Documentation] + |=== +<<<<<<< HEAD +=== rollup.deleteJob +*Stability:* experimental +======= === security.getBuiltinPrivileges [source,ts] @@ -9550,30 +10700,31 @@ link:{ref}/security-api-get-privileges.html[Documentation] + [source,ts] ---- client.security.getRole({ - name: string + name: string | string[] }) ---- link:{ref}/security-api-get-role.html[Documentation] + [cols=2*] |=== |`name` -|`string` - Role name +|`string \| string[]` - A comma-separated list of role names |=== === security.getRoleMapping +>>>>>>> 3db1bed4... Improve child performances (#1314) [source,ts] ---- client.security.getRoleMapping({ - name: string + name: string | string[] }) ---- link:{ref}/security-api-get-role-mapping.html[Documentation] + [cols=2*] |=== |`name` -|`string` - Role-Mapping name +|`string \| string[]` - A comma-separated list of role-mapping names |=== @@ -9724,7 +10875,11 @@ client.security.putRoleMapping({ body: object }) ---- +<<<<<<< HEAD +link:{ref}/searchable-snapshots-api-clear-cache.html[Documentation] + +======= link:{ref}/security-api-put-role-mapping.html[Documentation] + +>>>>>>> 3db1bed4... Improve child performances (#1314) [cols=2*] |=== |`name` @@ -9770,7 +10925,11 @@ client.slm.deleteLifecycle({ policy_id: string }) ---- +<<<<<<< HEAD +link:{ref}/searchable-snapshots-repository-stats.html[Documentation] + +======= link:{ref}/slm-api-delete-policy.html[Documentation] + +>>>>>>> 3db1bed4... Improve child performances (#1314) [cols=2*] |=== |`policy_id` or `policyId` @@ -9786,7 +10945,11 @@ client.slm.executeLifecycle({ policy_id: string }) ---- +<<<<<<< HEAD +link:{ref}/searchable-snapshots-api-stats.html[Documentation] + +======= link:{ref}/slm-api-execute-lifecycle.html[Documentation] + +>>>>>>> 3db1bed4... Improve child performances (#1314) [cols=2*] |=== |`policy_id` or `policyId` @@ -9875,6 +11038,302 @@ client.slm.stop() link:{ref}/slm-api-stop.html[Documentation] + +=== snapshot.cleanupRepository + +[source,ts] +---- +client.snapshot.cleanupRepository({ + repository: string, + master_timeout: string, + timeout: string +}) +---- +link:{ref}/clean-up-snapshot-repo-api.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== snapshot.create + +[source,ts] +---- +client.snapshot.create({ + repository: string, + snapshot: string, + master_timeout: string, + wait_for_completion: boolean, + body: object +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string` - A snapshot name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should this request wait until the operation has completed before returning + +|`body` +|`object` - The snapshot definition + +|=== + +=== snapshot.createRepository + +[source,ts] +---- +client.snapshot.createRepository({ + repository: string, + master_timeout: string, + timeout: string, + verify: boolean, + body: object +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|`verify` +|`boolean` - Whether to verify the repository after creation + +|`body` +|`object` - The repository definition + +|=== + +=== snapshot.delete + +[source,ts] +---- +client.snapshot.delete({ + repository: string, + snapshot: string | string[], + master_timeout: string +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string \| string[]` - A comma-separated list of snapshot names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|=== + +=== snapshot.deleteRepository + +[source,ts] +---- +client.snapshot.deleteRepository({ + repository: string | string[], + master_timeout: string, + timeout: string +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string \| string[]` - Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported. + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== snapshot.get + +[source,ts] +---- +client.snapshot.get({ + repository: string, + snapshot: string | string[], + master_timeout: string, + ignore_unavailable: boolean, + verbose: boolean +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string \| string[]` - A comma-separated list of snapshot names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + +|`verbose` +|`boolean` - Whether to show verbose snapshot info or only show the basic info found in the repository index blob + +|=== + +=== snapshot.getRepository + +[source,ts] +---- +client.snapshot.getRepository({ + repository: string | string[], + master_timeout: string, + local: boolean +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string \| string[]` - A comma-separated list of repository names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== + +=== snapshot.restore + +[source,ts] +---- +<<<<<<< HEAD +client.security.getRole({ + name: string +======= +client.snapshot.restore({ + repository: string, + snapshot: string, + master_timeout: string, + wait_for_completion: boolean, + body: object +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`name` +|`string` - Role name +======= +|`repository` +|`string` - A repository name + +|`snapshot` +|`string` - A snapshot name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should this request wait until the operation has completed before returning + +|`body` +|`object` - Details of what to restore +>>>>>>> a064f0f3... Improve child performances (#1314) + +|=== + +=== snapshot.status + +[source,ts] +---- +<<<<<<< HEAD +client.security.getRoleMapping({ + name: string +======= +client.snapshot.status({ + repository: string, + snapshot: string | string[], + master_timeout: string, + ignore_unavailable: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`name` +|`string` - Role-Mapping name +======= +|`repository` +|`string` - A repository name + +|`snapshot` +|`string \| string[]` - A comma-separated list of snapshot names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown +>>>>>>> a064f0f3... Improve child performances (#1314) + +|=== + +=== snapshot.verifyRepository + +[source,ts] +---- +client.snapshot.verifyRepository({ + repository: string, + master_timeout: string, + timeout: string +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|=== + === sql.clearCursor [source,ts] @@ -9937,6 +11396,175 @@ client.ssl.certificates() link:{ref}/security-api-ssl.html[Documentation] + +=== tasks.cancel + +[source,ts] +---- +client.tasks.cancel({ + task_id: string, + nodes: string | string[], + actions: string | string[], + parent_task_id: string, + wait_for_completion: boolean +}) +---- +link:{ref}/tasks.html[Documentation] + +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - Cancel the task with specified task id (node_id:task_number) + +|`nodes` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`actions` +|`string \| string[]` - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. + +|`parent_task_id` or `parentTaskId` +|`string` - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false + +|=== + +=== tasks.get + +[source,ts] +---- +client.tasks.get({ + task_id: string, + wait_for_completion: boolean, + timeout: string +}) +---- +link:{ref}/tasks.html[Documentation] + +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - Return the task with specified id (node_id:task_number) + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Wait for the matching tasks to complete (default: false) + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== tasks.list + +[source,ts] +---- +client.tasks.list({ + nodes: string | string[], + actions: string | string[], + detailed: boolean, + parent_task_id: string, + wait_for_completion: boolean, + group_by: 'nodes' | 'parents' | 'none', + timeout: string +}) +---- +link:{ref}/tasks.html[Documentation] + +[cols=2*] +|=== +|`nodes` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`actions` +|`string \| string[]` - A comma-separated list of actions that should be returned. Leave empty to return all. + +|`detailed` +|`boolean` - Return detailed task information (default: false) + +|`parent_task_id` or `parentTaskId` +|`string` - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Wait for the matching tasks to complete (default: false) + +|`group_by` or `groupBy` +|`'nodes' \| 'parents' \| 'none'` - Group tasks by nodes or parent/child relationships + +_Default:_ `nodes` + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== termvectors + +[source,ts] +---- +client.termvectors({ + index: string, + id: string, + term_statistics: boolean, + field_statistics: boolean, + fields: string | string[], + offsets: boolean, + positions: boolean, + payloads: boolean, + preference: string, + routing: string, + realtime: boolean, + version: number, + version_type: 'internal' | 'external' | 'external_gte', + body: object +}) +---- +link:{ref}/docs-termvectors.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The index in which the document resides. + +|`id` +|`string` - The id of the document, when not specified a doc param should be supplied. + +|`term_statistics` or `termStatistics` +|`boolean` - Specifies if total term frequency and document frequency should be returned. + +|`field_statistics` or `fieldStatistics` +|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + +_Default:_ `true` + +|`fields` +|`string \| string[]` - A comma-separated list of fields to return. + +|`offsets` +|`boolean` - Specifies if term offsets should be returned. + +_Default:_ `true` + +|`positions` +|`boolean` - Specifies if term positions should be returned. + +_Default:_ `true` + +|`payloads` +|`boolean` - Specifies if term payloads should be returned. + +_Default:_ `true` + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random). + +|`routing` +|`string` - Specific routing value. + +|`realtime` +|`boolean` - Specifies if request is real-time as opposed to near-real-time (default: true). + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte'` - Specific version type + +|`body` +|`object` - Define parameters and or supply a document to get termvectors for. See documentation. + +|=== + === transform.deleteTransform [source,ts] @@ -10133,6 +11761,269 @@ link:{ref}/update-transform.html[Documentation] + |=== +=== update + +[source,ts] +---- +client.update({ + id: string, + index: string, + type: string, + wait_for_active_shards: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + lang: string, + refresh: 'true' | 'false' | 'wait_for', + retry_on_conflict: number, + routing: string, + timeout: string, + if_seq_no: number, + if_primary_term: number, + require_alias: boolean, + body: object +}) +---- +link:{ref}/docs-update.html[Documentation] + +{jsclient}/update_examples.html[Code Example] + +[cols=2*] +|=== +|`id` +|`string` - Document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + + +WARNING: This parameter has been deprecated. + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the update 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) + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - A list of fields to extract and return from the _source field + +|`lang` +|`string` - The script language (default: painless) + +|`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. + +|`retry_on_conflict` or `retryOnConflict` +|`number` - Specify how many times should the operation be retried when a conflict occurs (default: 0) + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`if_seq_no` or `ifSeqNo` +|`number` - only perform the update operation if the last operation that has changed the document has the specified sequence number + +|`if_primary_term` or `ifPrimaryTerm` +|`number` - only perform the update operation if the last operation that has changed the document has the specified primary term + +|`require_alias` or `requireAlias` +|`boolean` - When true, requires destination is an alias. Default is false + +|`body` +|`object` - The request definition requires either `script` or partial `doc` + +|=== + +=== updateByQuery + +[source,ts] +---- +client.updateByQuery({ + index: string | string[], + analyzer: string, + analyze_wildcard: boolean, + default_operator: 'AND' | 'OR', + df: string, + from: number, + ignore_unavailable: boolean, + allow_no_indices: boolean, + conflicts: 'abort' | 'proceed', + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + pipeline: string, + preference: string, + q: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + search_timeout: string, + max_docs: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + version: boolean, + version_type: boolean, + request_cache: boolean, + refresh: boolean, + timeout: string, + wait_for_active_shards: string, + scroll_size: number, + wait_for_completion: boolean, + requests_per_second: number, + slices: number|string, + body: object +}) +---- +link:{ref}/docs-update-by-query.html[Documentation] + +{jsclient}/update_by_query_examples.html[Code Example] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + +_Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`conflicts` +|`'abort' \| 'proceed'` - What to do when the update by query hits version conflicts? + +_Default:_ `abort` + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`pipeline` +|`string` - Ingest pipeline to set on index requests made by this action. (default: none) + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`q` +|`string` - Query in the Lucene query string syntax + +|`routing` +|`string \| string[]` - A comma-separated list of specific routing values + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type + +|`search_timeout` or `searchTimeout` +|`string` - Explicit timeout for each search request. Defaults to no timeout. + +|`max_docs` or `maxDocs` +|`number` - Maximum number of documents to process (default: all documents) + +|`sort` +|`string \| string[]` - A comma-separated list of : pairs + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - A list of fields to extract and return from the _source field + +|`terminate_after` or `terminateAfter` +|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + +|`stats` +|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`version_type` or `versionType` +|`boolean` - Should the document increment the version number (internal) on hit or not (reindex) + +|`request_cache` or `requestCache` +|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting + +|`refresh` +|`boolean` - Should the affected indexes be refreshed? + +|`timeout` +|`string` - Time each individual bulk request should wait for shards that are unavailable. + +_Default:_ `1m` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`scroll_size` or `scrollSize` +|`number` - Size on the scroll request powering the update by query + +_Default:_ `100` + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request should block until the update by query operation is complete. + +_Default:_ `true` + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. + +|`slices` +|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + +_Default:_ `1` + +|`body` +|`object` - The search definition using the Query DSL + +|=== + +=== updateByQueryRethrottle + +[source,ts] +---- +client.updateByQueryRethrottle({ + task_id: string, + requests_per_second: number +}) +---- +link:{ref}/docs-update-by-query.html[Documentation] + +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - The task id to rethrottle + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + +|=== + === watcher.ackWatch [source,ts] diff --git a/index.js b/index.js index 0538d2b7c..7f7a498bf 100644 --- a/index.js +++ b/index.js @@ -17,17 +17,19 @@ const Helpers = nodeMajor < 10 ? /* istanbul ignore next */ null : require('./li const Serializer = require('./lib/Serializer') const errors = require('./lib/errors') const { ConfigurationError } = errors +const { prepareHeaders } = Connection.internals const kInitialOptions = Symbol('elasticsearchjs-initial-options') const kChild = Symbol('elasticsearchjs-child') const kExtensions = Symbol('elasticsearchjs-extensions') const kEventEmitter = Symbol('elasticsearchjs-event-emitter') -const buildApi = require('./api') +const ESAPI = require('./api') -class Client { +class Client extends ESAPI { constructor (opts = {}) { - if (opts.cloud) { + super({ ConfigurationError }) + if (opts.cloud && opts[kChild] === undefined) { const { id, username, password } = opts.cloud // the cloud id is `cluster-name:base64encodedurl` // the url is a string divided by two '$', the first is the cloud url @@ -56,37 +58,41 @@ class Client { throw new ConfigurationError('Missing node(s) option') } - const checkAuth = getAuth(opts.node || opts.nodes) - if (checkAuth && checkAuth.username && checkAuth.password) { - opts.auth = Object.assign({}, opts.auth, { username: checkAuth.username, password: checkAuth.password }) + if (opts[kChild] === undefined) { + const checkAuth = getAuth(opts.node || opts.nodes) + if (checkAuth && checkAuth.username && checkAuth.password) { + opts.auth = Object.assign({}, opts.auth, { username: checkAuth.username, password: checkAuth.password }) + } } - const options = Object.assign({}, { - Connection, - Transport, - Serializer, - ConnectionPool: opts.cloud ? CloudConnectionPool : ConnectionPool, - maxRetries: 3, - requestTimeout: 30000, - pingTimeout: 3000, - sniffInterval: false, - sniffOnStart: false, - sniffEndpoint: '_nodes/_all/http', - sniffOnConnectionFault: false, - resurrectStrategy: 'ping', - suggestCompression: false, - compression: false, - ssl: null, - agent: null, - headers: {}, - nodeFilter: null, - nodeSelector: 'round-robin', - generateRequestId: null, - name: 'elasticsearch-js', - auth: null, - opaqueIdPrefix: null, - context: null - }, opts) + const options = opts[kChild] !== undefined + ? opts[kChild].initialOptions + : Object.assign({}, { + Connection, + Transport, + Serializer, + ConnectionPool: opts.cloud ? CloudConnectionPool : ConnectionPool, + maxRetries: 3, + requestTimeout: 30000, + pingTimeout: 3000, + sniffInterval: false, + sniffOnStart: false, + sniffEndpoint: '_nodes/_all/http', + sniffOnConnectionFault: false, + resurrectStrategy: 'ping', + suggestCompression: false, + compression: false, + ssl: null, + agent: null, + headers: {}, + nodeFilter: null, + nodeSelector: 'round-robin', + generateRequestId: null, + name: 'elasticsearch-js', + auth: null, + opaqueIdPrefix: null, + context: null + }, opts) this[kInitialOptions] = options this[kExtensions] = [] @@ -140,17 +146,6 @@ class Client { if (Helpers !== null) { this.helpers = new Helpers({ client: this, maxRetries: options.maxRetries }) } - - const apis = buildApi({ - makeRequest: this.transport.request.bind(this.transport), - result: { body: null, statusCode: null, headers: null, warnings: null }, - ConfigurationError - }) - - const apiNames = Object.keys(apis) - for (var i = 0, len = apiNames.length; i < len; i++) { - this[apiNames[i]] = apis[apiNames[i]] - } } get emit () { @@ -186,7 +181,7 @@ class Client { throw new Error(`The method "${method}" already exists on namespace "${namespace}"`) } - this[namespace] = this[namespace] || {} + if (this[namespace] == null) this[namespace] = {} this[namespace][method] = fn({ makeRequest: this.transport.request.bind(this.transport), result: { body: null, statusCode: null, headers: null, warnings: null }, @@ -209,15 +204,21 @@ class Client { child (opts) { // Merge the new options with the initial ones - const initialOptions = Object.assign({}, this[kInitialOptions], opts) + const options = Object.assign({}, this[kInitialOptions], opts) // Pass to the child client the parent instances that cannot be overriden - initialOptions[kChild] = { + options[kChild] = { connectionPool: this.connectionPool, serializer: this.serializer, - eventEmitter: this[kEventEmitter] + eventEmitter: this[kEventEmitter], + initialOptions: options } - const client = new Client(initialOptions) + /* istanbul ignore else */ + if (options.auth !== undefined) { + options.headers = prepareHeaders(options.headers, options.auth) + } + + const client = new Client(options) // Add parent extensions if (this[kExtensions].length > 0) { this[kExtensions].forEach(({ name, opts, fn }) => { diff --git a/lib/Connection.js b/lib/Connection.js index 7ab7b43a8..a624397bb 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -324,3 +324,4 @@ function prepareHeaders (headers = {}, auth) { } module.exports = Connection +module.exports.internals = { prepareHeaders } diff --git a/lib/Transport.js b/lib/Transport.js index 2d7e2285f..ae40482ba 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -112,10 +112,17 @@ class Transport { body: null, statusCode: null, headers: null, - warnings: options.warnings || null, meta } + Object.defineProperty(result, 'warnings', { + get () { + return this.headers && this.headers.warning + ? this.headers.warning.split(/(?!\B"[^"]*),(?![^"]*"\B)/) + : null + } + }) + // We should not retry if we are sending a stream body, because we should store in memory // a copy of the stream to be able to send it again, but since we don't know in advance // the size of the stream, we risk to take too much memory. @@ -183,11 +190,6 @@ class Transport { const { statusCode, headers } = response result.statusCode = statusCode result.headers = headers - if (headers['warning'] !== undefined) { - result.warnings = result.warnings || [] - // split the string over the commas not inside quotes - result.warnings.push.apply(result.warnings, headers['warning'].split(/(?!\B"[^"]*),(?![^"]*"\B)/)) - } if (options.asStream === true) { result.body = response diff --git a/scripts/generate.js b/scripts/generate.js index d24e9b7ed..1bdb36456 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -36,7 +36,6 @@ function start (opts) { const kibanaTypeDefFile = join(packageFolder, 'kibana.d.ts') const docOutputFile = join(__dirname, '..', 'docs', 'reference.asciidoc') const requestParamsOutputFile = join(packageFolder, 'requestParams.d.ts') - const allSpec = [] log.text = 'Cleaning API folder...' rimraf.sync(join(apiOutputFolder, '*.js')) @@ -51,8 +50,25 @@ function start (opts) { const xPackFolderContents = readdirSync(xPackFolder) .filter(file => !file.startsWith('data_frame_transform_deprecated')) - apiFolderContents.forEach(generateApiFile(apiFolder, log)) - xPackFolderContents.forEach(generateApiFile(xPackFolder, log)) + const allSpec = apiFolderContents.concat(xPackFolderContents) + .filter(file => file !== '_common.json') + .filter(file => !file.includes('deprecated')) + .sort() + .map(file => { + try { + return JSON.parse(readFileSync(join(apiFolder, file), 'utf8')) + } catch (err) { + return JSON.parse(readFileSync(join(xPackFolder, file), 'utf8')) + } + }) + + const namespaces = namespacify(apiFolderContents.concat(xPackFolderContents)) + for (const namespace in namespaces) { + if (namespace === '_common') continue + const code = generate(namespace, namespaces[namespace], { apiFolder, xPackFolder }, opts.branch || opts.tag) + const filePath = join(apiOutputFolder, `${namespace}.js`) + writeFileSync(filePath, code, { encoding: 'utf8' }) + } writeFileSync( requestParamsOutputFile, @@ -60,7 +76,7 @@ function start (opts) { { encoding: 'utf8' } ) - const { fn: factory, types, kibanaTypes } = genFactory(apiOutputFolder, [apiFolder, xPackFolder]) + const { fn: factory, types, kibanaTypes } = genFactory(apiOutputFolder, [apiFolder, xPackFolder], namespaces) writeFileSync( mainOutputFile, factory, @@ -89,9 +105,6 @@ function start (opts) { lintFiles(log, () => { log.text = 'Generating documentation' - const allSpec = apiFolderContents.filter(f => f !== '_common.json') - .map(f => require(join(apiFolder, f))) - .concat(xPackFolderContents.map(f => require(join(xPackFolder, f)))) writeFileSync( docOutputFile, generateDocs(require(join(apiFolder, '_common.json')), allSpec), @@ -102,27 +115,6 @@ function start (opts) { }) }) - function generateApiFile (apiFolder, log) { - var common = null - try { - common = require(join(apiFolder, '_common.json')) - } catch (e) {} - - return function _generateApiFile (file) { - if (file === '_common.json') return - log.text = `Processing ${file}` - - const spec = require(join(apiFolder, file)) - // const { stability } = spec[Object.keys(spec)[0]] - // if (stability !== 'stable') return - allSpec.push(spec) - const code = generate(opts.branch || opts.tag, spec, common) - const filePath = join(apiOutputFolder, `${file.slice(0, file.lastIndexOf('.'))}.js`) - - writeFileSync(filePath, code, { encoding: 'utf8' }) - } - } - function lintFiles (log, cb) { log.text = 'Linting...' const files = [join(packageFolder, '*.js'), join(apiOutputFolder, '*.js')] @@ -133,4 +125,21 @@ function start (opts) { cb() }) } + + function namespacify (apis) { + return apis + .map(api => api.slice(0, -5)) + .filter(api => api !== '_common') + .filter(api => !api.includes('deprecated')) + .reduce((acc, val) => { + if (val.includes('.')) { + val = val.split('.') + acc[val[0]] = acc[val[0]] || [] + acc[val[0]].push(val[1]) + } else { + acc[val] = [] + } + return acc + }, {}) + } } diff --git a/scripts/utils/generateApis.js b/scripts/utils/generateApis.js index bf80a9a36..500c10697 100644 --- a/scripts/utils/generateApis.js +++ b/scripts/utils/generateApis.js @@ -8,6 +8,7 @@ 'use strict' +const { join } = require('path') const dedent = require('dedent') const semver = require('semver') const allowedMethods = { @@ -55,7 +56,115 @@ const ndjsonApi = [ 'xpack.monitoring.bulk' ] -function generate (version, spec, common) { +function generateNamespace (namespace, nested, folders, version) { + const common = require(join(folders.apiFolder, '_common.json')) + let code = dedent` + /* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + 'use strict' + + /* eslint camelcase: 0 */ + /* eslint no-unused-vars: 0 */ + + const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +` + if (nested.length > 0) { + let getters = '' + for (const n of nested) { + if (n.includes('_')) { + const nameSnaked = n + .replace(/\.([a-z])/g, k => k[1].toUpperCase()) + .replace(/_([a-z])/g, k => k[1].toUpperCase()) + getters += `${n}: { get () { return this.${nameSnaked} } },\n` + } + } + const api = generateMultiApi(version, namespace, nested, common, folders) + if (getters.length > 0) { + getters = `Object.defineProperties(${api.namespace}Api.prototype, {\n${getters}})` + } + + code += ` + const acceptedQuerystring = ${JSON.stringify(api.acceptedQuerystring)} + const snakeCase = ${JSON.stringify(api.snakeCase)} + + function ${api.namespace}Api (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError + } + + ${api.code} + + ${getters} + + module.exports = ${api.namespace}Api + ` + } else { + let spec = null + try { + spec = require(join(folders.apiFolder, `${namespace}.json`)) + } catch (err) { + spec = require(join(folders.xPackFolder, `${namespace}.json`)) + } + const api = generateSingleApi(version, spec, common) + code += ` + const acceptedQuerystring = ${JSON.stringify(api.acceptedQuerystring)} + const snakeCase = ${JSON.stringify(api.snakeCase)} + + ${api.code} + + module.exports = ${api.name}Api + ` + } + return code +} + +function generateMultiApi (version, namespace, nested, common, folders) { + const namespaceSnaked = namespace + .replace(/\.([a-z])/g, k => k[1].toUpperCase()) + .replace(/_([a-z])/g, k => k[1].toUpperCase()) + let code = '' + const snakeCase = {} + const acceptedQuerystring = [] + for (const n of nested) { + let spec = null + const nameSnaked = n + .replace(/\.([a-z])/g, k => k[1].toUpperCase()) + .replace(/_([a-z])/g, k => k[1].toUpperCase()) + try { + spec = require(join(folders.apiFolder, `${namespace}.${n}.json`)) + } catch (err) { + spec = require(join(folders.xPackFolder, `${namespace}.${n}.json`)) + } + const api = generateSingleApi(version, spec, common) + code += `${Uppercase(namespaceSnaked)}Api.prototype.${nameSnaked} = ${api.code}\n\n` + Object.assign(snakeCase, api.snakeCase) + for (const q of api.acceptedQuerystring) { + if (!acceptedQuerystring.includes(q)) { + acceptedQuerystring.push(q) + } + } + } + return { code, snakeCase, acceptedQuerystring, namespace: Uppercase(namespaceSnaked) } +} + +function generateSingleApi (version, spec, common) { const release = semver.valid(version) ? semver.major(version) : version const api = Object.keys(spec)[0] const name = api @@ -121,37 +230,15 @@ function generate (version, spec, common) { } const code = ` - function ${safeWords(name)} (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + function ${name}Api (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) ${genRequiredChecks()} ${genUrlValidation(paths, api)} - // 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 { ${genQueryBlacklist(false)}, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) var path = '' ${buildPath(api)} @@ -164,43 +251,18 @@ function generate (version, spec, common) { querystring } - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + return this.transport.request(request, options, callback) } `.trim() // always call trim to avoid newlines - const fn = dedent` - // 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 build${name[0].toUpperCase() + name.slice(1)} (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - ${acceptedQuerystring.map(q => `'${q}'`).join(',\n')} - ] - - const snakeCase = { - ${genSnakeCaseMap()} - } - - ${generateDocumentation(spec[api], api)} - return ${code} + return { + name, + code, + acceptedQuerystring: acceptedQuerystring, + snakeCase: genSnakeCaseMap(), + documentation: generateDocumentation(spec[api], api) } - module.exports = build${name[0].toUpperCase() + name.slice(1)} -` - - // new line at the end of file - return fn + '\n' - function genRequiredChecks (param) { const code = required .map(_genRequiredCheck) @@ -221,7 +283,7 @@ function generate (version, spec, common) { if (param === camelCased) { const check = ` if (params['${param}'] == null) { - const err = new ConfigurationError('Missing required parameter: ${param}') + const err = new this[kConfigurationError]('Missing required parameter: ${param}') return handleError(err, callback) } ` @@ -229,7 +291,7 @@ function generate (version, spec, common) { } else { const check = ` if (params['${param}'] == null && params['${camelCased}'] == null) { - const err = new ConfigurationError('Missing required parameter: ${param} or ${camelCased}') + const err = new this[kConfigurationError]('Missing required parameter: ${param} or ${camelCased}') return handleError(err, callback) } ` @@ -240,7 +302,7 @@ function generate (version, spec, common) { function _noBody () { const check = ` if (params.body != null) { - const err = new ConfigurationError('This API does not require a body') + const err = new this[kConfigurationError]('This API does not require a body') return handleError(err, callback) } ` @@ -257,13 +319,10 @@ function generate (version, spec, common) { return acceptedQuerystring.reduce((acc, val, index) => { if (toCamelCase(val) !== val) { - acc += `${toCamelCase(val)}: '${val}'` - if (index !== acceptedQuerystring.length - 1) { - acc += ',\n' - } + acc[toCamelCase(val)] = val } return acc - }, '') + }, {}) } function genQueryBlacklist (addQuotes = true) { @@ -333,13 +392,11 @@ function generate (version, spec, common) { for (var i = 0; i < sortedPaths.length; i++) { const { path, methods } = sortedPaths[i] if (sortedPaths.length === 1) { - code += ` - if (method == null) method = ${generatePickMethod(methods)} + code += `if (method == null) method = ${generatePickMethod(methods)} path = ${genPath(path)} ` } else if (i === 0) { - code += ` - if (${genCheck(path)}) { + code += `if (${genCheck(path)}) { if (method == null) method = ${generatePickMethod(methods)} path = ${genPath(path)} } @@ -359,60 +416,10 @@ function generate (version, spec, common) { } } - // var hasStaticPath = false - // var singlePathComponent = false - // paths - // .filter(path => { - // if (path.indexOf('{') > -1) return true - // if (hasStaticPath === false) { - // hasStaticPath = true - // return true - // } - // return false - // }) - // .sort((a, b) => (b.split('{').length + b.split('/').length) - (a.split('{').length + a.split('/').length)) - // .forEach((path, index, arr) => { - // if (arr.length === 1) { - // singlePathComponent = true - // code += ` - // path = ${genPath(path)} - // ` - // } else if (index === 0) { - // code += ` - // if (${genCheck(path)}) { - // path = ${genPath(path)} - // ` - // } else if (index === arr.length - 1) { - // code += ` - // } else { - // path = ${genPath(path)} - // ` - // } else { - // code += ` - // } else if (${genCheck(path)}) { - // path = ${genPath(path)} - // ` - // } - // }) - - // code += singlePathComponent ? '' : '}' return code } } -function safeWords (str) { - switch (str) { - // delete is a reserved word - case 'delete': - return '_delete' - // index is also a parameter - case 'index': - return '_index' - default: - return str - } -} - function generatePickMethod (methods) { if (methods.length === 1) { return `'${methods[0]}'` @@ -499,7 +506,7 @@ function genUrlValidation (paths, api) { } } code += `)) { - const err = new ConfigurationError('Missing required parameter of the url: ${params.join(', ')}') + const err = new this[kConfigurationError]('Missing required parameter of the url: ${params.join(', ')}') return handleError(err, callback) ` }) @@ -544,5 +551,9 @@ function intersect (first, ...rest) { }, first) } -module.exports = generate +function Uppercase (str) { + return str[0].toUpperCase() + str.slice(1) +} + +module.exports = generateNamespace module.exports.ndjsonApi = ndjsonApi diff --git a/scripts/utils/generateMain.js b/scripts/utils/generateMain.js index 9a761eb87..4c6557d03 100644 --- a/scripts/utils/generateMain.js +++ b/scripts/utils/generateMain.js @@ -20,24 +20,29 @@ const ndjsonApiKey = ndjsonApi }) .map(toPascalCase) -function genFactory (folder, paths) { +function genFactory (folder, paths, namespaces) { // get all the API files - const apiFiles = readdirSync(folder) + // const apiFiles = readdirSync(folder) + const apiFiles = readdirSync(paths[0]) + .concat(readdirSync(paths[1])) + .filter(file => file !== '_common.json') + .filter(file => !file.includes('deprecated')) + .sort() const types = apiFiles .map(file => { const name = file - .slice(0, -3) + .slice(0, -5) .replace(/\.([a-z])/g, k => k[1].toUpperCase()) .replace(/_([a-z])/g, k => k[1].toUpperCase()) return file - .slice(0, -3) // remove `.js` extension + .slice(0, -5) // remove `.json` extension .split('.') .reverse() .reduce((acc, val) => { - const spec = readSpec(paths, file.slice(0, -3)) - const isHead = isHeadMethod(spec, file.slice(0, -3)) - const body = hasBody(spec, file.slice(0, -3)) + const spec = readSpec(paths, file.slice(0, -5)) + const isHead = isHeadMethod(spec, file.slice(0, -5)) + const body = hasBody(spec, file.slice(0, -5)) const methods = acc === null ? buildMethodDefinition({ kibana: false }, val, name, body, isHead) : null const obj = {} if (methods) { @@ -58,18 +63,18 @@ function genFactory (folder, paths) { const kibanaTypes = apiFiles .map(file => { const name = file - .slice(0, -3) + .slice(0, -5) .replace(/\.([a-z])/g, k => k[1].toUpperCase()) .replace(/_([a-z])/g, k => k[1].toUpperCase()) return file - .slice(0, -3) // remove `.js` extension + .slice(0, -5) // remove `.json` extension .split('.') .reverse() .reduce((acc, val) => { - const spec = readSpec(paths, file.slice(0, -3)) - const isHead = isHeadMethod(spec, file.slice(0, -3)) - const body = hasBody(spec, file.slice(0, -3)) + const spec = readSpec(paths, file.slice(0, -5)) + const isHead = isHeadMethod(spec, file.slice(0, -5)) + const body = hasBody(spec, file.slice(0, -5)) const methods = acc === null ? buildMethodDefinition({ kibana: true }, val, name, body, isHead) : null const obj = {} if (methods) { @@ -84,37 +89,6 @@ function genFactory (folder, paths) { }) .reduce((acc, val) => deepmerge(acc, val), {}) - const apis = apiFiles - .map(file => { - // const name = format(file.slice(0, -3)) - return file - .slice(0, -3) // remove `.js` extension - .split('.') - .reverse() - .reduce((acc, val) => { - const obj = { - [val]: acc === null - ? `lazyLoad('${file.slice(0, -3)}', opts)` // `${name}(opts)` - : acc - } - if (isSnakeCased(val)) { - obj[camelify(val)] = acc === null - ? `lazyLoad('${file.slice(0, -3)}', opts)` // `${name}(opts)` - : acc - } - return obj - }, null) - }) - .reduce((acc, val) => deepmerge(acc, val), {}) - - // serialize the API object - const apisStr = JSON.stringify(apis, null, 2) - // split & join to fix the indentation - .split('\n') - .join('\n ') - // remove useless quotes - .replace(/"/g, '') - // serialize the type object const typesStr = Object.keys(types) .map(key => { @@ -141,6 +115,48 @@ function genFactory (folder, paths) { .replace(/"/g, '') .replace(/,$/gm, '') + let apisStr = '' + const getters = [] + for (const namespace in namespaces) { + if (namespaces[namespace].length > 0) { + getters.push(`${camelify(namespace)}: { + get () { + if (this[k${toPascalCase(camelify(namespace))}] === null) { + this[k${toPascalCase(camelify(namespace))}] = new ${toPascalCase(camelify(namespace))}Api(this.transport, this[kConfigurationError]) + } + return this[k${toPascalCase(camelify(namespace))}] + } + },\n`) + if (namespace.includes('_')) { + getters.push(`${namespace}: { get () { return this.${camelify(namespace)} } },\n`) + } + } else { + apisStr += `ESAPI.prototype.${camelify(namespace)} = ${camelify(namespace)}Api\n` + if (namespace.includes('_')) { + getters.push(`${namespace}: { get () { return this.${camelify(namespace)} } },\n`) + } + } + } + + apisStr += '\nObject.defineProperties(ESAPI.prototype, {\n' + for (const getter of getters) { + apisStr += getter + } + apisStr += '})' + + let modules = '' + let symbols = '' + let symbolsInstance = '' + for (const namespace in namespaces) { + if (namespaces[namespace].length > 0) { + modules += `const ${toPascalCase(camelify(namespace))}Api = require('./api/${namespace}')\n` + symbols += `const k${toPascalCase(camelify(namespace))} = Symbol('${toPascalCase(camelify(namespace))}')\n` + symbolsInstance += `this[k${toPascalCase(camelify(namespace))}] = null\n` + } else { + modules += `const ${camelify(namespace)}Api = require('./api/${namespace}')\n` + } + } + const fn = dedent` // Licensed to Elasticsearch B.V under one or more agreements. // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. @@ -148,62 +164,17 @@ function genFactory (folder, paths) { 'use strict' - const assert = require('assert') + ${modules} + + const { kConfigurationError } = require('./utils') + ${symbols} function ESAPI (opts) { - assert(opts.makeRequest, 'Missing makeRequest function') - assert(opts.ConfigurationError, 'Missing ConfigurationError class') - assert(opts.result, 'Missing default result object') - - const { result } = opts - opts.handleError = handleError - opts.snakeCaseKeys = snakeCaseKeys - - const apis = ${apisStr} - - - return apis - - function handleError (err, callback) { - if (callback) { - process.nextTick(callback, err, result) - return { then: noop, catch: noop, abort: noop } - } - return Promise.reject(err) - } - - function snakeCaseKeys (acceptedQuerystring, snakeCase, querystring, warnings) { - var target = {} - var keys = Object.keys(querystring) - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - target[snakeCase[key] || key] = querystring[key] - if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { - warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') - } - } - return target - } + this[kConfigurationError] = opts.ConfigurationError + ${symbolsInstance} } - // It's unlikely that a user needs all of our APIs, - // and since require is a sync operation that takes time - // (given the amount of APIs we have), let's lazy load them, - // so a given API file will be required only - // if the user actually needs that API. - // The following implementation takes advantage - // of js closures to have a simple cache with the least overhead. - function lazyLoad (file, opts) { - var fn = null - return function _lazyLoad (params, options, callback) { - if (fn === null) { - fn = require(${'`./api/${file}.js`'})(opts) - } - return fn(params, options, callback) - } - } - - function noop () {} + ${apisStr} module.exports = ESAPI ` diff --git a/test/bundlers/parcel-test/index.js b/test/bundlers/parcel-test/index.js new file mode 100644 index 000000000..792b4b873 --- /dev/null +++ b/test/bundlers/parcel-test/index.js @@ -0,0 +1,7 @@ +'use strict' + +const { Client } = require('../../../index') +const client = new Client({ node: 'http://localhost:9200' }) +client.info((err, result) => { + process.exit(err ? 1 : 0) +}) diff --git a/test/bundlers/parcel-test/package.json b/test/bundlers/parcel-test/package.json new file mode 100644 index 000000000..3f02de1db --- /dev/null +++ b/test/bundlers/parcel-test/package.json @@ -0,0 +1,16 @@ +{ + "name": "parcel-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node bundle.js", + "build": "parcel build index.js --target node --bundle-node-modules --out-file bundle.js --no-source-maps --out-dir ." + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "parcel-bundler": "^1.12.4" + } +} diff --git a/test/bundlers/rollup-test/index.js b/test/bundlers/rollup-test/index.js new file mode 100644 index 000000000..792b4b873 --- /dev/null +++ b/test/bundlers/rollup-test/index.js @@ -0,0 +1,7 @@ +'use strict' + +const { Client } = require('../../../index') +const client = new Client({ node: 'http://localhost:9200' }) +client.info((err, result) => { + process.exit(err ? 1 : 0) +}) diff --git a/test/bundlers/rollup-test/package.json b/test/bundlers/rollup-test/package.json new file mode 100644 index 000000000..7f74a670d --- /dev/null +++ b/test/bundlers/rollup-test/package.json @@ -0,0 +1,19 @@ +{ + "name": "rollup-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node bundle.js", + "build": "rollup -c" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@rollup/plugin-commonjs": "^15.1.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^9.0.0", + "rollup": "^2.28.0" + } +} diff --git a/test/bundlers/rollup-test/rollup.config.js b/test/bundlers/rollup-test/rollup.config.js new file mode 100644 index 000000000..55a936824 --- /dev/null +++ b/test/bundlers/rollup-test/rollup.config.js @@ -0,0 +1,13 @@ +import resolve from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' +import json from '@rollup/plugin-json' + +export default { + input: 'index.js', + output: { + file: 'bundle.js', + format: 'iife', + name: 'MyModule' + }, + plugins: [resolve(), commonjs({ include: ['../../../node_modules/**'] }), json()] +} diff --git a/test/bundlers/webpack-test/index.js b/test/bundlers/webpack-test/index.js new file mode 100644 index 000000000..792b4b873 --- /dev/null +++ b/test/bundlers/webpack-test/index.js @@ -0,0 +1,7 @@ +'use strict' + +const { Client } = require('../../../index') +const client = new Client({ node: 'http://localhost:9200' }) +client.info((err, result) => { + process.exit(err ? 1 : 0) +}) diff --git a/test/bundlers/webpack-test/package.json b/test/bundlers/webpack-test/package.json new file mode 100644 index 000000000..12e6b80f6 --- /dev/null +++ b/test/bundlers/webpack-test/package.json @@ -0,0 +1,17 @@ +{ + "name": "webpack-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node bundle.js", + "build": "webpack" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "webpack": "^4.44.2", + "webpack-cli": "^3.3.12" + } +} diff --git a/test/bundlers/webpack-test/webpack.config.js b/test/bundlers/webpack-test/webpack.config.js new file mode 100644 index 000000000..d4da84724 --- /dev/null +++ b/test/bundlers/webpack-test/webpack.config.js @@ -0,0 +1,12 @@ +'use strict' + +const path = require('path') + +module.exports = { + entry: './index.js', + target: 'node', + output: { + filename: 'bundle.js', + path: path.resolve(__dirname) + } +} diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index ecd16c442..0fcf1bcbf 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -42,13 +42,19 @@ function build (opts = {}) { stash.clear() try { - await client.indices.deleteAlias({ index: '_all', name: '_all' }, { ignore: 404 }) + await client.indices.deleteAlias({ + index: '_all', + name: '_all' + }, { ignore: [404] }) } catch (err) { assert.ifError(err, 'should not error: indices.deleteAlias') } try { - await client.indices.delete({ index: '_all', expandWildcards: 'all' }, { ignore: 404 }) + await client.indices.delete({ + index: '_all', + expand_wildcards: 'open,closed,hidden' + }, { ignore: [404] }) } catch (err) { assert.ifError(err, 'should not error: indices.delete') } @@ -371,6 +377,7 @@ function build (opts = {}) { } const options = { ignore: cmd.params.ignore, headers: action.headers } + if (!Array.isArray(options.ignore)) options.ignore = [options.ignore] if (cmd.params.ignore) delete cmd.params.ignore const [err, result] = await to(api(cmd.params, options)) diff --git a/test/unit/api.test.js b/test/unit/api.test.js index 13e1361fd..aab42556e 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -218,33 +218,6 @@ test('Basic (options and promises)', t => { }) }) -test('Pass unknown parameters as query parameters (and get a warning)', t => { - t.plan(4) - - function handler (req, res) { - t.strictEqual(req.url, '/test/_search?q=foo%3Abar&winter=is%20coming') - 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', - winter: 'is coming' - }, (err, { body, warnings }) => { - t.error(err) - t.deepEqual(body, { hello: 'world' }) - t.deepEqual(warnings, ['Client - Unknown parameter: "winter", sending it as query parameter']) - server.stop() - }) - }) -}) - test('If the API uses the same key for both url and query parameter, the url should win', t => { t.plan(2) diff --git a/test/unit/child.test.js b/test/unit/child.test.js index e6a2b91ea..5fff00e8b 100644 --- a/test/unit/child.test.js +++ b/test/unit/child.test.js @@ -265,3 +265,41 @@ test('Should create a child client (name check)', t => { child.info(t.error) }) }) + +test('Should create a child client (auth check)', t => { + t.plan(4) + + var count = 0 + function handler (req, res) { + if (count++ === 0) { + t.match(req.headers, { authorization: 'Basic Zm9vOmJhcg==' }) + } else { + t.match(req.headers, { authorization: 'ApiKey foobar' }) + } + 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}`, + auth: { + username: 'foo', + password: 'bar' + } + }) + const child = client.child({ + auth: { + apiKey: 'foobar' + } + }) + + client.info((err, res) => { + t.error(err) + child.info((err, res) => { + t.error(err) + server.stop() + }) + }) + }) +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 169b2df98..a19ce22f9 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -1791,45 +1791,6 @@ test('Warning header', t => { }) }) - t.test('Multiple warnings and external warning', t => { - t.plan(5) - - const warn1 = '112 - "cache down" "Wed, 21 Oct 2015 07:28:00 GMT"' - const warn2 = '199 agent "Error message" "2015-01-01"' - function handler (req, res) { - res.setHeader('Content-Type', 'application/json;utf=8') - res.setHeader('Warning', warn1 + ',' + warn2) - res.end(JSON.stringify({ hello: 'world' })) - } - - buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ Connection }) - pool.addConnection(`http://localhost:${port}`) - - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 3, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) - - transport.request({ - method: 'GET', - path: '/hello' - }, { - warnings: ['winter is coming'] - }, (err, { warnings }) => { - t.error(err) - t.deepEqual(warnings, ['winter is coming', warn1, warn2]) - warnings.forEach(w => t.type(w, 'string')) - server.stop() - }) - }) - }) - t.end() })