API generation

This commit is contained in:
delvedor
2020-06-03 09:11:45 +02:00
parent 57fbbd0a8f
commit 4121e1e7ff
12 changed files with 183 additions and 28 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'
}
/**