API generation

This commit is contained in:
delvedor
2020-03-30 14:50:18 +02:00
parent da35f71f2d
commit 2963fa6e0b
7 changed files with 399 additions and 0 deletions

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 buildIndicesDeleteIndexTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'timeout',
'master_timeout',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a indices.delete_index_template request
* Deletes an index template.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
*/
return function indicesDeleteIndexTemplate (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 = 'DELETE'
path = '/' + '_index_template' + '/' + encodeURIComponent(name)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIndicesDeleteIndexTemplate

View File

@ -0,0 +1,87 @@
// 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 buildIndicesGetIndexTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'flat_settings',
'master_timeout',
'local',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
flatSettings: 'flat_settings',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a indices.get_index_template request
* Returns an index template.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
*/
return function indicesGetIndexTemplate (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 = 'GET'
path = '/' + '_index_template' + '/' + encodeURIComponent(name)
} else {
if (method == null) method = 'GET'
path = '/' + '_index_template'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIndicesGetIndexTemplate

View File

@ -0,0 +1,91 @@
// 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 buildIndicesPutIndexTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'order',
'create',
'master_timeout',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a indices.put_index_template request
* Creates or updates an index template.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
*/
return function indicesPutIndexTemplate (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)
}
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') {
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 = 'PUT'
path = '/' + '_index_template' + '/' + encodeURIComponent(name)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIndicesPutIndexTemplate

View File

@ -224,6 +224,8 @@ function ESAPI (opts) {
deleteAlias: lazyLoad('indices.delete_alias', opts),
delete_data_stream: lazyLoad('indices.delete_data_stream', opts),
deleteDataStream: lazyLoad('indices.delete_data_stream', opts),
delete_index_template: lazyLoad('indices.delete_index_template', opts),
deleteIndexTemplate: lazyLoad('indices.delete_index_template', opts),
delete_template: lazyLoad('indices.delete_template', opts),
deleteTemplate: lazyLoad('indices.delete_template', opts),
exists: lazyLoad('indices.exists', opts),
@ -243,6 +245,8 @@ function ESAPI (opts) {
getDataStreams: lazyLoad('indices.get_data_streams', opts),
get_field_mapping: lazyLoad('indices.get_field_mapping', opts),
getFieldMapping: lazyLoad('indices.get_field_mapping', opts),
get_index_template: lazyLoad('indices.get_index_template', opts),
getIndexTemplate: lazyLoad('indices.get_index_template', opts),
get_mapping: lazyLoad('indices.get_mapping', opts),
getMapping: lazyLoad('indices.get_mapping', opts),
get_settings: lazyLoad('indices.get_settings', opts),
@ -254,6 +258,8 @@ function ESAPI (opts) {
open: lazyLoad('indices.open', opts),
put_alias: lazyLoad('indices.put_alias', opts),
putAlias: lazyLoad('indices.put_alias', opts),
put_index_template: lazyLoad('indices.put_index_template', opts),
putIndexTemplate: lazyLoad('indices.put_index_template', opts),
put_mapping: lazyLoad('indices.put_mapping', opts),
putMapping: lazyLoad('indices.put_mapping', opts),
put_settings: lazyLoad('indices.put_settings', opts),

View File

@ -636,6 +636,12 @@ export interface IndicesDeleteDataStream extends Generic {
name: string;
}
export interface IndicesDeleteIndexTemplate extends Generic {
name: string;
timeout?: string;
master_timeout?: string;
}
export interface IndicesDeleteTemplate extends Generic {
name: string;
timeout?: string;
@ -730,6 +736,13 @@ export interface IndicesGetFieldMapping extends Generic {
local?: boolean;
}
export interface IndicesGetIndexTemplate extends Generic {
name?: string | string[];
flat_settings?: boolean;
master_timeout?: string;
local?: boolean;
}
export interface IndicesGetMapping extends Generic {
index?: string | string[];
ignore_unavailable?: boolean;
@ -783,6 +796,14 @@ export interface IndicesPutAlias<T = RequestBody> extends Generic {
body?: T;
}
export interface IndicesPutIndexTemplate<T = RequestBody> extends Generic {
name: string;
order?: number;
create?: boolean;
master_timeout?: string;
body: T;
}
export interface IndicesPutMapping<T = RequestBody> extends Generic {
index: string | string[];
timeout?: string;

View File

@ -2546,6 +2546,30 @@ link:{ref}/data-streams.html[Documentation] +
|===
=== indices.deleteIndexTemplate
[source,ts]
----
client.indices.deleteIndexTemplate({
name: string,
timeout: string,
master_timeout: string
})
----
link:{ref}/indices-templates.html[Documentation] +
[cols=2*]
|===
|`name`
|`string` - The name of the template
|`timeout`
|`string` - Explicit operation timeout
|`master_timeout` or `masterTimeout`
|`string` - Specify timeout for connection to master
|===
=== indices.deleteTemplate
[source,ts]
@ -2930,6 +2954,34 @@ _Default:_ `open`
|===
=== indices.getIndexTemplate
[source,ts]
----
client.indices.getIndexTemplate({
name: string | string[],
flat_settings: boolean,
master_timeout: string,
local: boolean
})
----
link:{ref}/indices-templates.html[Documentation] +
[cols=2*]
|===
|`name`
|`string \| string[]` - The comma separated names of the index templates
|`flat_settings` or `flatSettings`
|`boolean` - Return settings in flat format (default: false)
|`master_timeout` or `masterTimeout`
|`string` - Explicit operation timeout for connection to master node
|`local`
|`boolean` - Return local information, do not retrieve the state from master node (default: false)
|===
=== indices.getMapping
[source,ts]
@ -3146,6 +3198,38 @@ link:{ref}/indices-aliases.html[Documentation] +
|===
=== indices.putIndexTemplate
[source,ts]
----
client.indices.putIndexTemplate({
name: string,
order: number,
create: boolean,
master_timeout: string,
body: object
})
----
link:{ref}/indices-templates.html[Documentation] +
[cols=2*]
|===
|`name`
|`string` - The name of the template
|`order`
|`number` - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)
|`create`
|`boolean` - Whether the index template should only be added if new or can also replace an existing one
|`master_timeout` or `masterTimeout`
|`string` - Specify timeout for connection to master
|`body`
|`object` - The template definition
|===
=== indices.putMapping
[source,ts]

24
index.d.ts vendored
View File

@ -869,6 +869,14 @@ declare class Client extends EventEmitter {
deleteDataStream<TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteDataStream<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesDeleteDataStream, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteDataStream<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesDeleteDataStream, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_index_template<TResponse = ResponseBody, TContext = unknown>(params?: RequestParams.IndicesDeleteIndexTemplate, options?: TransportRequestOptions): Promise<ApiResponse<TResponse, TContext>>
delete_index_template<TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_index_template<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesDeleteIndexTemplate, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_index_template<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesDeleteIndexTemplate, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteIndexTemplate<TResponse = ResponseBody, TContext = unknown>(params?: RequestParams.IndicesDeleteIndexTemplate, options?: TransportRequestOptions): Promise<ApiResponse<TResponse, TContext>>
deleteIndexTemplate<TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteIndexTemplate<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesDeleteIndexTemplate, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
deleteIndexTemplate<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesDeleteIndexTemplate, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_template<TResponse = ResponseBody, TContext = unknown>(params?: RequestParams.IndicesDeleteTemplate, options?: TransportRequestOptions): Promise<ApiResponse<TResponse, TContext>>
delete_template<TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
delete_template<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesDeleteTemplate, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
@ -945,6 +953,14 @@ declare class Client extends EventEmitter {
getFieldMapping<TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getFieldMapping<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesGetFieldMapping, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getFieldMapping<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesGetFieldMapping, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_index_template<TResponse = ResponseBody, TContext = unknown>(params?: RequestParams.IndicesGetIndexTemplate, options?: TransportRequestOptions): Promise<ApiResponse<TResponse, TContext>>
get_index_template<TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_index_template<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesGetIndexTemplate, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_index_template<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesGetIndexTemplate, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getIndexTemplate<TResponse = ResponseBody, TContext = unknown>(params?: RequestParams.IndicesGetIndexTemplate, options?: TransportRequestOptions): Promise<ApiResponse<TResponse, TContext>>
getIndexTemplate<TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getIndexTemplate<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesGetIndexTemplate, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getIndexTemplate<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesGetIndexTemplate, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_mapping<TResponse = ResponseBody, TContext = unknown>(params?: RequestParams.IndicesGetMapping, options?: TransportRequestOptions): Promise<ApiResponse<TResponse, TContext>>
get_mapping<TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_mapping<TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesGetMapping, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
@ -989,6 +1005,14 @@ declare class Client extends EventEmitter {
putAlias<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
putAlias<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesPutAlias<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
putAlias<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesPutAlias<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
put_index_template<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(params?: RequestParams.IndicesPutIndexTemplate<TRequestBody>, options?: TransportRequestOptions): Promise<ApiResponse<TResponse, TContext>>
put_index_template<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
put_index_template<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesPutIndexTemplate<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
put_index_template<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesPutIndexTemplate<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
putIndexTemplate<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(params?: RequestParams.IndicesPutIndexTemplate<TRequestBody>, options?: TransportRequestOptions): Promise<ApiResponse<TResponse, TContext>>
putIndexTemplate<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
putIndexTemplate<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesPutIndexTemplate<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
putIndexTemplate<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesPutIndexTemplate<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
put_mapping<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(params?: RequestParams.IndicesPutMapping<TRequestBody>, options?: TransportRequestOptions): Promise<ApiResponse<TResponse, TContext>>
put_mapping<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
put_mapping<TRequestBody extends RequestBody, TResponse = ResponseBody, TContext = unknown>(params: RequestParams.IndicesPutMapping<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback