From cfc21f56c2d335294222f3d8d085f6ea2a875092 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 10 Apr 2020 12:21:27 +0200 Subject: [PATCH] API generation --- api/api/indices.exists_index_template.js | 88 +++++++++++++++++++++ api/api/searchable_snapshots.clear_cache.js | 2 +- api/api/searchable_snapshots.mount.js | 2 +- api/api/searchable_snapshots.stats.js | 2 +- api/index.js | 2 + api/requestParams.d.ts | 7 ++ docs/reference.asciidoc | 30 ++++++- index.d.ts | 8 ++ 8 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 api/api/indices.exists_index_template.js diff --git a/api/api/indices.exists_index_template.js b/api/api/indices.exists_index_template.js new file mode 100644 index 000000000..5bb126810 --- /dev/null +++ b/api/api/indices.exists_index_template.js @@ -0,0 +1,88 @@ +// 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 buildIndicesExistsIndexTemplate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + 'flat_settings', + 'master_timeout', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + flatSettings: 'flat_settings', + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + /** + * Perform a indices.exists_index_template request + * Returns information about whether a particular index template exists. + * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + */ + return function indicesExistsIndexTemplate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'HEAD' + path = '/' + '_index_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildIndicesExistsIndexTemplate diff --git a/api/api/searchable_snapshots.clear_cache.js b/api/api/searchable_snapshots.clear_cache.js index f30c6a612..79a5d0712 100644 --- a/api/api/searchable_snapshots.clear_cache.js +++ b/api/api/searchable_snapshots.clear_cache.js @@ -27,7 +27,7 @@ function buildSearchableSnapshotsClearCache (opts) { /** * Perform a searchable_snapshots.clear_cache request - * https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-clear-cache.html + * https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-clear-cache.html */ return function searchableSnapshotsClearCache (params, options, callback) { options = options || {} diff --git a/api/api/searchable_snapshots.mount.js b/api/api/searchable_snapshots.mount.js index f055d057f..6c704c528 100644 --- a/api/api/searchable_snapshots.mount.js +++ b/api/api/searchable_snapshots.mount.js @@ -23,7 +23,7 @@ function buildSearchableSnapshotsMount (opts) { /** * Perform a searchable_snapshots.mount request - * https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-mount-snapshot + * https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-mount-snapshot.html */ return function searchableSnapshotsMount (params, options, callback) { options = options || {} diff --git a/api/api/searchable_snapshots.stats.js b/api/api/searchable_snapshots.stats.js index 899d83897..a1a3d6fba 100644 --- a/api/api/searchable_snapshots.stats.js +++ b/api/api/searchable_snapshots.stats.js @@ -21,7 +21,7 @@ function buildSearchableSnapshotsStats (opts) { /** * Perform a searchable_snapshots.stats request - * https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-stats.html + * https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-stats.html */ return function searchableSnapshotsStats (params, options, callback) { options = options || {} diff --git a/api/index.js b/api/index.js index dc63a7a9e..fd75aa869 100644 --- a/api/index.js +++ b/api/index.js @@ -239,6 +239,8 @@ function ESAPI (opts) { exists: lazyLoad('indices.exists', opts), exists_alias: lazyLoad('indices.exists_alias', opts), existsAlias: lazyLoad('indices.exists_alias', opts), + exists_index_template: lazyLoad('indices.exists_index_template', opts), + existsIndexTemplate: lazyLoad('indices.exists_index_template', opts), exists_template: lazyLoad('indices.exists_template', opts), existsTemplate: lazyLoad('indices.exists_template', opts), exists_type: lazyLoad('indices.exists_type', opts), diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 9123c92f9..85e6a444d 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -673,6 +673,13 @@ export interface IndicesExistsAlias extends Generic { local?: boolean; } +export interface IndicesExistsIndexTemplate extends Generic { + name: string; + flat_settings?: boolean; + master_timeout?: string; + local?: boolean; +} + export interface IndicesExistsTemplate extends Generic { name: string | string[]; flat_settings?: boolean; diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 3e8cd9e8b..ff225854f 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -2699,6 +2699,34 @@ _Default:_ `all` |=== +=== indices.existsIndexTemplate + +[source,ts] +---- +client.indices.existsIndexTemplate({ + name: string, + flat_settings: boolean, + master_timeout: string, + local: boolean +}) +---- +link:{ref}/indices-templates.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the template + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`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) + +|=== + === indices.existsTemplate [source,ts] @@ -8814,7 +8842,7 @@ client.searchableSnapshots.mount({ body: object }) ---- - +link:{ref}/searchable-snapshots-api-mount-snapshot.html[Documentation] + [cols=2*] |=== |`repository` diff --git a/index.d.ts b/index.d.ts index 46bd2a26c..e3eecf68e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -929,6 +929,14 @@ declare class Client extends EventEmitter { existsAlias, TContext = unknown>(callback: callbackFn): TransportRequestCallback existsAlias, TContext = unknown>(params: RequestParams.IndicesExistsAlias, callback: callbackFn): TransportRequestCallback existsAlias, TContext = unknown>(params: RequestParams.IndicesExistsAlias, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + exists_index_template, TContext = unknown>(params?: RequestParams.IndicesExistsIndexTemplate, options?: TransportRequestOptions): TransportRequestPromise> + exists_index_template, TContext = unknown>(callback: callbackFn): TransportRequestCallback + exists_index_template, TContext = unknown>(params: RequestParams.IndicesExistsIndexTemplate, callback: callbackFn): TransportRequestCallback + exists_index_template, TContext = unknown>(params: RequestParams.IndicesExistsIndexTemplate, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + existsIndexTemplate, TContext = unknown>(params?: RequestParams.IndicesExistsIndexTemplate, options?: TransportRequestOptions): TransportRequestPromise> + existsIndexTemplate, TContext = unknown>(callback: callbackFn): TransportRequestCallback + existsIndexTemplate, TContext = unknown>(params: RequestParams.IndicesExistsIndexTemplate, callback: callbackFn): TransportRequestCallback + existsIndexTemplate, TContext = unknown>(params: RequestParams.IndicesExistsIndexTemplate, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback exists_template, TContext = unknown>(params?: RequestParams.IndicesExistsTemplate, options?: TransportRequestOptions): TransportRequestPromise> exists_template, TContext = unknown>(callback: callbackFn): TransportRequestCallback exists_template, TContext = unknown>(params: RequestParams.IndicesExistsTemplate, callback: callbackFn): TransportRequestCallback