From 8522f303ee75a27f8a5f6b6013ed3f0d6e1583a8 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 7 Apr 2020 10:44:50 +0200 Subject: [PATCH] API generation --- api/api/cluster.exists_component_template.js | 86 ++++++++++++++++ api/api/searchable_snapshots.clear_cache.js | 82 +++++++++++++++ api/api/searchable_snapshots.mount.js | 93 +++++++++++++++++ api/api/searchable_snapshots.stats.js | 76 ++++++++++++++ api/index.js | 14 +++ api/requestParams.d.ts | 25 +++++ docs/reference.asciidoc | 103 ++++++++++++++++++- index.d.ts | 44 ++++++++ 8 files changed, 522 insertions(+), 1 deletion(-) create mode 100644 api/api/cluster.exists_component_template.js create mode 100644 api/api/searchable_snapshots.clear_cache.js create mode 100644 api/api/searchable_snapshots.mount.js create mode 100644 api/api/searchable_snapshots.stats.js diff --git a/api/api/cluster.exists_component_template.js b/api/api/cluster.exists_component_template.js new file mode 100644 index 000000000..8860da8a6 --- /dev/null +++ b/api/api/cluster.exists_component_template.js @@ -0,0 +1,86 @@ +// 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 buildClusterExistsComponentTemplate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + 'master_timeout', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + /** + * Perform a cluster.exists_component_template request + * Returns information about whether a particular component template exist + * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html + */ + return function clusterExistsComponentTemplate (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 = '/' + '_component_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 = buildClusterExistsComponentTemplate diff --git a/api/api/searchable_snapshots.clear_cache.js b/api/api/searchable_snapshots.clear_cache.js new file mode 100644 index 000000000..f30c6a612 --- /dev/null +++ b/api/api/searchable_snapshots.clear_cache.js @@ -0,0 +1,82 @@ +// 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 buildSearchableSnapshotsClearCache (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'index' + ] + + const snakeCase = { + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards' + + } + + /** + * Perform a searchable_snapshots.clear_cache request + * https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-clear-cache.html + */ + return function searchableSnapshotsClearCache (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) + '/' + '_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 + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildSearchableSnapshotsClearCache diff --git a/api/api/searchable_snapshots.mount.js b/api/api/searchable_snapshots.mount.js new file mode 100644 index 000000000..f055d057f --- /dev/null +++ b/api/api/searchable_snapshots.mount.js @@ -0,0 +1,93 @@ +// 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 buildSearchableSnapshotsMount (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + 'master_timeout', + 'wait_for_completion' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + waitForCompletion: 'wait_for_completion' + } + + /** + * Perform a searchable_snapshots.mount request + * https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-mount-snapshot + */ + return function searchableSnapshotsMount (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['repository'] == null) { + const err = new ConfigurationError('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new ConfigurationError('Missing required parameter: snapshot') + 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['snapshot'] != null && (params['repository'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: repository') + 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, repository, snapshot, ...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 = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_mount' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildSearchableSnapshotsMount diff --git a/api/api/searchable_snapshots.stats.js b/api/api/searchable_snapshots.stats.js new file mode 100644 index 000000000..899d83897 --- /dev/null +++ b/api/api/searchable_snapshots.stats.js @@ -0,0 +1,76 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSearchableSnapshotsStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + /** + * Perform a searchable_snapshots.stats request + * https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-stats.html + */ + return function searchableSnapshotsStats (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 = '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 + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildSearchableSnapshotsStats diff --git a/api/index.js b/api/index.js index 860f9296d..dc63a7a9e 100644 --- a/api/index.js +++ b/api/index.js @@ -102,6 +102,8 @@ function ESAPI (opts) { allocationExplain: lazyLoad('cluster.allocation_explain', opts), delete_component_template: lazyLoad('cluster.delete_component_template', opts), deleteComponentTemplate: lazyLoad('cluster.delete_component_template', opts), + exists_component_template: lazyLoad('cluster.exists_component_template', opts), + existsComponentTemplate: lazyLoad('cluster.exists_component_template', opts), get_component_template: lazyLoad('cluster.get_component_template', opts), getComponentTemplate: lazyLoad('cluster.get_component_template', opts), get_settings: lazyLoad('cluster.get_settings', opts), @@ -488,6 +490,18 @@ function ESAPI (opts) { searchShards: lazyLoad('search_shards', opts), search_template: lazyLoad('search_template', opts), searchTemplate: lazyLoad('search_template', opts), + searchable_snapshots: { + clear_cache: lazyLoad('searchable_snapshots.clear_cache', opts), + clearCache: lazyLoad('searchable_snapshots.clear_cache', opts), + mount: lazyLoad('searchable_snapshots.mount', opts), + stats: lazyLoad('searchable_snapshots.stats', opts) + }, + searchableSnapshots: { + clear_cache: lazyLoad('searchable_snapshots.clear_cache', opts), + clearCache: lazyLoad('searchable_snapshots.clear_cache', opts), + mount: lazyLoad('searchable_snapshots.mount', opts), + stats: lazyLoad('searchable_snapshots.stats', opts) + }, security: { authenticate: lazyLoad('security.authenticate', opts), change_password: lazyLoad('security.change_password', opts), diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 0d32c7998..9123c92f9 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -268,6 +268,12 @@ export interface ClusterDeleteComponentTemplate extends Generic { master_timeout?: string; } +export interface ClusterExistsComponentTemplate extends Generic { + name: string; + master_timeout?: string; + local?: boolean; +} + export interface ClusterGetComponentTemplate extends Generic { name?: string | string[]; master_timeout?: string; @@ -2181,6 +2187,25 @@ export interface RollupStopJob extends Generic { timeout?: string; } +export interface SearchableSnapshotsClearCache extends Generic { + index?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; +} + +export interface SearchableSnapshotsMount extends Generic { + repository: string; + snapshot: string; + master_timeout?: string; + wait_for_completion?: boolean; + body: T; +} + +export interface SearchableSnapshotsStats extends Generic { + index?: string | string[]; +} + export interface SecurityAuthenticate extends Generic { } diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index c7ebdfb33..66e4513bc 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -1109,6 +1109,30 @@ link:{ref}/indices-component-templates.html[Documentation] + |=== +=== cluster.existsComponentTemplate + +[source,ts] +---- +client.cluster.existsComponentTemplate({ + name: string, + master_timeout: string, + local: boolean +}) +---- +link:{ref}/indices-component-templates.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the template + +|`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) + +|=== + === cluster.getComponentTemplate [source,ts] @@ -5118,7 +5142,7 @@ link:{ref}/tasks.html[Documentation] + |`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 child tasks is completed. Defaults to false +|`boolean` - Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false |=== @@ -8749,6 +8773,83 @@ link:{ref}/rollup-stop-job.html[Documentation] + |=== +=== searchableSnapshots.clearCache +*Stability:* experimental +[source,ts] +---- +client.searchableSnapshots.clearCache({ + index: string | string[], + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'none' | 'all' +}) +---- +link:{ref}/searchable-snapshots-api-clear-cache.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names + +|`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` + +|=== + +=== searchableSnapshots.mount +*Stability:* experimental +[source,ts] +---- +client.searchableSnapshots.mount({ + repository: string, + snapshot: string, + master_timeout: string, + wait_for_completion: boolean, + body: object +}) +---- +link:https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-mount-snapshot[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - The name of the repository containing the snapshot of the index to mount + +|`snapshot` +|`string` - The name of the snapshot of the index to mount + +|`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 restore configuration for mounting the snapshot as searchable + +|=== + +=== searchableSnapshots.stats +*Stability:* experimental +[source,ts] +---- +client.searchableSnapshots.stats({ + index: string | string[] +}) +---- +link:{ref}/searchable-snapshots-api-stats.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names + +|=== + === security.authenticate [source,ts] diff --git a/index.d.ts b/index.d.ts index 197c7a6b9..46bd2a26c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -423,6 +423,14 @@ declare class Client extends EventEmitter { deleteComponentTemplate, TContext = unknown>(callback: callbackFn): TransportRequestCallback deleteComponentTemplate, TContext = unknown>(params: RequestParams.ClusterDeleteComponentTemplate, callback: callbackFn): TransportRequestCallback deleteComponentTemplate, TContext = unknown>(params: RequestParams.ClusterDeleteComponentTemplate, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + exists_component_template, TContext = unknown>(params?: RequestParams.ClusterExistsComponentTemplate, options?: TransportRequestOptions): TransportRequestPromise> + exists_component_template, TContext = unknown>(callback: callbackFn): TransportRequestCallback + exists_component_template, TContext = unknown>(params: RequestParams.ClusterExistsComponentTemplate, callback: callbackFn): TransportRequestCallback + exists_component_template, TContext = unknown>(params: RequestParams.ClusterExistsComponentTemplate, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + existsComponentTemplate, TContext = unknown>(params?: RequestParams.ClusterExistsComponentTemplate, options?: TransportRequestOptions): TransportRequestPromise> + existsComponentTemplate, TContext = unknown>(callback: callbackFn): TransportRequestCallback + existsComponentTemplate, TContext = unknown>(params: RequestParams.ClusterExistsComponentTemplate, callback: callbackFn): TransportRequestCallback + existsComponentTemplate, TContext = unknown>(params: RequestParams.ClusterExistsComponentTemplate, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback get_component_template, TContext = unknown>(params?: RequestParams.ClusterGetComponentTemplate, options?: TransportRequestOptions): TransportRequestPromise> get_component_template, TContext = unknown>(callback: callbackFn): TransportRequestCallback get_component_template, TContext = unknown>(params: RequestParams.ClusterGetComponentTemplate, callback: callbackFn): TransportRequestCallback @@ -1880,6 +1888,42 @@ declare class Client extends EventEmitter { searchTemplate, TRequestBody extends RequestBody = Record, TContext = unknown>(callback: callbackFn): TransportRequestCallback searchTemplate, TRequestBody extends RequestBody = Record, TContext = unknown>(params: RequestParams.SearchTemplate, callback: callbackFn): TransportRequestCallback searchTemplate, TRequestBody extends RequestBody = Record, TContext = unknown>(params: RequestParams.SearchTemplate, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + searchable_snapshots: { + clear_cache, TContext = unknown>(params?: RequestParams.SearchableSnapshotsClearCache, options?: TransportRequestOptions): TransportRequestPromise> + clear_cache, TContext = unknown>(callback: callbackFn): TransportRequestCallback + clear_cache, TContext = unknown>(params: RequestParams.SearchableSnapshotsClearCache, callback: callbackFn): TransportRequestCallback + clear_cache, TContext = unknown>(params: RequestParams.SearchableSnapshotsClearCache, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + clearCache, TContext = unknown>(params?: RequestParams.SearchableSnapshotsClearCache, options?: TransportRequestOptions): TransportRequestPromise> + clearCache, TContext = unknown>(callback: callbackFn): TransportRequestCallback + clearCache, TContext = unknown>(params: RequestParams.SearchableSnapshotsClearCache, callback: callbackFn): TransportRequestCallback + clearCache, TContext = unknown>(params: RequestParams.SearchableSnapshotsClearCache, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + mount, TRequestBody extends RequestBody = Record, TContext = unknown>(params?: RequestParams.SearchableSnapshotsMount, options?: TransportRequestOptions): TransportRequestPromise> + mount, TRequestBody extends RequestBody = Record, TContext = unknown>(callback: callbackFn): TransportRequestCallback + mount, TRequestBody extends RequestBody = Record, TContext = unknown>(params: RequestParams.SearchableSnapshotsMount, callback: callbackFn): TransportRequestCallback + mount, TRequestBody extends RequestBody = Record, TContext = unknown>(params: RequestParams.SearchableSnapshotsMount, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + stats, TContext = unknown>(params?: RequestParams.SearchableSnapshotsStats, options?: TransportRequestOptions): TransportRequestPromise> + stats, TContext = unknown>(callback: callbackFn): TransportRequestCallback + stats, TContext = unknown>(params: RequestParams.SearchableSnapshotsStats, callback: callbackFn): TransportRequestCallback + stats, TContext = unknown>(params: RequestParams.SearchableSnapshotsStats, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + } + searchableSnapshots: { + clear_cache, TContext = unknown>(params?: RequestParams.SearchableSnapshotsClearCache, options?: TransportRequestOptions): TransportRequestPromise> + clear_cache, TContext = unknown>(callback: callbackFn): TransportRequestCallback + clear_cache, TContext = unknown>(params: RequestParams.SearchableSnapshotsClearCache, callback: callbackFn): TransportRequestCallback + clear_cache, TContext = unknown>(params: RequestParams.SearchableSnapshotsClearCache, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + clearCache, TContext = unknown>(params?: RequestParams.SearchableSnapshotsClearCache, options?: TransportRequestOptions): TransportRequestPromise> + clearCache, TContext = unknown>(callback: callbackFn): TransportRequestCallback + clearCache, TContext = unknown>(params: RequestParams.SearchableSnapshotsClearCache, callback: callbackFn): TransportRequestCallback + clearCache, TContext = unknown>(params: RequestParams.SearchableSnapshotsClearCache, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + mount, TRequestBody extends RequestBody = Record, TContext = unknown>(params?: RequestParams.SearchableSnapshotsMount, options?: TransportRequestOptions): TransportRequestPromise> + mount, TRequestBody extends RequestBody = Record, TContext = unknown>(callback: callbackFn): TransportRequestCallback + mount, TRequestBody extends RequestBody = Record, TContext = unknown>(params: RequestParams.SearchableSnapshotsMount, callback: callbackFn): TransportRequestCallback + mount, TRequestBody extends RequestBody = Record, TContext = unknown>(params: RequestParams.SearchableSnapshotsMount, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + stats, TContext = unknown>(params?: RequestParams.SearchableSnapshotsStats, options?: TransportRequestOptions): TransportRequestPromise> + stats, TContext = unknown>(callback: callbackFn): TransportRequestCallback + stats, TContext = unknown>(params: RequestParams.SearchableSnapshotsStats, callback: callbackFn): TransportRequestCallback + stats, TContext = unknown>(params: RequestParams.SearchableSnapshotsStats, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + } security: { authenticate, TContext = unknown>(params?: RequestParams.SecurityAuthenticate, options?: TransportRequestOptions): TransportRequestPromise> authenticate, TContext = unknown>(callback: callbackFn): TransportRequestCallback