From 5cfc87b181f1912dfe151737f8f12da610a4c062 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 16 Dec 2020 16:58:19 +0100 Subject: [PATCH] API generation --- api/api/cat.js | 4 ++-- api/api/indices.js | 28 ++++++++++++++++++++++++++++ api/api/rollup.js | 14 ++++++++++++-- api/kibana.d.ts | 1 + api/requestParams.d.ts | 9 +++++++-- docs/reference.asciidoc | 37 +++++++++++++++++++++++++++++-------- index.d.ts | 8 ++++++++ 7 files changed, 87 insertions(+), 14 deletions(-) diff --git a/api/api/cat.js b/api/api/cat.js index 71ff1d922..16f26d396 100644 --- a/api/api/cat.js +++ b/api/api/cat.js @@ -23,8 +23,8 @@ /* 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', 'size', 'allow_no_match', 'allow_no_datafeeds', 'allow_no_jobs', 'from'] -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' } +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', 'nodes', 'actions', 'parent_task_id', 'size', 'allow_no_match', 'allow_no_datafeeds', 'allow_no_jobs', 'from'] +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', parentTaskId: 'parent_task_id', allowNoMatch: 'allow_no_match', allowNoDatafeeds: 'allow_no_datafeeds', allowNoJobs: 'allow_no_jobs' } function CatApi (transport, ConfigurationError) { this.transport = transport diff --git a/api/api/indices.js b/api/api/indices.js index 2e579feb5..11dd5e135 100644 --- a/api/api/indices.js +++ b/api/api/indices.js @@ -1548,6 +1548,33 @@ IndicesApi.prototype.getDataStream = function indicesGetDataStreamApi (params, o return this.transport.request(request, options, callback) } +IndicesApi.prototype.migrateToDataStream = function indicesMigrateToDataStreamApi (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 = '/' + '_data_stream' + '/' + '_migrate' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + IndicesApi.prototype.promoteDataStream = function indicesPromoteDataStreamApi (params, options, callback) { ;[params, options, callback] = normalizeArguments(params, options, callback) @@ -1662,6 +1689,7 @@ Object.defineProperties(IndicesApi.prototype, { data_streams_stats: { get () { return this.dataStreamsStats } }, delete_data_stream: { get () { return this.deleteDataStream } }, get_data_stream: { get () { return this.getDataStream } }, + migrate_to_data_stream: { get () { return this.migrateToDataStream } }, promote_data_stream: { get () { return this.promoteDataStream } }, reload_search_analyzers: { get () { return this.reloadSearchAnalyzers } } }) diff --git a/api/api/rollup.js b/api/api/rollup.js index f30d976c7..364097f3b 100644 --- a/api/api/rollup.js +++ b/api/api/rollup.js @@ -176,17 +176,27 @@ RollupApi.prototype.rollup = function rollupRollupApi (params, options, callback const err = new this[kConfigurationError]('Missing required parameter: index') return handleError(err, callback) } + if (params['rollup_index'] == null && params['rollupIndex'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: rollup_index or rollupIndex') + 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 + // check required url components + if ((params['rollup_index'] != null || params['rollupIndex'] != null) && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, rollupIndex, rollup_index, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) var path = '' if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_rollup' + path = '/' + encodeURIComponent(index) + '/' + '_rollup' + '/' + encodeURIComponent(rollup_index || rollupIndex) // build request object const request = { diff --git a/api/kibana.d.ts b/api/kibana.d.ts index 3d11f5675..dc1598491 100644 --- a/api/kibana.d.ts +++ b/api/kibana.d.ts @@ -229,6 +229,7 @@ interface KibanaClient { getSettings, TContext = Context>(params?: RequestParams.IndicesGetSettings, options?: TransportRequestOptions): TransportRequestPromise> getTemplate, TContext = Context>(params?: RequestParams.IndicesGetTemplate, options?: TransportRequestOptions): TransportRequestPromise> getUpgrade, TContext = Context>(params?: RequestParams.IndicesGetUpgrade, options?: TransportRequestOptions): TransportRequestPromise> + migrateToDataStream, TContext = Context>(params?: RequestParams.IndicesMigrateToDataStream, options?: TransportRequestOptions): TransportRequestPromise> open, TContext = Context>(params?: RequestParams.IndicesOpen, options?: TransportRequestOptions): TransportRequestPromise> promoteDataStream, TContext = Context>(params?: RequestParams.IndicesPromoteDataStream, options?: TransportRequestOptions): TransportRequestPromise> putAlias, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.IndicesPutAlias, options?: TransportRequestOptions): TransportRequestPromise> diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index a222ed5e2..ec458a9b6 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -359,10 +359,10 @@ export interface CatSnapshots extends Generic { export interface CatTasks extends Generic { format?: string; - node_id?: string | string[]; + nodes?: string | string[]; actions?: string | string[]; detailed?: boolean; - parent_task?: number; + parent_task_id?: string; h?: string | string[]; help?: boolean; s?: string | string[]; @@ -1158,6 +1158,10 @@ export interface IndicesGetUpgrade extends Generic { expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; } +export interface IndicesMigrateToDataStream extends Generic { + name: string; +} + export interface IndicesOpen extends Generic { index: string | string[]; timeout?: string; @@ -2034,6 +2038,7 @@ export interface RollupPutJob extends Generic { export interface RollupRollup extends Generic { index: string; + rollup_index: string; body: T; } diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 7631118b8..ef7073f31 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -1470,10 +1470,10 @@ link:{ref}/cat-snapshots.html[Documentation] + ---- client.cat.tasks({ format: string, - node_id: string | string[], + nodes: string | string[], actions: string | string[], detailed: boolean, - parent_task: number, + parent_task_id: string, h: string | string[], help: boolean, s: string | string[], @@ -1487,7 +1487,7 @@ link:{ref}/tasks.html[Documentation] + |`format` |`string` - a short version of the Accept header, e.g. json, yaml -|`node_id` or `nodeId` +|`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` @@ -1496,8 +1496,8 @@ link:{ref}/tasks.html[Documentation] + |`detailed` |`boolean` - Return detailed task information (default: false) -|`parent_task` or `parentTask` -|`number` - Return tasks with specified parent task id. Set to -1 to return all. +|`parent_task_id` or `parentTaskId` +|`string` - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. |`h` |`string \| string[]` - Comma-separated list of column names to display @@ -2957,7 +2957,7 @@ link:{ref}/enrich-stats-api.html[Documentation] + [discrete] === eql.delete -*Stability:* beta + [source,ts] ---- client.eql.delete({ @@ -2974,7 +2974,7 @@ link:{ref}/eql-search-api.html[Documentation] + [discrete] === eql.get -*Stability:* beta + [source,ts] ---- client.eql.get({ @@ -3000,7 +3000,7 @@ _Default:_ `5d` [discrete] === eql.search -*Stability:* beta + [source,ts] ---- client.eql.search({ @@ -4812,6 +4812,23 @@ _Default:_ `open` |=== +[discrete] +=== indices.migrateToDataStream + +[source,ts] +---- +client.indices.migrateToDataStream({ + name: string +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the alias to migrate + +|=== + [discrete] === indices.open @@ -8482,6 +8499,7 @@ link:{ref}/rollup-put-job.html[Documentation] + ---- client.rollup.rollup({ index: string, + rollup_index: string, body: object }) ---- @@ -8491,6 +8509,9 @@ link:{ref}/rollup-api.html[Documentation] + |`index` |`string` - The index to roll up +|`rollup_index` or `rollupIndex` +|`string` - The name of the rollup index to create + |`body` |`object` - The rollup configuration diff --git a/index.d.ts b/index.d.ts index d7eff0e92..f894c10e3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1045,6 +1045,14 @@ declare class Client { getUpgrade, TContext = Context>(callback: callbackFn): TransportRequestCallback getUpgrade, TContext = Context>(params: RequestParams.IndicesGetUpgrade, callback: callbackFn): TransportRequestCallback getUpgrade, TContext = Context>(params: RequestParams.IndicesGetUpgrade, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + migrate_to_data_stream, TContext = Context>(params?: RequestParams.IndicesMigrateToDataStream, options?: TransportRequestOptions): TransportRequestPromise> + migrate_to_data_stream, TContext = Context>(callback: callbackFn): TransportRequestCallback + migrate_to_data_stream, TContext = Context>(params: RequestParams.IndicesMigrateToDataStream, callback: callbackFn): TransportRequestCallback + migrate_to_data_stream, TContext = Context>(params: RequestParams.IndicesMigrateToDataStream, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + migrateToDataStream, TContext = Context>(params?: RequestParams.IndicesMigrateToDataStream, options?: TransportRequestOptions): TransportRequestPromise> + migrateToDataStream, TContext = Context>(callback: callbackFn): TransportRequestCallback + migrateToDataStream, TContext = Context>(params: RequestParams.IndicesMigrateToDataStream, callback: callbackFn): TransportRequestCallback + migrateToDataStream, TContext = Context>(params: RequestParams.IndicesMigrateToDataStream, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback open, TContext = Context>(params?: RequestParams.IndicesOpen, options?: TransportRequestOptions): TransportRequestPromise> open, TContext = Context>(callback: callbackFn): TransportRequestCallback open, TContext = Context>(params: RequestParams.IndicesOpen, callback: callbackFn): TransportRequestCallback