API generation

This commit is contained in:
delvedor
2021-03-22 11:54:16 +01:00
parent d615692b9f
commit 111da7e529
7 changed files with 104 additions and 52 deletions

59
api/api/features.js Normal file
View File

@ -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

View File

@ -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 } }
})

View File

@ -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 } },

4
api/kibana.d.ts vendored
View File

@ -176,6 +176,9 @@ interface KibanaClient {
exists<TResponse = boolean, TContext = Context>(params?: RequestParams.Exists, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
existsSource<TResponse = boolean, TContext = Context>(params?: RequestParams.ExistsSource, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
explain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.Explain<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
features: {
getFeatures<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.FeaturesGetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
}
fieldCaps<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.FieldCaps<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
get<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.Get, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
getScript<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.GetScript, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
@ -435,7 +438,6 @@ interface KibanaClient {
delete<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotDelete, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
deleteRepository<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotDeleteRepository, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
get<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotGet, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
getFeatures<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotGetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
getRepository<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotGetRepository, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
restore<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotRestore<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
status<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotStatus, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>

View File

@ -788,6 +788,10 @@ export interface Explain<T = RequestBody> extends Generic {
body?: T;
}
export interface FeaturesGetFeatures extends Generic {
master_timeout?: string;
}
export interface FieldCaps<T = RequestBody> 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;

View File

@ -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

18
index.d.ts vendored
View File

@ -720,6 +720,16 @@ declare class Client {
explain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
explain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Explain<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
explain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Explain<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
features: {
get_features<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.FeaturesGetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
get_features<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_features<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.FeaturesGetFeatures, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_features<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.FeaturesGetFeatures, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getFeatures<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.FeaturesGetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
getFeatures<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getFeatures<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.FeaturesGetFeatures, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getFeatures<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.FeaturesGetFeatures, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
}
field_caps<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.FieldCaps<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
field_caps<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
field_caps<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.FieldCaps<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
@ -2391,14 +2401,6 @@ declare class Client {
get<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotGet, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotGet, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_features<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotGetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
get_features<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_features<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotGetFeatures, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_features<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotGetFeatures, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getFeatures<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotGetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
getFeatures<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getFeatures<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotGetFeatures, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
getFeatures<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotGetFeatures, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_repository<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotGetRepository, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
get_repository<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
get_repository<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotGetRepository, callback: callbackFn<TResponse, TContext>): TransportRequestCallback