API generation

This commit is contained in:
delvedor
2020-07-20 14:09:53 +02:00
parent 68bc20c440
commit 3e20dd578f
11 changed files with 182 additions and 20 deletions

View File

@ -21,6 +21,7 @@ function buildBulk (opts) {
'_source_excludes',
'_source_includes',
'pipeline',
'require_alias',
'pretty',
'human',
'error_trace',
@ -32,6 +33,7 @@ function buildBulk (opts) {
waitForActiveShards: 'wait_for_active_shards',
_sourceExcludes: '_source_excludes',
_sourceIncludes: '_source_includes',
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

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

View File

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

View File

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

View File

@ -23,6 +23,7 @@ function buildUpdate (opts) {
'timeout',
'if_seq_no',
'if_primary_term',
'require_alias',
'pretty',
'human',
'error_trace',
@ -37,6 +38,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

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

1
api/kibana.d.ts vendored
View File

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

@ -6,7 +6,6 @@ import { RequestBody, RequestNDBody } from '../lib/Transport'
export interface Generic {
method?: string;
ignore?: number | number[];
filter_path?: string | string[];
pretty?: boolean;
human?: boolean;
@ -18,13 +17,14 @@ export interface Bulk<T = RequestNDBody> extends Generic {
index?: string;
type?: string;
wait_for_active_shards?: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
routing?: string;
timeout?: string;
_source?: string | string[];
_source_excludes?: string | string[];
_source_includes?: string | string[];
pipeline?: string;
require_alias?: boolean;
body: T;
}
@ -388,7 +388,7 @@ export interface Create<T = RequestBody> extends Generic {
index: string;
type?: string;
wait_for_active_shards?: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
routing?: string;
timeout?: string;
version?: number;
@ -419,7 +419,7 @@ export interface Delete extends Generic {
index: string;
type?: string;
wait_for_active_shards?: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
routing?: string;
timeout?: string;
if_seq_no?: number;
@ -586,7 +586,7 @@ export interface Index<T = RequestBody> extends Generic {
type?: string;
wait_for_active_shards?: string;
op_type?: 'index' | 'create';
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
routing?: string;
timeout?: string;
version?: number;
@ -594,6 +594,7 @@ export interface Index<T = RequestBody> extends Generic {
if_seq_no?: number;
if_primary_term?: number;
pipeline?: string;
require_alias?: boolean;
body: T;
}
@ -656,6 +657,12 @@ export interface IndicesCreateDataStream<T = RequestBody> 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 +880,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;
}
@ -1405,12 +1413,13 @@ export interface Update<T = RequestBody> extends Generic {
_source_excludes?: string | string[];
_source_includes?: string | string[];
lang?: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
retry_on_conflict?: number;
routing?: string;
timeout?: string;
if_seq_no?: number;
if_primary_term?: number;
require_alias?: boolean;
body: T;
}
@ -1964,6 +1973,7 @@ export interface MlGetDataFrameAnalyticsStats extends Generic {
allow_no_match?: boolean;
from?: number;
size?: number;
verbose?: boolean;
}
export interface MlGetDatafeedStats extends Generic {
@ -2276,7 +2286,7 @@ export interface SecurityAuthenticate extends Generic {
export interface SecurityChangePassword<T = RequestBody> extends Generic {
username?: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
body: T;
}
@ -2294,39 +2304,39 @@ export interface SecurityClearCachedRoles extends Generic {
}
export interface SecurityCreateApiKey<T = RequestBody> extends Generic {
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
body: T;
}
export interface SecurityDeletePrivileges extends Generic {
application: string;
name: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
}
export interface SecurityDeleteRole extends Generic {
name: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
}
export interface SecurityDeleteRoleMapping extends Generic {
name: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
}
export interface SecurityDeleteUser extends Generic {
username: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
}
export interface SecurityDisableUser extends Generic {
username: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
}
export interface SecurityEnableUser extends Generic {
username: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
}
export interface SecurityGetApiKey extends Generic {
@ -2378,25 +2388,25 @@ export interface SecurityInvalidateToken<T = RequestBody> extends Generic {
}
export interface SecurityPutPrivileges<T = RequestBody> extends Generic {
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
body: T;
}
export interface SecurityPutRole<T = RequestBody> extends Generic {
name: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
body: T;
}
export interface SecurityPutRoleMapping<T = RequestBody> extends Generic {
name: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
body: T;
}
export interface SecurityPutUser<T = RequestBody> extends Generic {
username: string;
refresh?: 'true' | 'false' | 'wait_for';
refresh?: 'wait_for' | boolean;
body: T;
}

View File

@ -110,6 +110,7 @@ client.bulk({
_source_excludes: string | string[],
_source_includes: string | string[],
pipeline: string,
require_alias: boolean,
body: object
})
----
@ -147,6 +148,9 @@ link:{ref}/docs-bulk.html[Documentation] +
|`pipeline`
|`string` - The pipeline id to preprocess incoming documents with
|`require_alias` or `requireAlias`
|`boolean` - Sets require_alias for all incoming documents. Defaults to unset (false)
|`body`
|`object` - The operation definition and data (action-data pairs), separated by newlines
@ -2407,6 +2411,7 @@ client.index({
if_seq_no: number,
if_primary_term: number,
pipeline: string,
require_alias: boolean,
body: object
})
----
@ -2454,6 +2459,9 @@ WARNING: This parameter has been deprecated.
|`pipeline`
|`string` - The pipeline id to preprocess incoming documents with
|`require_alias` or `requireAlias`
|`boolean` - When true, requires destination to be an alias. Default is false
|`body`
|`object` - The document
@ -2698,6 +2706,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 +3597,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 +3631,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
@ -5740,6 +5778,7 @@ client.update({
timeout: string,
if_seq_no: number,
if_primary_term: number,
require_alias: boolean,
body: object
})
----
@ -5791,6 +5830,9 @@ WARNING: This parameter has been deprecated.
|`if_primary_term` or `ifPrimaryTerm`
|`number` - only perform the update operation if the last operation that has changed the document has the specified primary term
|`require_alias` or `requireAlias`
|`boolean` - When true, requires destination is an alias. Default is false
|`body`
|`object` - The request definition requires either `script` or partial `doc`
@ -7990,7 +8032,8 @@ client.ml.getDataFrameAnalyticsStats({
id: string,
allow_no_match: boolean,
from: number,
size: number
size: number,
verbose: boolean
})
----
link:{ref}/get-dfanalytics-stats.html[Documentation] +
@ -8010,6 +8053,9 @@ _Default:_ `true`
|`number` - specifies a max number of analytics to get +
_Default:_ `100`
|`verbose`
|`boolean` - whether the stats response should be verbose
|===
=== ml.getDatafeedStats

8
index.d.ts vendored
View File

@ -844,6 +844,14 @@ declare class Client {
createDataStream<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
createDataStream<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.IndicesCreateDataStream<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
createDataStream<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.IndicesCreateDataStream<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
data_streams_stats<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesDataStreamsStats, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
data_streams_stats<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
data_streams_stats<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesDataStreamsStats, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
data_streams_stats<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesDataStreamsStats, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
dataStreamsStats<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesDataStreamsStats, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
dataStreamsStats<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
dataStreamsStats<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesDataStreamsStats, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
dataStreamsStats<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesDataStreamsStats, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesDelete, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
delete<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.IndicesDelete, callback: callbackFn<TResponse, TContext>): TransportRequestCallback