API generation

This commit is contained in:
delvedor
2020-04-10 12:21:27 +02:00
parent 0e659031e3
commit cfc21f56c2
8 changed files with 137 additions and 4 deletions

View File

@ -0,0 +1,88 @@
// 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 buildIndicesExistsIndexTemplate (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.exists_index_template request
* Returns information about whether a particular index template exists.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
*/
return function indicesExistsIndexTemplate (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 = 'HEAD'
path = '/' + '_index_template' + '/' + encodeURIComponent(name)
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIndicesExistsIndexTemplate

View File

@ -27,7 +27,7 @@ function buildSearchableSnapshotsClearCache (opts) {
/** /**
* Perform a searchable_snapshots.clear_cache request * Perform a searchable_snapshots.clear_cache request
* https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-clear-cache.html * https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-clear-cache.html
*/ */
return function searchableSnapshotsClearCache (params, options, callback) { return function searchableSnapshotsClearCache (params, options, callback) {
options = options || {} options = options || {}

View File

@ -23,7 +23,7 @@ function buildSearchableSnapshotsMount (opts) {
/** /**
* Perform a searchable_snapshots.mount request * Perform a searchable_snapshots.mount request
* https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-mount-snapshot * https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-mount-snapshot.html
*/ */
return function searchableSnapshotsMount (params, options, callback) { return function searchableSnapshotsMount (params, options, callback) {
options = options || {} options = options || {}

View File

@ -21,7 +21,7 @@ function buildSearchableSnapshotsStats (opts) {
/** /**
* Perform a searchable_snapshots.stats request * Perform a searchable_snapshots.stats request
* https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-stats.html * https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-stats.html
*/ */
return function searchableSnapshotsStats (params, options, callback) { return function searchableSnapshotsStats (params, options, callback) {
options = options || {} options = options || {}

View File

@ -239,6 +239,8 @@ function ESAPI (opts) {
exists: lazyLoad('indices.exists', opts), exists: lazyLoad('indices.exists', opts),
exists_alias: lazyLoad('indices.exists_alias', opts), exists_alias: lazyLoad('indices.exists_alias', opts),
existsAlias: lazyLoad('indices.exists_alias', opts), existsAlias: lazyLoad('indices.exists_alias', opts),
exists_index_template: lazyLoad('indices.exists_index_template', opts),
existsIndexTemplate: lazyLoad('indices.exists_index_template', opts),
exists_template: lazyLoad('indices.exists_template', opts), exists_template: lazyLoad('indices.exists_template', opts),
existsTemplate: lazyLoad('indices.exists_template', opts), existsTemplate: lazyLoad('indices.exists_template', opts),
exists_type: lazyLoad('indices.exists_type', opts), exists_type: lazyLoad('indices.exists_type', opts),

View File

@ -673,6 +673,13 @@ export interface IndicesExistsAlias extends Generic {
local?: boolean; local?: boolean;
} }
export interface IndicesExistsIndexTemplate extends Generic {
name: string;
flat_settings?: boolean;
master_timeout?: string;
local?: boolean;
}
export interface IndicesExistsTemplate extends Generic { export interface IndicesExistsTemplate extends Generic {
name: string | string[]; name: string | string[];
flat_settings?: boolean; flat_settings?: boolean;

View File

@ -2699,6 +2699,34 @@ _Default:_ `all`
|=== |===
=== indices.existsIndexTemplate
[source,ts]
----
client.indices.existsIndexTemplate({
name: string,
flat_settings: boolean,
master_timeout: string,
local: boolean
})
----
link:{ref}/indices-templates.html[Documentation] +
[cols=2*]
|===
|`name`
|`string` - The name of the template
|`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.existsTemplate === indices.existsTemplate
[source,ts] [source,ts]
@ -8814,7 +8842,7 @@ client.searchableSnapshots.mount({
body: object body: object
}) })
---- ----
link:{ref}/searchable-snapshots-api-mount-snapshot.html[Documentation] +
[cols=2*] [cols=2*]
|=== |===
|`repository` |`repository`

8
index.d.ts vendored
View File

@ -929,6 +929,14 @@ declare class Client extends EventEmitter {
existsAlias<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback existsAlias<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
existsAlias<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesExistsAlias, callback: callbackFn<TResponse, TContext>): TransportRequestCallback existsAlias<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesExistsAlias, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
existsAlias<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesExistsAlias, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback existsAlias<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesExistsAlias, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
exists_index_template<TResponse = Record<string, any>, TContext = unknown>(params?: RequestParams.IndicesExistsIndexTemplate, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
exists_index_template<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
exists_index_template<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesExistsIndexTemplate, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
exists_index_template<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesExistsIndexTemplate, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
existsIndexTemplate<TResponse = Record<string, any>, TContext = unknown>(params?: RequestParams.IndicesExistsIndexTemplate, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
existsIndexTemplate<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
existsIndexTemplate<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesExistsIndexTemplate, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
existsIndexTemplate<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesExistsIndexTemplate, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
exists_template<TResponse = Record<string, any>, TContext = unknown>(params?: RequestParams.IndicesExistsTemplate, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>> exists_template<TResponse = Record<string, any>, TContext = unknown>(params?: RequestParams.IndicesExistsTemplate, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
exists_template<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback exists_template<TResponse = Record<string, any>, TContext = unknown>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
exists_template<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesExistsTemplate, callback: callbackFn<TResponse, TContext>): TransportRequestCallback exists_template<TResponse = Record<string, any>, TContext = unknown>(params: RequestParams.IndicesExistsTemplate, callback: callbackFn<TResponse, TContext>): TransportRequestCallback