API generation

This commit is contained in:
delvedor
2020-06-15 09:55:15 +02:00
parent a82aae8cfb
commit aec79375bd
6 changed files with 149 additions and 6 deletions

View File

@ -0,0 +1,85 @@
// 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 buildIndicesResolveIndex (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'expand_wildcards',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
expandWildcards: 'expand_wildcards',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* 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
*/
return function indicesResolveIndex (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['name'] == null) {
const err = new ConfigurationError('Missing required parameter: name')
return handleError(err, callback)
}
// 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 (method == null) method = 'GET'
path = '/' + '_resolve' + '/' + 'index' + '/' + encodeURIComponent(name)
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIndicesResolveIndex

View File

@ -12,10 +12,12 @@ function buildMlDeleteExpiredData (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'requests_per_second',
'timeout'
]
const snakeCase = {
requestsPerSecond: 'requests_per_second'
}
@ -43,7 +45,7 @@ function buildMlDeleteExpiredData (opts) {
}
var warnings = []
var { method, body, ...querystring } = params
var { method, body, jobId, job_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
@ -53,8 +55,13 @@ function buildMlDeleteExpiredData (opts) {
var path = ''
if (method == null) method = 'DELETE'
path = '/' + '_ml' + '/' + '_delete_expired_data'
if ((job_id || jobId) != null) {
if (method == null) method = 'DELETE'
path = '/' + '_ml' + '/' + '_delete_expired_data' + '/' + encodeURIComponent(job_id || jobId)
} else {
if (method == null) method = 'DELETE'
path = '/' + '_ml' + '/' + '_delete_expired_data'
}
// build request object
const request = {

View File

@ -250,6 +250,8 @@ function ESAPI (opts) {
refresh: lazyLoad('indices.refresh', opts),
reload_search_analyzers: lazyLoad('indices.reload_search_analyzers', opts),
reloadSearchAnalyzers: lazyLoad('indices.reload_search_analyzers', opts),
resolve_index: lazyLoad('indices.resolve_index', opts),
resolveIndex: lazyLoad('indices.resolve_index', opts),
rollover: lazyLoad('indices.rollover', opts),
segments: lazyLoad('indices.segments', opts),
shard_stores: lazyLoad('indices.shard_stores', opts),

View File

@ -882,6 +882,11 @@ export interface IndicesRefresh extends Generic {
expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all';
}
export interface IndicesResolveIndex extends Generic {
name: string | string[];
expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all';
}
export interface IndicesRollover<T = RequestBody> extends Generic {
alias: string;
new_index?: string;
@ -1786,6 +1791,9 @@ export interface MlDeleteDatafeed extends Generic {
}
export interface MlDeleteExpiredData<T = RequestBody> extends Generic {
job_id?: string;
requests_per_second?: number;
timeout?: string;
body?: T;
}

View File

@ -3629,6 +3629,27 @@ _Default:_ `open`
|===
=== indices.resolveIndex
*Stability:* experimental
[source,ts]
----
client.indices.resolveIndex({
name: string | string[],
expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all'
})
----
link:{ref}/indices-resolve-index.html[Documentation] +
[cols=2*]
|===
|`name`
|`string \| string[]` - A comma-separated list of names or wildcard expressions
|`expand_wildcards` or `expandWildcards`
|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) +
_Default:_ `open`
|===
=== indices.rollover
[source,ts]
@ -3780,7 +3801,7 @@ link:{ref}/indices-shrink-index.html[Documentation] +
|===
=== indices.simulateIndexTemplate
*Stability:* experimental
[source,ts]
----
client.indices.simulateIndexTemplate({
@ -3812,7 +3833,7 @@ link:{ref}/indices-templates.html[Documentation] +
|===
=== indices.simulateTemplate
*Stability:* experimental
[source,ts]
----
client.indices.simulateTemplate({
@ -7284,12 +7305,24 @@ link:{ref}/ml-delete-datafeed.html[Documentation] +
[source,ts]
----
client.ml.deleteExpiredData({
job_id: string,
requests_per_second: number,
timeout: string,
body: object
})
----
link:{ref}/ml-delete-expired-data.html[Documentation] +
[cols=2*]
|===
|`job_id` or `jobId`
|`string` - The ID of the job(s) to perform expired data hygiene for
|`requests_per_second` or `requestsPerSecond`
|`number` - The desired requests per second for the deletion processes.
|`timeout`
|`string` - How long can the underlying delete processes run until they are canceled
|`body`
|`object` - deleting expired data parameters

8
index.d.ts vendored
View File

@ -985,6 +985,14 @@ declare class Client extends EventEmitter {
reloadSearchAnalyzers<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
reloadSearchAnalyzers<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesReloadSearchAnalyzers, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
reloadSearchAnalyzers<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesReloadSearchAnalyzers, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
resolve_index<TResponse = Record<string, any>, TContext = unknown>(params?: RequestParams.IndicesResolveIndex, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
resolve_index<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
resolve_index<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesResolveIndex, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
resolve_index<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesResolveIndex, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
resolveIndex<TResponse = Record<string, any>, TContext = unknown>(params?: RequestParams.IndicesResolveIndex, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
resolveIndex<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
resolveIndex<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesResolveIndex, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
resolveIndex<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesResolveIndex, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
rollover<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params?: RequestParams.IndicesRollover<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
rollover<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
rollover<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesRollover<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback