API generation

This commit is contained in:
delvedor
2020-12-16 16:58:19 +01:00
parent 30c8e7ae98
commit 5cfc87b181
7 changed files with 87 additions and 14 deletions

View File

@ -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

View File

@ -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 } }
})

View File

@ -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 = {

1
api/kibana.d.ts vendored
View File

@ -229,6 +229,7 @@ interface KibanaClient {
getSettings<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesGetSettings, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
getTemplate<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesGetTemplate, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
getUpgrade<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesGetUpgrade, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
migrateToDataStream<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesMigrateToDataStream, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
open<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesOpen, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
promoteDataStream<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesPromoteDataStream, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
putAlias<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesPutAlias<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>

View File

@ -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<T = RequestBody> extends Generic {
export interface RollupRollup<T = RequestBody> extends Generic {
index: string;
rollup_index: string;
body: T;
}

View File

@ -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

8
index.d.ts vendored
View File

@ -1045,6 +1045,14 @@ declare class Client {
getUpgrade<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getUpgrade<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesGetUpgrade, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getUpgrade<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesGetUpgrade, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
migrate_to_data_stream<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesMigrateToDataStream, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
migrate_to_data_stream<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
migrate_to_data_stream<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesMigrateToDataStream, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
migrate_to_data_stream<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesMigrateToDataStream, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
migrateToDataStream<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesMigrateToDataStream, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
migrateToDataStream<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
migrateToDataStream<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesMigrateToDataStream, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
migrateToDataStream<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesMigrateToDataStream, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
open<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesOpen, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
open<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
open<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesOpen, callback: callbackFn<TResponse, TContext>): TransportRequestCallback