From 111da7e52916153222fbe45efce343a63508a78e Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 22 Mar 2021 11:54:16 +0100 Subject: [PATCH] API generation --- api/api/features.js | 59 +++++++++++++++++++++++++++++++++++++++++ api/api/snapshot.js | 22 --------------- api/index.js | 11 ++++++++ api/kibana.d.ts | 4 ++- api/requestParams.d.ts | 8 +++--- docs/reference.asciidoc | 34 ++++++++++++------------ index.d.ts | 18 +++++++------ 7 files changed, 104 insertions(+), 52 deletions(-) create mode 100644 api/api/features.js diff --git a/api/api/features.js b/api/api/features.js new file mode 100644 index 000000000..152ae7d2b --- /dev/null +++ b/api/api/features.js @@ -0,0 +1,59 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function FeaturesApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +FeaturesApi.prototype.getFeatures = function featuresGetFeaturesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + let { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + let path = '' + if (method == null) method = 'GET' + path = '/' + '_features' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(FeaturesApi.prototype, { + get_features: { get () { return this.getFeatures } } +}) + +module.exports = FeaturesApi diff --git a/api/api/snapshot.js b/api/api/snapshot.js index ddc78dcc6..35de58733 100644 --- a/api/api/snapshot.js +++ b/api/api/snapshot.js @@ -275,27 +275,6 @@ SnapshotApi.prototype.get = function snapshotGetApi (params, options, callback) return this.transport.request(request, options, callback) } -SnapshotApi.prototype.getFeatures = function snapshotGetFeaturesApi (params, options, callback) { - ;[params, options, callback] = normalizeArguments(params, options, callback) - - let { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - - let path = '' - if (method == null) method = 'GET' - path = '/' + '_snapshottable_features' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - return this.transport.request(request, options, callback) -} - SnapshotApi.prototype.getRepository = function snapshotGetRepositoryApi (params, options, callback) { ;[params, options, callback] = normalizeArguments(params, options, callback) @@ -425,7 +404,6 @@ Object.defineProperties(SnapshotApi.prototype, { cleanup_repository: { get () { return this.cleanupRepository } }, create_repository: { get () { return this.createRepository } }, delete_repository: { get () { return this.deleteRepository } }, - get_features: { get () { return this.getFeatures } }, get_repository: { get () { return this.getRepository } }, verify_repository: { get () { return this.verifyRepository } } }) diff --git a/api/index.js b/api/index.js index 496d99cdb..2156ab29c 100644 --- a/api/index.js +++ b/api/index.js @@ -33,6 +33,7 @@ const deleteScriptApi = require('./api/delete_script') const existsApi = require('./api/exists') const existsSourceApi = require('./api/exists_source') const explainApi = require('./api/explain') +const FeaturesApi = require('./api/features') const fieldCapsApi = require('./api/field_caps') const getApi = require('./api/get') const getScriptApi = require('./api/get_script') @@ -94,6 +95,7 @@ const { kConfigurationError } = require('./utils') const kCat = Symbol('Cat') const kCluster = Symbol('Cluster') const kDanglingIndices = Symbol('DanglingIndices') +const kFeatures = Symbol('Features') const kIndices = Symbol('Indices') const kIngest = Symbol('Ingest') const kNodes = Symbol('Nodes') @@ -127,6 +129,7 @@ function ESAPI (opts) { this[kCat] = null this[kCluster] = null this[kDanglingIndices] = null + this[kFeatures] = null this[kIndices] = null this[kIngest] = null this[kNodes] = null @@ -228,6 +231,14 @@ Object.defineProperties(ESAPI.prototype, { delete_by_query_rethrottle: { get () { return this.deleteByQueryRethrottle } }, delete_script: { get () { return this.deleteScript } }, exists_source: { get () { return this.existsSource } }, + features: { + get () { + if (this[kFeatures] === null) { + this[kFeatures] = new FeaturesApi(this.transport, this[kConfigurationError]) + } + return this[kFeatures] + } + }, field_caps: { get () { return this.fieldCaps } }, get_script: { get () { return this.getScript } }, get_script_context: { get () { return this.getScriptContext } }, diff --git a/api/kibana.d.ts b/api/kibana.d.ts index 68fe01bbd..52518bded 100644 --- a/api/kibana.d.ts +++ b/api/kibana.d.ts @@ -176,6 +176,9 @@ interface KibanaClient { exists(params?: RequestParams.Exists, options?: TransportRequestOptions): TransportRequestPromise> existsSource(params?: RequestParams.ExistsSource, options?: TransportRequestOptions): TransportRequestPromise> explain, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.Explain, options?: TransportRequestOptions): TransportRequestPromise> + features: { + getFeatures, TContext = Context>(params?: RequestParams.FeaturesGetFeatures, options?: TransportRequestOptions): TransportRequestPromise> + } fieldCaps, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.FieldCaps, options?: TransportRequestOptions): TransportRequestPromise> get, TContext = Context>(params?: RequestParams.Get, options?: TransportRequestOptions): TransportRequestPromise> getScript, TContext = Context>(params?: RequestParams.GetScript, options?: TransportRequestOptions): TransportRequestPromise> @@ -435,7 +438,6 @@ interface KibanaClient { delete, TContext = Context>(params?: RequestParams.SnapshotDelete, options?: TransportRequestOptions): TransportRequestPromise> deleteRepository, TContext = Context>(params?: RequestParams.SnapshotDeleteRepository, options?: TransportRequestOptions): TransportRequestPromise> get, TContext = Context>(params?: RequestParams.SnapshotGet, options?: TransportRequestOptions): TransportRequestPromise> - getFeatures, TContext = Context>(params?: RequestParams.SnapshotGetFeatures, options?: TransportRequestOptions): TransportRequestPromise> getRepository, TContext = Context>(params?: RequestParams.SnapshotGetRepository, options?: TransportRequestOptions): TransportRequestPromise> restore, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.SnapshotRestore, options?: TransportRequestOptions): TransportRequestPromise> status, TContext = Context>(params?: RequestParams.SnapshotStatus, options?: TransportRequestOptions): TransportRequestPromise> diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 5df6ec9ad..429c0beb9 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -788,6 +788,10 @@ export interface Explain extends Generic { body?: T; } +export interface FeaturesGetFeatures extends Generic { + master_timeout?: string; +} + export interface FieldCaps extends Generic { index?: string | string[]; fields?: string | string[]; @@ -2394,10 +2398,6 @@ export interface SnapshotGet extends Generic { verbose?: boolean; } -export interface SnapshotGetFeatures extends Generic { - master_timeout?: string; -} - export interface SnapshotGetRepository extends Generic { repository?: string | string[]; master_timeout?: string; diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index e5f5ee358..51bc3ca9d 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -3264,6 +3264,23 @@ _Default:_ `OR` |=== +[discrete] +=== features.getFeatures + +[source,ts] +---- +client.features.getFeatures({ + master_timeout: string +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|=== + [discrete] === fieldCaps @@ -9976,23 +9993,6 @@ link:{ref}/modules-snapshots.html[Documentation] + |=== -[discrete] -=== snapshot.getFeatures - -[source,ts] ----- -client.snapshot.getFeatures({ - master_timeout: string -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|=== - [discrete] === snapshot.getRepository diff --git a/index.d.ts b/index.d.ts index 01c856178..7f7502630 100644 --- a/index.d.ts +++ b/index.d.ts @@ -720,6 +720,16 @@ declare class Client { explain, TRequestBody extends RequestBody = Record, TContext = Context>(callback: callbackFn): TransportRequestCallback explain, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.Explain, callback: callbackFn): TransportRequestCallback explain, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.Explain, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + features: { + get_features, TContext = Context>(params?: RequestParams.FeaturesGetFeatures, options?: TransportRequestOptions): TransportRequestPromise> + get_features, TContext = Context>(callback: callbackFn): TransportRequestCallback + get_features, TContext = Context>(params: RequestParams.FeaturesGetFeatures, callback: callbackFn): TransportRequestCallback + get_features, TContext = Context>(params: RequestParams.FeaturesGetFeatures, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + getFeatures, TContext = Context>(params?: RequestParams.FeaturesGetFeatures, options?: TransportRequestOptions): TransportRequestPromise> + getFeatures, TContext = Context>(callback: callbackFn): TransportRequestCallback + getFeatures, TContext = Context>(params: RequestParams.FeaturesGetFeatures, callback: callbackFn): TransportRequestCallback + getFeatures, TContext = Context>(params: RequestParams.FeaturesGetFeatures, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback + } field_caps, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.FieldCaps, options?: TransportRequestOptions): TransportRequestPromise> field_caps, TRequestBody extends RequestBody = Record, TContext = Context>(callback: callbackFn): TransportRequestCallback field_caps, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.FieldCaps, callback: callbackFn): TransportRequestCallback @@ -2391,14 +2401,6 @@ declare class Client { get, TContext = Context>(callback: callbackFn): TransportRequestCallback get, TContext = Context>(params: RequestParams.SnapshotGet, callback: callbackFn): TransportRequestCallback get, TContext = Context>(params: RequestParams.SnapshotGet, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback - get_features, TContext = Context>(params?: RequestParams.SnapshotGetFeatures, options?: TransportRequestOptions): TransportRequestPromise> - get_features, TContext = Context>(callback: callbackFn): TransportRequestCallback - get_features, TContext = Context>(params: RequestParams.SnapshotGetFeatures, callback: callbackFn): TransportRequestCallback - get_features, TContext = Context>(params: RequestParams.SnapshotGetFeatures, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback - getFeatures, TContext = Context>(params?: RequestParams.SnapshotGetFeatures, options?: TransportRequestOptions): TransportRequestPromise> - getFeatures, TContext = Context>(callback: callbackFn): TransportRequestCallback - getFeatures, TContext = Context>(params: RequestParams.SnapshotGetFeatures, callback: callbackFn): TransportRequestCallback - getFeatures, TContext = Context>(params: RequestParams.SnapshotGetFeatures, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback get_repository, TContext = Context>(params?: RequestParams.SnapshotGetRepository, options?: TransportRequestOptions): TransportRequestPromise> get_repository, TContext = Context>(callback: callbackFn): TransportRequestCallback get_repository, TContext = Context>(params: RequestParams.SnapshotGetRepository, callback: callbackFn): TransportRequestCallback