API generation

This commit is contained in:
delvedor
2020-07-20 12:17:14 +02:00
parent 1e8bcbebfe
commit e6a4050b0b
14 changed files with 215 additions and 88 deletions

View File

@ -23,6 +23,7 @@ function buildBulk (opts) {
'_source_includes',
'_source_include',
'pipeline',
'require_alias',
'pretty',
'human',
'error_trace',
@ -36,6 +37,7 @@ function buildBulk (opts) {
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
requireAlias: 'require_alias',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -22,6 +22,7 @@ function buildIndex (opts) {
'if_seq_no',
'if_primary_term',
'pipeline',
'require_alias',
'pretty',
'human',
'error_trace',
@ -35,6 +36,7 @@ function buildIndex (opts) {
versionType: 'version_type',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
requireAlias: 'require_alias',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -12,16 +12,11 @@ function buildIndicesCreateDataStream (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**

View File

@ -0,0 +1,77 @@
// 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 = [
]
const snakeCase = {
}
/**
* 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

View File

@ -12,16 +12,11 @@ function buildIndicesDeleteDataStream (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**

View File

@ -12,16 +12,11 @@ function buildIndicesGetDataStream (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**

View File

@ -17,6 +17,7 @@ function buildIndicesPutMapping (opts) {
'ignore_unavailable',
'allow_no_indices',
'expand_wildcards',
'write_index_only',
'pretty',
'human',
'error_trace',
@ -29,6 +30,7 @@ function buildIndicesPutMapping (opts) {
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',
writeIndexOnly: 'write_index_only',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -14,7 +14,8 @@ function buildMlGetDataFrameAnalyticsStats (opts) {
const acceptedQuerystring = [
'allow_no_match',
'from',
'size'
'size',
'verbose'
]
const snakeCase = {

View File

@ -25,6 +25,7 @@ function buildUpdate (opts) {
'timeout',
'if_seq_no',
'if_primary_term',
'require_alias',
'pretty',
'human',
'error_trace',
@ -41,6 +42,7 @@ function buildUpdate (opts) {
retryOnConflict: 'retry_on_conflict',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
requireAlias: 'require_alias',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}

View File

@ -251,6 +251,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),

1
api/kibana.d.ts vendored
View File

@ -198,6 +198,7 @@ interface KibanaClient {
close<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesClose, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
create<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesCreate<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
createDataStream<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesCreateDataStream<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
dataStreamsStats<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesDataStreamsStats, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
delete<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesDelete, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
deleteAlias<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesDeleteAlias, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
deleteDataStream<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesDeleteDataStream, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>

View File

@ -27,6 +27,7 @@ export interface Bulk<T = RequestNDBody> extends Generic {
_source_excludes?: string | string[];
_source_includes?: string | string[];
pipeline?: string;
require_alias?: boolean;
body: T;
}
@ -599,6 +600,7 @@ export interface Index<T = RequestBody> extends Generic {
if_seq_no?: number;
if_primary_term?: number;
pipeline?: string;
require_alias?: boolean;
body: T;
}
@ -655,11 +657,6 @@ export interface IndicesCreate<T = RequestBody> extends Generic {
body?: T;
}
export interface IndicesCreateDataStream<T = RequestBody> extends Generic {
name: string;
body?: T;
}
export interface IndicesDelete extends Generic {
index: string | string[];
timeout?: string;
@ -676,10 +673,6 @@ export interface IndicesDeleteAlias extends Generic {
master_timeout?: string;
}
export interface IndicesDeleteDataStream extends Generic {
name: string | string[];
}
export interface IndicesDeleteIndexTemplate extends Generic {
name: string;
timeout?: string;
@ -773,10 +766,6 @@ export interface IndicesGetAlias extends Generic {
local?: boolean;
}
export interface IndicesGetDataStream extends Generic {
name?: string | string[];
}
export interface IndicesGetFieldMapping extends Generic {
fields: string | string[];
index?: string | string[];
@ -862,6 +851,7 @@ export interface IndicesPutMapping<T = RequestBody> extends Generic {
ignore_unavailable?: boolean;
allow_no_indices?: boolean;
expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all';
write_index_only?: boolean;
body: T;
}
@ -1395,6 +1385,7 @@ export interface Update<T = RequestBody> extends Generic {
timeout?: string;
if_seq_no?: number;
if_primary_term?: number;
require_alias?: boolean;
body: T;
}
@ -1771,6 +1762,19 @@ export interface IlmStart extends Generic {
export interface IlmStop extends Generic {
}
export interface IndicesCreateDataStream<T = RequestBody> extends Generic {
name: string;
body?: T;
}
export interface IndicesDataStreamsStats extends Generic {
name?: string | string[];
}
export interface IndicesDeleteDataStream extends Generic {
name: string | string[];
}
export interface IndicesFreeze extends Generic {
index: string;
timeout?: string;
@ -1781,6 +1785,10 @@ export interface IndicesFreeze extends Generic {
wait_for_active_shards?: string;
}
export interface IndicesGetDataStream extends Generic {
name?: string | string[];
}
export interface IndicesReloadSearchAnalyzers extends Generic {
index: string | string[];
ignore_unavailable?: boolean;
@ -1996,6 +2004,7 @@ export interface MlGetDataFrameAnalyticsStats extends Generic {
allow_no_match?: boolean;
from?: number;
size?: number;
verbose?: boolean;
}
export interface MlGetDatafeedStats extends Generic {