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;
}