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 {

View File

@ -3112,7 +3112,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.
|===
@ -3676,6 +3678,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]
@ -4671,7 +4705,7 @@ client.search({
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,
@ -4792,7 +4826,7 @@ _Default:_ `missing`
|`boolean` - Whether to calculate and return scores even if they are not used for sorting
|`track_total_hits` or `trackTotalHits`
|`boolean` - Indicate if the number of documents that match the query should be tracked
|`boolean\|long` - Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number.
|`allow_partial_search_results` or `allowPartialSearchResults`
|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout +
@ -5038,7 +5072,7 @@ link:{ref}/modules-snapshots.html[Documentation] +
----
client.snapshot.delete({
repository: string,
snapshot: string,
snapshot: string | string[],
master_timeout: string
})
----
@ -5049,7 +5083,7 @@ link:{ref}/modules-snapshots.html[Documentation] +
|`string` - A repository name
|`snapshot`
|`string` - A snapshot name
|`string \| string[]` - A comma-separated list of snapshot names
|`master_timeout` or `masterTimeout`
|`string` - Explicit operation timeout for connection to master node
@ -5070,7 +5104,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
@ -5733,7 +5767,7 @@ client.asyncSearch.submit({
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,
@ -5860,7 +5894,7 @@ _Default:_ `missing`
|`boolean` - Whether to calculate and return scores even if they are not used for sorting
|`track_total_hits` or `trackTotalHits`
|`boolean` - Indicate if the number of documents that match the query should be tracked
|`boolean\|long` - Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number.
|`allow_partial_search_results` or `allowPartialSearchResults`
|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout +
@ -7254,10 +7288,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
@ -7538,7 +7579,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] +
@ -7553,6 +7595,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
@ -8086,7 +8131,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] +
@ -8116,6 +8162,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
@ -9253,14 +9302,14 @@ link:{ref}/security-api-get-privileges.html[Documentation] +
[source,ts]
----
client.security.getRole({
name: string
name: string | string[]
})
----
link:{ref}/security-api-get-role.html[Documentation] +
[cols=2*]
|===
|`name`
|`string` - Role name
|`string \| string[]` - A comma-separated list of role names
|===
@ -9269,14 +9318,14 @@ link:{ref}/security-api-get-role.html[Documentation] +
[source,ts]
----
client.security.getRoleMapping({
name: string
name: string | string[]
})
----
link:{ref}/security-api-get-role-mapping.html[Documentation] +
[cols=2*]
|===
|`name`
|`string` - Role-Mapping name
|`string \| string[]` - A comma-separated list of role-mapping names
|===

24
index.d.ts vendored
View File

@ -1137,6 +1137,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
@ -1317,14 +1325,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