API generation

This commit is contained in:
delvedor
2020-06-03 09:09:42 +02:00
parent 1a25b623b0
commit dbbee273d9
13 changed files with 199 additions and 44 deletions

View File

@ -30,7 +30,7 @@ function buildClusterDeleteComponentTemplate (opts) {
/**
* Perform a cluster.delete_component_template request
* Deletes a component template
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html
*/
return function clusterDeleteComponentTemplate (params, options, callback) {
options = options || {}

View File

@ -30,7 +30,7 @@ function buildClusterExistsComponentTemplate (opts) {
/**
* Perform a cluster.exists_component_template request
* Returns information about whether a particular component template exist
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html
*/
return function clusterExistsComponentTemplate (params, options, callback) {
options = options || {}

View File

@ -30,7 +30,7 @@ function buildClusterGetComponentTemplate (opts) {
/**
* Perform a cluster.get_component_template request
* Returns one or more component templates
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html
*/
return function clusterGetComponentTemplate (params, options, callback) {
options = options || {}

View File

@ -31,7 +31,7 @@ function buildClusterPutComponentTemplate (opts) {
/**
* Perform a cluster.put_component_template request
* Creates or updates a component template
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html
*/
return function clusterPutComponentTemplate (params, options, callback) {
options = options || {}

View File

@ -46,10 +46,6 @@ function buildIndicesCreateDataStream (opts) {
const err = new ConfigurationError('Missing required parameter: name')
return handleError(err, callback)
}
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {

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 buildIndicesSimulateTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'create',
'cause',
'master_timeout',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a indices.simulate_template request
* Simulate resolving the given template name or body
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
*/
return function indicesSimulateTemplate (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 = 'POST'
path = '/' + '_index_template' + '/' + '_simulate' + '/' + encodeURIComponent(name)
} else {
if (method == null) method = 'POST'
path = '/' + '_index_template' + '/' + '_simulate'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIndicesSimulateTemplate

View File

@ -13,11 +13,13 @@ function buildMlForecast (opts) {
const acceptedQuerystring = [
'duration',
'expires_in'
'expires_in',
'max_model_memory'
]
const snakeCase = {
expiresIn: 'expires_in'
expiresIn: 'expires_in',
maxModelMemory: 'max_model_memory'
}
/**

View File

@ -17,14 +17,15 @@ function buildMlGetTrainedModels (opts) {
'decompress_definition',
'from',
'size',
'tags'
'tags',
'for_export'
]
const snakeCase = {
allowNoMatch: 'allow_no_match',
includeModelDefinition: 'include_model_definition',
decompressDefinition: 'decompress_definition'
decompressDefinition: 'decompress_definition',
forExport: 'for_export'
}
/**

View File

@ -28,7 +28,7 @@ function buildSnapshotDelete (opts) {
/**
* Perform a snapshot.delete request
* Deletes a snapshot.
* Deletes one or more snapshots.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*/
return function snapshotDelete (params, options, callback) {

View File

@ -291,6 +291,8 @@ function ESAPI (opts) {
shrink: lazyLoad('indices.shrink', opts),
simulate_index_template: lazyLoad('indices.simulate_index_template', opts),
simulateIndexTemplate: lazyLoad('indices.simulate_index_template', opts),
simulate_template: lazyLoad('indices.simulate_template', opts),
simulateTemplate: lazyLoad('indices.simulate_template', opts),
split: lazyLoad('indices.split', opts),
stats: lazyLoad('indices.stats', opts),
unfreeze: lazyLoad('indices.unfreeze', opts),

View File

@ -629,7 +629,7 @@ export interface IndicesCreate<T = RequestBody> extends Generic {
export interface IndicesCreateDataStream<T = RequestBody> extends Generic {
name: string;
body: T;
body?: T;
}
export interface IndicesDelete extends Generic {
@ -913,6 +913,14 @@ export interface IndicesSimulateIndexTemplate<T = RequestBody> extends Generic {
body?: T;
}
export interface IndicesSimulateTemplate<T = RequestBody> extends Generic {
name?: string;
create?: boolean;
cause?: string;
master_timeout?: string;
body?: T;
}
export interface IndicesSplit<T = RequestBody> extends Generic {
index: string;
target: string;
@ -1186,7 +1194,7 @@ export interface Search<T = RequestBody> extends Generic {
suggest_text?: string;
timeout?: string;
track_scores?: boolean;
track_total_hits?: boolean;
track_total_hits?: boolean|long;
allow_partial_search_results?: boolean;
typed_keys?: boolean;
version?: boolean;
@ -1251,7 +1259,7 @@ export interface SnapshotCreateRepository<T = RequestBody> extends Generic {
export interface SnapshotDelete extends Generic {
repository: string;
snapshot: string;
snapshot: string | string[];
master_timeout?: string;
}
@ -1453,7 +1461,7 @@ export interface AsyncSearchSubmit<T = RequestBody> extends Generic {
suggest_text?: string;
timeout?: string;
track_scores?: boolean;
track_total_hits?: boolean;
track_total_hits?: boolean|long;
allow_partial_search_results?: boolean;
typed_keys?: boolean;
version?: boolean;
@ -1808,7 +1816,8 @@ export interface MlDeleteDatafeed extends Generic {
force?: boolean;
}
export interface MlDeleteExpiredData extends Generic {
export interface MlDeleteExpiredData<T = RequestBody> extends Generic {
body?: T;
}
export interface MlDeleteFilter extends Generic {
@ -1882,6 +1891,7 @@ export interface MlForecast extends Generic {
job_id: string;
duration?: string;
expires_in?: string;
max_model_memory?: string;
}
export interface MlGetBuckets<T = RequestBody> extends Generic {
@ -2021,6 +2031,7 @@ export interface MlGetTrainedModels extends Generic {
from?: number;
size?: number;
tags?: string | string[];
for_export?: boolean;
}
export interface MlGetTrainedModelsStats extends Generic {
@ -2307,11 +2318,11 @@ export interface SecurityGetPrivileges extends Generic {
}
export interface SecurityGetRole extends Generic {
name?: string;
name?: string | string[];
}
export interface SecurityGetRoleMapping extends Generic {
name?: string;
name?: string | string[];
}
export interface SecurityGetToken<T = RequestBody> extends Generic {