From 791f2168a3b99b1fd78b5940ec5cbd8ca0ac4293 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 12 May 2021 17:38:05 +0200 Subject: [PATCH] API generation --- api/api/termsenum.js | 56 +++++++++++++++++++++++++++++++++++++++++ api/index.js | 2 ++ api/requestParams.d.ts | 5 ++++ docs/reference.asciidoc | 21 ++++++++++++++++ index.d.ts | 4 +++ 5 files changed, 88 insertions(+) create mode 100644 api/api/termsenum.js diff --git a/api/api/termsenum.js b/api/api/termsenum.js new file mode 100644 index 000000000..029c4769d --- /dev/null +++ b/api/api/termsenum.js @@ -0,0 +1,56 @@ +/* + * 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 = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function termsenumApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params.index == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + let { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + let path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_terms_enum' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = termsenumApi diff --git a/api/index.js b/api/index.js index ca8bb5d80..e226a1f55 100644 --- a/api/index.js +++ b/api/index.js @@ -84,6 +84,7 @@ const SnapshotApi = require('./api/snapshot') const SqlApi = require('./api/sql') const SslApi = require('./api/ssl') const TasksApi = require('./api/tasks') +const termsenumApi = require('./api/termsenum') const termvectorsApi = require('./api/termvectors') const TextStructureApi = require('./api/text_structure') const TransformApi = require('./api/transform') @@ -201,6 +202,7 @@ ESAPI.prototype.scroll = scrollApi ESAPI.prototype.search = searchApi ESAPI.prototype.searchShards = searchShardsApi ESAPI.prototype.searchTemplate = searchTemplateApi +ESAPI.prototype.termsenum = termsenumApi ESAPI.prototype.termvectors = termvectorsApi ESAPI.prototype.update = updateApi ESAPI.prototype.updateByQuery = updateByQueryApi diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index e5332916d..1391ed578 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -2509,6 +2509,11 @@ export interface TasksList extends Generic { timeout?: string; } +export interface Termsenum extends Generic { + index: string | string[]; + body?: T; +} + export interface Termvectors extends Generic { index: string; id?: string; diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index d3c57ffc4..de5c23a2b 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -10345,6 +10345,27 @@ _Default:_ `nodes` |=== +[discrete] +=== termsenum +*Stability:* beta +[source,ts] +---- +client.termsenum({ + index: string | string[], + body: object +}) +---- +link:{ref}/terms-enum.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`body` +|`object` - field name, string which is the prefix expected in matching terms, timeout and size for max number of results + +|=== + [discrete] === termvectors diff --git a/index.d.ts b/index.d.ts index 45e78212f..1064b3b69 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2561,6 +2561,10 @@ declare class Client { list, TContext = Context>(params: RequestParams.TasksList, callback: callbackFn): TransportRequestCallback list, TContext = Context>(params: RequestParams.TasksList, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback } + termsenum, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.Termsenum, options?: TransportRequestOptions): TransportRequestPromise> + termsenum, TRequestBody extends RequestBody = Record, TContext = Context>(callback: callbackFn): TransportRequestCallback + termsenum, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.Termsenum, callback: callbackFn): TransportRequestCallback + termsenum, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.Termsenum, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback termvectors, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.Termvectors, options?: TransportRequestOptions): TransportRequestPromise> termvectors, TRequestBody extends RequestBody = Record, TContext = Context>(callback: callbackFn): TransportRequestCallback termvectors, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.Termvectors, callback: callbackFn): TransportRequestCallback