API generation

This commit is contained in:
delvedor
2019-07-29 11:39:50 +02:00
parent a948a98be6
commit 1f1b4c29fa
6 changed files with 169 additions and 3 deletions

View File

@ -14,14 +14,18 @@ function buildIlmExplainLifecycle (opts) {
* Perform a [ilm.explain_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html) request
*
* @param {string} index - The name of the index to explain
* @param {boolean} only_managed - filters the indices included in the response to ones managed by ILM
* @param {boolean} only_errors - filters the indices included in the response to ones in an ILM error state, implies only_managed
*/
const acceptedQuerystring = [
'only_managed',
'only_errors'
]
const snakeCase = {
onlyManaged: 'only_managed',
onlyErrors: 'only_errors'
}
return function ilmExplainLifecycle (params, options, callback) {

106
api/api/indices.clone.js Normal file
View File

@ -0,0 +1,106 @@
// 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 buildIndicesClone (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [indices.clone](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clone-index.html) request
*
* @param {string} index - The name of the source index to clone
* @param {string} target - The name of the target index to clone into
* @param {time} timeout - Explicit operation timeout
* @param {time} master_timeout - Specify timeout for connection to master
* @param {string} wait_for_active_shards - Set the number of active shards to wait for on the cloned index before the operation returns.
* @param {object} body - The configuration for the target index (`settings` and `aliases`)
*/
const acceptedQuerystring = [
'timeout',
'master_timeout',
'wait_for_active_shards',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
masterTimeout: 'master_timeout',
waitForActiveShards: 'wait_for_active_shards',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function indicesClone (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['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
if (params['target'] == null) {
const err = new ConfigurationError('Missing required parameter: target')
return handleError(err, callback)
}
// check required url components
if (params['target'] != null && (params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: index')
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, index, target, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'PUT'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_clone' + '/' + encodeURIComponent(target)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIndicesClone

View File

@ -159,6 +159,7 @@ function ESAPI (opts) {
analyze: lazyLoad('indices.analyze', opts),
clear_cache: lazyLoad('indices.clear_cache', opts),
clearCache: lazyLoad('indices.clear_cache', opts),
clone: lazyLoad('indices.clone', opts),
close: lazyLoad('indices.close', opts),
create: lazyLoad('indices.create', opts),
delete: lazyLoad('indices.delete', opts),

View File

@ -558,6 +558,15 @@ export interface IndicesClearCache extends Generic {
request?: boolean;
}
export interface IndicesClone<T = any> extends Generic {
index: string;
target: string;
timeout?: string;
master_timeout?: string;
wait_for_active_shards?: string;
body?: T;
}
export interface IndicesClose extends Generic {
index: string | string[];
timeout?: string;
@ -1418,6 +1427,8 @@ export interface IlmDeleteLifecycle extends Generic {
export interface IlmExplainLifecycle extends Generic {
index?: string;
only_managed?: boolean;
only_errors?: boolean;
}
export interface IlmGetLifecycle extends Generic {

View File

@ -2143,6 +2143,41 @@ _Default:_ `open`
|===
=== indices.clone
[source,ts]
----
client.indices.clone({
index: string,
target: string,
timeout: string,
master_timeout: string,
wait_for_active_shards: string,
body: object
})
----
link:{ref}/indices-clone-index.html[Reference]
[cols=2*]
|===
|`index`
|`string` - The name of the source index to clone
|`target`
|`string` - The name of the target index to clone into
|`timeout`
|`string` - Explicit operation timeout
|`master_timeout` or `masterTimeout`
|`string` - Specify timeout for connection to master
|`wait_for_active_shards` or `waitForActiveShards`
|`string` - Set the number of active shards to wait for on the cloned index before the operation returns.
|`body`
|`object` - The configuration for the target index (`settings` and `aliases`)
|===
=== indices.close
[source,ts]
----
@ -5509,7 +5544,9 @@ link:{ref}/ilm-delete-lifecycle.html[Reference]
[source,ts]
----
client.ilm.explainLifecycle({
index: string
index: string,
only_managed: boolean,
only_errors: boolean
})
----
link:{ref}/ilm-explain-lifecycle.html[Reference]
@ -5518,6 +5555,12 @@ link:{ref}/ilm-explain-lifecycle.html[Reference]
|`index`
|`string` - The name of the index to explain
|`only_managed` or `onlyManaged`
|`boolean` - filters the indices included in the response to ones managed by ILM
|`only_errors` or `onlyErrors`
|`boolean` - filters the indices included in the response to ones in an ILM error state, implies only_managed
|===
=== ilm.getLifecycle

1
index.d.ts vendored
View File

@ -257,6 +257,7 @@ declare class Client extends EventEmitter {
analyze: ApiMethod<RequestParams.IndicesAnalyze>
clear_cache: ApiMethod<RequestParams.IndicesClearCache>
clearCache: ApiMethod<RequestParams.IndicesClearCache>
clone: ApiMethod<RequestParams.IndicesClone>
close: ApiMethod<RequestParams.IndicesClose>
create: ApiMethod<RequestParams.IndicesCreate>
delete: ApiMethod<RequestParams.IndicesDelete>