API generation

This commit is contained in:
delvedor
2020-09-01 14:09:43 +02:00
parent 02ed45f76b
commit e86d38087e
19 changed files with 396 additions and 42 deletions

View File

@ -27,6 +27,7 @@ function buildCatMlDatafeeds (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'allow_no_datafeeds',
'format',
'h',
@ -37,6 +38,7 @@ function buildCatMlDatafeeds (opts) {
]
const snakeCase = {
allowNoMatch: 'allow_no_match',
allowNoDatafeeds: 'allow_no_datafeeds'
}

View File

@ -27,6 +27,7 @@ function buildCatMlJobs (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'allow_no_jobs',
'bytes',
'format',
@ -38,6 +39,7 @@ function buildCatMlJobs (opts) {
]
const snakeCase = {
allowNoMatch: 'allow_no_match',
allowNoJobs: 'allow_no_jobs'
}

View File

@ -0,0 +1,87 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildClosePointInTime (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a close_point_in_time request
* Close a point in time
* https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time.html
*/
return function closePointInTime (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, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'DELETE'
path = '/' + '_pit'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildClosePointInTime

View File

@ -51,7 +51,7 @@ function buildIndicesAddBlock (opts) {
/**
* Perform a indices.add_block request
* Adds a block to an index.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-blocks.html
* https://www.elastic.co/guide/en/elasticsearch/reference/master/index-modules-blocks.html
*/
return function indicesAddBlock (params, options, callback) {
options = options || {}

View File

@ -36,7 +36,7 @@ function buildIndicesCreateDataStream (opts) {
/**
* Perform a indices.create_data_stream request
* Creates or updates a data stream
* Creates a data stream
* https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html
*/
return function indicesCreateDataStream (params, options, callback) {

View File

@ -44,7 +44,7 @@ function buildIndicesResolveIndex (opts) {
/**
* Perform a indices.resolve_index request
* Returns information about any matching indices, aliases, and data streams
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-index.html
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-index-api.html
*/
return function indicesResolveIndex (params, options, callback) {
options = options || {}

View File

@ -27,12 +27,14 @@ function buildMlCloseJob (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'allow_no_jobs',
'force',
'timeout'
]
const snakeCase = {
allowNoMatch: 'allow_no_match',
allowNoJobs: 'allow_no_jobs'
}

View File

@ -27,10 +27,12 @@ function buildMlGetDatafeedStats (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'allow_no_datafeeds'
]
const snakeCase = {
allowNoMatch: 'allow_no_match',
allowNoDatafeeds: 'allow_no_datafeeds'
}

View File

@ -27,10 +27,12 @@ function buildMlGetDatafeeds (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'allow_no_datafeeds'
]
const snakeCase = {
allowNoMatch: 'allow_no_match',
allowNoDatafeeds: 'allow_no_datafeeds'
}

View File

@ -27,10 +27,12 @@ function buildMlGetJobStats (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'allow_no_jobs'
]
const snakeCase = {
allowNoMatch: 'allow_no_match',
allowNoJobs: 'allow_no_jobs'
}

View File

@ -27,10 +27,12 @@ function buildMlGetJobs (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'allow_no_jobs'
]
const snakeCase = {
allowNoMatch: 'allow_no_match',
allowNoJobs: 'allow_no_jobs'
}

View File

@ -33,6 +33,7 @@ function buildMlGetOverallBuckets (opts) {
'exclude_interim',
'start',
'end',
'allow_no_match',
'allow_no_jobs'
]
@ -41,6 +42,7 @@ function buildMlGetOverallBuckets (opts) {
bucketSpan: 'bucket_span',
overallScore: 'overall_score',
excludeInterim: 'exclude_interim',
allowNoMatch: 'allow_no_match',
allowNoJobs: 'allow_no_jobs'
}

View File

@ -27,12 +27,14 @@ function buildMlStopDatafeed (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'allow_no_datafeeds',
'force',
'timeout'
]
const snakeCase = {
allowNoMatch: 'allow_no_match',
allowNoDatafeeds: 'allow_no_datafeeds'
}

View File

@ -0,0 +1,98 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildOpenPointInTime (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'preference',
'routing',
'ignore_unavailable',
'expand_wildcards',
'keep_alive'
]
const snakeCase = {
ignoreUnavailable: 'ignore_unavailable',
expandWildcards: 'expand_wildcards',
keepAlive: 'keep_alive'
}
/**
* Perform a open_point_in_time request
* Open a point in time that can be used in subsequent searches
* https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time.html
*/
return function openPointInTime (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, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null) {
if (method == null) method = 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_pit'
} else {
if (method == null) method = 'POST'
path = '/' + '_pit'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildOpenPointInTime

View File

@ -112,6 +112,8 @@ function ESAPI (opts) {
},
clear_scroll: lazyLoad('clear_scroll', opts),
clearScroll: lazyLoad('clear_scroll', opts),
close_point_in_time: lazyLoad('close_point_in_time', opts),
closePointInTime: lazyLoad('close_point_in_time', opts),
cluster: {
allocation_explain: lazyLoad('cluster.allocation_explain', opts),
allocationExplain: lazyLoad('cluster.allocation_explain', opts),
@ -505,6 +507,8 @@ function ESAPI (opts) {
stats: lazyLoad('nodes.stats', opts),
usage: lazyLoad('nodes.usage', opts)
},
open_point_in_time: lazyLoad('open_point_in_time', opts),
openPointInTime: lazyLoad('open_point_in_time', opts),
ping: lazyLoad('ping', opts),
put_script: lazyLoad('put_script', opts),
putScript: lazyLoad('put_script', opts),

6
api/kibana.d.ts vendored
View File

@ -130,6 +130,7 @@ interface KibanaClient {
unfollow<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.CcrUnfollow, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
}
clearScroll<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.ClearScroll<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
closePointInTime<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.ClosePointInTime<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
cluster: {
allocationExplain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.ClusterAllocationExplain<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
deleteComponentTemplate<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.ClusterDeleteComponentTemplate, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
@ -212,7 +213,7 @@ interface KibanaClient {
clone<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesClone<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
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>>
createDataStream<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.IndicesCreateDataStream, 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>>
@ -333,7 +334,7 @@ interface KibanaClient {
startDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlStartDataFrameAnalytics<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
startDatafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlStartDatafeed<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
stopDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlStopDataFrameAnalytics<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
stopDatafeed<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.MlStopDatafeed, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
stopDatafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlStopDatafeed<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
updateDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlUpdateDataFrameAnalytics<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
updateDatafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlUpdateDatafeed<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
updateFilter<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlUpdateFilter<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
@ -355,6 +356,7 @@ interface KibanaClient {
stats<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.NodesStats, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
usage<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.NodesUsage, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
}
openPointInTime<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.OpenPointInTime, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
ping<TResponse = boolean, TContext = Context>(params?: RequestParams.Ping, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
putScript<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.PutScript<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
rankEval<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.RankEval<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>

View File

@ -1538,6 +1538,7 @@ export interface CatMlDataFrameAnalytics extends Generic {
export interface CatMlDatafeeds extends Generic {
datafeed_id?: string;
allow_no_match?: boolean;
allow_no_datafeeds?: boolean;
format?: string;
h?: string | string[];
@ -1549,6 +1550,7 @@ export interface CatMlDatafeeds extends Generic {
export interface CatMlJobs extends Generic {
job_id?: string;
allow_no_match?: boolean;
allow_no_jobs?: boolean;
bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb';
format?: string;
@ -1642,6 +1644,10 @@ export interface CcrUnfollow extends Generic {
index: string;
}
export interface ClosePointInTime<T = RequestBody> extends Generic {
body?: T;
}
export interface DataFrameTransformDeprecatedDeleteTransform extends Generic {
transform_id: string;
force?: boolean;
@ -1776,9 +1782,8 @@ export interface IlmStart extends Generic {
export interface IlmStop extends Generic {
}
export interface IndicesCreateDataStream<T = RequestBody> extends Generic {
export interface IndicesCreateDataStream extends Generic {
name: string;
body?: T;
}
export interface IndicesDataStreamsStats extends Generic {
@ -1854,6 +1859,7 @@ export interface MigrationDeprecations extends Generic {
export interface MlCloseJob<T = RequestBody> extends Generic {
job_id: string;
allow_no_match?: boolean;
allow_no_jobs?: boolean;
force?: boolean;
timeout?: string;
@ -2023,11 +2029,13 @@ export interface MlGetDataFrameAnalyticsStats extends Generic {
export interface MlGetDatafeedStats extends Generic {
datafeed_id?: string;
allow_no_match?: boolean;
allow_no_datafeeds?: boolean;
}
export interface MlGetDatafeeds extends Generic {
datafeed_id?: string;
allow_no_match?: boolean;
allow_no_datafeeds?: boolean;
}
@ -2052,11 +2060,13 @@ export interface MlGetInfluencers<T = RequestBody> extends Generic {
export interface MlGetJobStats extends Generic {
job_id?: string;
allow_no_match?: boolean;
allow_no_jobs?: boolean;
}
export interface MlGetJobs extends Generic {
job_id?: string;
allow_no_match?: boolean;
allow_no_jobs?: boolean;
}
@ -2080,6 +2090,7 @@ export interface MlGetOverallBuckets<T = RequestBody> extends Generic {
exclude_interim?: boolean;
start?: string;
end?: string;
allow_no_match?: boolean;
allow_no_jobs?: boolean;
body?: T;
}
@ -2211,11 +2222,13 @@ export interface MlStopDataFrameAnalytics<T = RequestBody> extends Generic {
body?: T;
}
export interface MlStopDatafeed extends Generic {
export interface MlStopDatafeed<T = RequestBody> extends Generic {
datafeed_id: string;
allow_no_match?: boolean;
allow_no_datafeeds?: boolean;
force?: boolean;
timeout?: string;
body?: T;
}
export interface MlUpdateDataFrameAnalytics<T = RequestBody> extends Generic {
@ -2264,6 +2277,15 @@ export interface MonitoringBulk<T = RequestNDBody> extends Generic {
body: T;
}
export interface OpenPointInTime extends Generic {
index?: string | string[];
preference?: string;
routing?: string;
ignore_unavailable?: boolean;
expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all';
keep_alive?: string;
}
export interface RollupDeleteJob extends Generic {
id: string;
}