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'
}
/**

View File

@ -257,6 +257,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

@ -625,7 +625,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 {
@ -927,6 +927,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;
@ -1776,7 +1784,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 {
@ -1850,6 +1859,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 {
@ -1989,6 +1999,7 @@ export interface MlGetTrainedModels extends Generic {
from?: number;
size?: number;
tags?: string | string[];
for_export?: boolean;
}
export interface MlGetTrainedModelsStats extends Generic {

View File

@ -3219,7 +3219,9 @@ _Default:_ `open`
|`string` - Specify timeout for connection to master
|`local`
|`boolean` - Return local information, do not retrieve the state from master node (default: false)
|`boolean` - Return local information, do not retrieve the state from master node (default: false) +
WARNING: This parameter has been deprecated.
|===
@ -3809,6 +3811,38 @@ link:{ref}/indices-templates.html[Documentation] +
|===
=== indices.simulateTemplate
[source,ts]
----
client.indices.simulateTemplate({
name: string,
create: boolean,
cause: string,
master_timeout: string,
body: object
})
----
link:{ref}/indices-templates.html[Documentation] +
[cols=2*]
|===
|`name`
|`string` - The name of the index template
|`create`
|`boolean` - Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one
|`cause`
|`string` - User defined reason for dry-run creating the new template for simulation purposes
|`master_timeout` or `masterTimeout`
|`string` - Specify timeout for connection to master
|`body`
|`object` - New index template definition to be simulated, if no index template name is specified
|===
=== indices.split
[source,ts]
@ -5233,7 +5267,7 @@ link:{ref}/modules-snapshots.html[Documentation] +
[cols=2*]
|===
|`repository`
|`string \| string[]` - A comma-separated list of repository names
|`string \| string[]` - Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported.
|`master_timeout` or `masterTimeout`
|`string` - Explicit operation timeout for connection to master node
@ -7245,10 +7279,17 @@ link:{ref}/ml-delete-datafeed.html[Documentation] +
[source,ts]
----
client.ml.deleteExpiredData()
client.ml.deleteExpiredData({
body: object
})
----
link:{ref}/ml-delete-expired-data.html[Documentation] +
[cols=2*]
|===
|`body`
|`object` - deleting expired data parameters
|===
=== ml.deleteFilter
@ -7529,7 +7570,8 @@ link:{ref}/ml-flush-job.html[Documentation] +
client.ml.forecast({
job_id: string,
duration: string,
expires_in: string
expires_in: string,
max_model_memory: string
})
----
link:{ref}/ml-forecast.html[Documentation] +
@ -7544,6 +7586,9 @@ link:{ref}/ml-forecast.html[Documentation] +
|`expires_in` or `expiresIn`
|`string` - The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity.
|`max_model_memory` or `maxModelMemory`
|`string` - The max memory able to be used by the forecast. Default is 20mb.
|===
=== ml.getBuckets
@ -8077,7 +8122,8 @@ client.ml.getTrainedModels({
decompress_definition: boolean,
from: number,
size: number,
tags: string | string[]
tags: string | string[],
for_export: boolean
})
----
link:{ref}/get-inference.html[Documentation] +
@ -8107,6 +8153,9 @@ _Default:_ `100`
|`tags`
|`string \| string[]` - A comma-separated list of tags that the model must have.
|`for_export` or `forExport`
|`boolean` - Omits fields that are illegal to set on model PUT
|===
=== ml.getTrainedModelsStats

24
index.d.ts vendored
View File

@ -1013,6 +1013,14 @@ declare class Client extends EventEmitter {
simulateIndexTemplate<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
simulateIndexTemplate<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesSimulateIndexTemplate<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
simulateIndexTemplate<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesSimulateIndexTemplate<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
simulate_template<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params?: RequestParams.IndicesSimulateTemplate<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
simulate_template<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
simulate_template<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesSimulateTemplate<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
simulate_template<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesSimulateTemplate<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
simulateTemplate<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params?: RequestParams.IndicesSimulateTemplate<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
simulateTemplate<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
simulateTemplate<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesSimulateTemplate<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
simulateTemplate<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesSimulateTemplate<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
split<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params?: RequestParams.IndicesSplit<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
split<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
split<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesSplit<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
@ -1193,14 +1201,14 @@ declare class Client extends EventEmitter {
deleteDatafeed<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteDatafeed<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteDatafeed, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteDatafeed<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteDatafeed, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_expired_data<TResponse = Record<string, any>, TContext = unknown>(params?: RequestParams.MlDeleteExpiredData, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
delete_expired_data<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_expired_data<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteExpiredData, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_expired_data<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteExpiredData, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteExpiredData<TResponse = Record<string, any>, TContext = unknown>(params?: RequestParams.MlDeleteExpiredData, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
deleteExpiredData<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteExpiredData<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteExpiredData, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteExpiredData<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteExpiredData, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_expired_data<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params?: RequestParams.MlDeleteExpiredData<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
delete_expired_data<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_expired_data<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteExpiredData<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_expired_data<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteExpiredData<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteExpiredData<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params?: RequestParams.MlDeleteExpiredData<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
deleteExpiredData<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteExpiredData<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteExpiredData<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteExpiredData<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteExpiredData<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_filter<TResponse = Record<string, any>, TContext = unknown>(params?: RequestParams.MlDeleteFilter, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
delete_filter<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_filter<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.MlDeleteFilter, callback: callbackFn<TResponse, TContext>): TransportRequestCallback