API generation

This commit is contained in:
delvedor
2021-08-11 12:00:15 +02:00
parent 3bd3748feb
commit 0f35880143
5 changed files with 177 additions and 4 deletions

87
api/api/search_mvt.js Normal file
View File

@ -0,0 +1,87 @@
/*
* 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 = ['exact_bounds', 'extent', 'grid_precision', 'grid_type', 'size', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
const snakeCase = { exactBounds: 'exact_bounds', gridPrecision: 'grid_precision', gridType: 'grid_type', errorTrace: 'error_trace', filterPath: 'filter_path' }
function searchMvtApi (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)
}
if (params.field == null) {
const err = new this[kConfigurationError]('Missing required parameter: field')
return handleError(err, callback)
}
if (params.zoom == null) {
const err = new this[kConfigurationError]('Missing required parameter: zoom')
return handleError(err, callback)
}
if (params.x == null) {
const err = new this[kConfigurationError]('Missing required parameter: x')
return handleError(err, callback)
}
if (params.y == null) {
const err = new this[kConfigurationError]('Missing required parameter: y')
return handleError(err, callback)
}
// check required url components
if (params.y != null && (params.x == null || params.zoom == null || params.field == null || params.index == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: x, zoom, field, index')
return handleError(err, callback)
} else if (params.x != null && (params.zoom == null || params.field == null || params.index == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: zoom, field, index')
return handleError(err, callback)
} else if (params.zoom != null && (params.field == null || params.index == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: field, index')
return handleError(err, callback)
} else if (params.field != null && (params.index == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: index')
return handleError(err, callback)
}
let { method, body, index, field, zoom, x, y, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
let path = ''
if (method == null) method = body == null ? 'GET' : 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_mvt' + '/' + encodeURIComponent(field) + '/' + encodeURIComponent(zoom) + '/' + encodeURIComponent(x) + '/' + encodeURIComponent(y)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
return this.transport.request(request, options, callback)
}
module.exports = searchMvtApi

View File

@ -74,6 +74,7 @@ const RollupApi = require('./api/rollup')
const scriptsPainlessExecuteApi = require('./api/scripts_painless_execute')
const scrollApi = require('./api/scroll')
const searchApi = require('./api/search')
const searchMvtApi = require('./api/search_mvt')
const searchShardsApi = require('./api/search_shards')
const searchTemplateApi = require('./api/search_template')
const SearchableSnapshotsApi = require('./api/searchable_snapshots')
@ -200,6 +201,7 @@ ESAPI.prototype.renderSearchTemplate = renderSearchTemplateApi
ESAPI.prototype.scriptsPainlessExecute = scriptsPainlessExecuteApi
ESAPI.prototype.scroll = scrollApi
ESAPI.prototype.search = searchApi
ESAPI.prototype.searchMvt = searchMvtApi
ESAPI.prototype.searchShards = searchShardsApi
ESAPI.prototype.searchTemplate = searchTemplateApi
ESAPI.prototype.termsEnum = termsEnumApi
@ -397,6 +399,7 @@ Object.defineProperties(ESAPI.prototype, {
}
},
scripts_painless_execute: { get () { return this.scriptsPainlessExecute } },
search_mvt: { get () { return this.searchMvt } },
search_shards: { get () { return this.searchShards } },
search_template: { get () { return this.searchTemplate } },
searchableSnapshots: {

View File

@ -2236,6 +2236,20 @@ export interface Search<T = RequestBody> extends Generic {
body?: T;
}
export interface SearchMvt<T = RequestBody> extends Generic {
index: string | string[];
field: string;
zoom: integer;
x: integer;
y: integer;
exact_bounds?: boolean;
extent?: number;
grid_precision?: number;
grid_type?: 'grid' | 'point';
size?: number;
body?: T;
}
export interface SearchShards extends Generic {
index?: string | string[];
preference?: string;

View File

@ -1969,7 +1969,7 @@ link:{ref}/cluster-allocation-explain.html[Documentation] +
|`boolean` - Return information about disk usage and shard sizes (default: false)
|`body`
|`object` - The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard'
|`object` - The index, shard, and primary flag to explain. Empty means 'explain a randomly-chosen unassigned shard'
|===
@ -9248,6 +9248,67 @@ _Default:_ `5`
|===
[discrete]
=== searchMvt
*Stability:* experimental
[source,ts]
----
client.searchMvt({
index: string | string[],
field: string,
zoom: integer,
x: integer,
y: integer,
exact_bounds: boolean,
extent: number,
grid_precision: number,
grid_type: 'grid' | 'point',
size: number,
body: object
})
----
link:{ref}/search-vector-tile-api.html[Documentation] +
[cols=2*]
|===
|`index`
|`string \| string[]` - Comma-separated list of data streams, indices, or aliases to search
|`field`
|`string` - Field containing geospatial data to return
|`zoom`
|`integer` - Zoom level for the vector tile to search
|`x`
|`integer` - X coordinate for the vector tile to search
|`y`
|`integer` - Y coordinate for the vector tile to search
|`exact_bounds` or `exactBounds`
|`boolean` - If false, the meta layer's feature is the bounding box of the tile. If true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation.
|`extent`
|`number` - Size, in pixels, of a side of the vector tile. +
_Default:_ `4096`
|`grid_precision` or `gridPrecision`
|`number` - Additional zoom levels available through the aggs layer. Accepts 0-8. +
_Default:_ `8`
|`grid_type` or `gridType`
|`'grid' \| 'point'` - Determines the geometry type for features in the aggs layer. +
_Default:_ `grid`
|`size`
|`number` - Maximum number of features to return in the hits layer. Accepts 0-10000. +
_Default:_ `10000`
|`body`
|`object` - Search request body.
|===
[discrete]
=== searchShards
@ -10865,7 +10926,7 @@ client.sql.clearCursor({
body: object
})
----
link:{ref}/sql-pagination.html[Documentation] +
link:{ref}/clear-sql-cursor-api.html[Documentation] +
[cols=2*]
|===
|`body`
@ -10952,7 +11013,7 @@ client.sql.query({
body: object
})
----
link:{ref}/sql-rest-overview.html[Documentation] +
link:{ref}/sql-search-api.html[Documentation] +
{jsclient}/sql_query_examples.html[Code Example] +
[cols=2*]
|===
@ -10973,7 +11034,7 @@ client.sql.translate({
body: object
})
----
link:{ref}/sql-translate.html[Documentation] +
link:{ref}/sql-translate-api.html[Documentation] +
[cols=2*]
|===
|`body`

8
index.d.ts vendored
View File

@ -2105,6 +2105,14 @@ declare class Client {
search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Search<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Search<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
search_mvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SearchMvt<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
search_mvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
search_mvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SearchMvt<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
search_mvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SearchMvt<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
searchMvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SearchMvt<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
searchMvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
searchMvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SearchMvt<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
searchMvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SearchMvt<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
search_shards<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SearchShards, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
search_shards<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
search_shards<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SearchShards, callback: callbackFn<TResponse, TContext>): TransportRequestCallback