From af5c9781317d72a78011f3f6c369a5b154d13380 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 15 Jul 2020 15:43:04 +0200 Subject: [PATCH] API generation --- api/api/indices.data_streams_stats.js | 86 +++++++++++++++++++++++++++ api/api/indices.put_mapping.js | 2 + api/index.js | 2 + api/kibana.d.ts | 1 + api/requestParams.d.ts | 7 +++ docs/reference.asciidoc | 34 ++++++++++- index.d.ts | 8 +++ 7 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 api/api/indices.data_streams_stats.js diff --git a/api/api/indices.data_streams_stats.js b/api/api/indices.data_streams_stats.js new file mode 100644 index 000000000..53abb7fc7 --- /dev/null +++ b/api/api/indices.data_streams_stats.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 buildIndicesDataStreamsStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + 'expand_wildcards', + 'forbid_closed_indices', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + expandWildcards: 'expand_wildcards', + forbidClosedIndices: 'forbid_closed_indices', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + /** + * Perform a indices.data_streams_stats request + * Provides statistics on operations happening in a data stream. + * https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + */ + return function indicesDataStreamsStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_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 + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildIndicesDataStreamsStats diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index 7335604cb..3fdef01e4 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -18,6 +18,7 @@ function buildIndicesPutMapping (opts) { 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', + 'write_index_only', 'pretty', 'human', 'error_trace', @@ -31,6 +32,7 @@ function buildIndicesPutMapping (opts) { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', + writeIndexOnly: 'write_index_only', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/index.js b/api/index.js index cba5c6f80..3b9c905e4 100644 --- a/api/index.js +++ b/api/index.js @@ -215,6 +215,8 @@ function ESAPI (opts) { create: lazyLoad('indices.create', opts), create_data_stream: lazyLoad('indices.create_data_stream', opts), createDataStream: lazyLoad('indices.create_data_stream', opts), + data_streams_stats: lazyLoad('indices.data_streams_stats', opts), + dataStreamsStats: lazyLoad('indices.data_streams_stats', opts), delete: lazyLoad('indices.delete', opts), delete_alias: lazyLoad('indices.delete_alias', opts), deleteAlias: lazyLoad('indices.delete_alias', opts), diff --git a/api/kibana.d.ts b/api/kibana.d.ts index 92dc72a20..88c2cbb1f 100644 --- a/api/kibana.d.ts +++ b/api/kibana.d.ts @@ -188,6 +188,7 @@ interface KibanaClient { close, TContext = Context>(params?: RequestParams.IndicesClose, options?: TransportRequestOptions): TransportRequestPromise> create, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.IndicesCreate, options?: TransportRequestOptions): TransportRequestPromise> createDataStream, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.IndicesCreateDataStream, options?: TransportRequestOptions): TransportRequestPromise> + dataStreamsStats, TContext = Context>(params?: RequestParams.IndicesDataStreamsStats, options?: TransportRequestOptions): TransportRequestPromise> delete, TContext = Context>(params?: RequestParams.IndicesDelete, options?: TransportRequestOptions): TransportRequestPromise> deleteAlias, TContext = Context>(params?: RequestParams.IndicesDeleteAlias, options?: TransportRequestOptions): TransportRequestPromise> deleteDataStream, TContext = Context>(params?: RequestParams.IndicesDeleteDataStream, options?: TransportRequestOptions): TransportRequestPromise> diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 4dff1b3dc..e30727099 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -656,6 +656,12 @@ export interface IndicesCreateDataStream extends Generic { body?: T; } +export interface IndicesDataStreamsStats extends Generic { + name?: string | string[]; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + forbid_closed_indices?: boolean; +} + export interface IndicesDelete extends Generic { index: string | string[]; timeout?: string; @@ -873,6 +879,7 @@ export interface IndicesPutMapping extends Generic { ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + write_index_only?: boolean; body: T; } diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 87b6a6bff..10605db24 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -2473,7 +2473,7 @@ client.indices.addBlock({ expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' }) ---- - +link:{ref}/indices-blocks.html[Documentation] + [cols=2*] |=== |`index` @@ -2698,6 +2698,32 @@ link:{ref}/data-streams.html[Documentation] + |=== +=== indices.dataStreamsStats +*Stability:* experimental +[source,ts] +---- +client.indices.dataStreamsStats({ + name: string | string[], + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + forbid_closed_indices: boolean +}) +---- +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 + +|`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` + +|`forbid_closed_indices` or `forbidClosedIndices` +|`boolean` - If set to false stats will also collected from closed indices if explicitly specified or if expand_wildcards expands to closed indices + +_Default:_ `true` + +|=== + === indices.delete [source,ts] @@ -3563,6 +3589,7 @@ client.indices.putMapping({ ignore_unavailable: boolean, allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + write_index_only: boolean, body: object }) ---- @@ -3596,6 +3623,9 @@ WARNING: This parameter has been deprecated. |`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + _Default:_ `open` +|`write_index_only` or `writeIndexOnly` +|`boolean` - When true, applies mappings only to the write index of an alias or data stream + |`body` |`object` - The mapping definition @@ -3748,7 +3778,7 @@ client.indices.resolveIndex({ expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' }) ---- - +link:{ref}/indices-resolve-index.html[Documentation] + [cols=2*] |=== |`name` diff --git a/index.d.ts b/index.d.ts index b76003eb2..4f2673652 100644 --- a/index.d.ts +++ b/index.d.ts @@ -844,6 +844,14 @@ declare class Client { createDataStream, TRequestBody extends RequestBody = Record, TContext = Context>(callback: callbackFn): TransportRequestCallback createDataStream, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.IndicesCreateDataStream, callback: callbackFn): TransportRequestCallback createDataStream, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.IndicesCreateDataStream, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + data_streams_stats, TContext = Context>(params?: RequestParams.IndicesDataStreamsStats, options?: TransportRequestOptions): TransportRequestPromise> + data_streams_stats, TContext = Context>(callback: callbackFn): TransportRequestCallback + data_streams_stats, TContext = Context>(params: RequestParams.IndicesDataStreamsStats, callback: callbackFn): TransportRequestCallback + data_streams_stats, TContext = Context>(params: RequestParams.IndicesDataStreamsStats, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + dataStreamsStats, TContext = Context>(params?: RequestParams.IndicesDataStreamsStats, options?: TransportRequestOptions): TransportRequestPromise> + dataStreamsStats, TContext = Context>(callback: callbackFn): TransportRequestCallback + dataStreamsStats, TContext = Context>(params: RequestParams.IndicesDataStreamsStats, callback: callbackFn): TransportRequestCallback + dataStreamsStats, TContext = Context>(params: RequestParams.IndicesDataStreamsStats, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback delete, TContext = Context>(params?: RequestParams.IndicesDelete, options?: TransportRequestOptions): TransportRequestPromise> delete, TContext = Context>(callback: callbackFn): TransportRequestCallback delete, TContext = Context>(params: RequestParams.IndicesDelete, callback: callbackFn): TransportRequestCallback