From 1f1b4c29fad92a392b9b45316c24fd923af9c482 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 29 Jul 2019 11:39:50 +0200 Subject: [PATCH] API generation --- api/api/ilm.explain_lifecycle.js | 8 ++- api/api/indices.clone.js | 106 +++++++++++++++++++++++++++++++ api/index.js | 1 + api/requestParams.d.ts | 11 ++++ docs/reference.asciidoc | 45 ++++++++++++- index.d.ts | 1 + 6 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 api/api/indices.clone.js diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js index 34eb2c9e2..b9734b4bb 100644 --- a/api/api/ilm.explain_lifecycle.js +++ b/api/api/ilm.explain_lifecycle.js @@ -14,14 +14,18 @@ function buildIlmExplainLifecycle (opts) { * Perform a [ilm.explain_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html) request * * @param {string} index - The name of the index to explain + * @param {boolean} only_managed - filters the indices included in the response to ones managed by ILM + * @param {boolean} only_errors - filters the indices included in the response to ones in an ILM error state, implies only_managed */ const acceptedQuerystring = [ - + 'only_managed', + 'only_errors' ] const snakeCase = { - + onlyManaged: 'only_managed', + onlyErrors: 'only_errors' } return function ilmExplainLifecycle (params, options, callback) { diff --git a/api/api/indices.clone.js b/api/api/indices.clone.js new file mode 100644 index 000000000..5c3a522a0 --- /dev/null +++ b/api/api/indices.clone.js @@ -0,0 +1,106 @@ +// 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 buildIndicesClone (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + /** + * Perform a [indices.clone](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clone-index.html) request + * + * @param {string} index - The name of the source index to clone + * @param {string} target - The name of the target index to clone into + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @param {string} wait_for_active_shards - Set the number of active shards to wait for on the cloned index before the operation returns. + * @param {object} body - The configuration for the target index (`settings` and `aliases`) + */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'wait_for_active_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + waitForActiveShards: 'wait_for_active_shards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + return function indicesClone (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['index'] == null) { + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) + } + if (params['target'] == null) { + const err = new ConfigurationError('Missing required parameter: target') + return handleError(err, callback) + } + + // check required url components + if (params['target'] != 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, target, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_clone' + '/' + encodeURIComponent(target) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildIndicesClone diff --git a/api/index.js b/api/index.js index 92ebd15a5..dc0255be1 100644 --- a/api/index.js +++ b/api/index.js @@ -159,6 +159,7 @@ function ESAPI (opts) { analyze: lazyLoad('indices.analyze', opts), clear_cache: lazyLoad('indices.clear_cache', opts), clearCache: lazyLoad('indices.clear_cache', opts), + clone: lazyLoad('indices.clone', opts), close: lazyLoad('indices.close', opts), create: lazyLoad('indices.create', opts), delete: lazyLoad('indices.delete', opts), diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 486988947..08863fb02 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -558,6 +558,15 @@ export interface IndicesClearCache extends Generic { request?: boolean; } +export interface IndicesClone extends Generic { + index: string; + target: string; + timeout?: string; + master_timeout?: string; + wait_for_active_shards?: string; + body?: T; +} + export interface IndicesClose extends Generic { index: string | string[]; timeout?: string; @@ -1418,6 +1427,8 @@ export interface IlmDeleteLifecycle extends Generic { export interface IlmExplainLifecycle extends Generic { index?: string; + only_managed?: boolean; + only_errors?: boolean; } export interface IlmGetLifecycle extends Generic { diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 39ff97e3b..e22bd9a45 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -2143,6 +2143,41 @@ _Default:_ `open` |=== +=== indices.clone +[source,ts] +---- +client.indices.clone({ + index: string, + target: string, + timeout: string, + master_timeout: string, + wait_for_active_shards: string, + body: object +}) +---- +link:{ref}/indices-clone-index.html[Reference] +[cols=2*] +|=== +|`index` +|`string` - The name of the source index to clone + +|`target` +|`string` - The name of the target index to clone into + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Set the number of active shards to wait for on the cloned index before the operation returns. + +|`body` +|`object` - The configuration for the target index (`settings` and `aliases`) + +|=== + === indices.close [source,ts] ---- @@ -5509,7 +5544,9 @@ link:{ref}/ilm-delete-lifecycle.html[Reference] [source,ts] ---- client.ilm.explainLifecycle({ - index: string + index: string, + only_managed: boolean, + only_errors: boolean }) ---- link:{ref}/ilm-explain-lifecycle.html[Reference] @@ -5518,6 +5555,12 @@ link:{ref}/ilm-explain-lifecycle.html[Reference] |`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 diff --git a/index.d.ts b/index.d.ts index 1357bb2ae..ad404495c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -257,6 +257,7 @@ declare class Client extends EventEmitter { analyze: ApiMethod clear_cache: ApiMethod clearCache: ApiMethod + clone: ApiMethod close: ApiMethod create: ApiMethod delete: ApiMethod