Skip to content

Commit def28e3

Browse files
committed
API generation
1 parent 498199c commit def28e3

File tree

5 files changed

+173
-0
lines changed

5 files changed

+173
-0
lines changed

Diff for: api/api/search_mvt.js

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
'use strict'
21+
22+
/* eslint camelcase: 0 */
23+
/* eslint no-unused-vars: 0 */
24+
25+
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
26+
const acceptedQuerystring = ['exact_bounds', 'extent', 'grid_precision', 'grid_type', 'size', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
27+
const snakeCase = { exactBounds: 'exact_bounds', gridPrecision: 'grid_precision', gridType: 'grid_type', errorTrace: 'error_trace', filterPath: 'filter_path' }
28+
29+
function searchMvtApi (params, options, callback) {
30+
;[params, options, callback] = normalizeArguments(params, options, callback)
31+
32+
// check required parameters
33+
if (params.index == null) {
34+
const err = new this[kConfigurationError]('Missing required parameter: index')
35+
return handleError(err, callback)
36+
}
37+
if (params.field == null) {
38+
const err = new this[kConfigurationError]('Missing required parameter: field')
39+
return handleError(err, callback)
40+
}
41+
if (params.zoom == null) {
42+
const err = new this[kConfigurationError]('Missing required parameter: zoom')
43+
return handleError(err, callback)
44+
}
45+
if (params.x == null) {
46+
const err = new this[kConfigurationError]('Missing required parameter: x')
47+
return handleError(err, callback)
48+
}
49+
if (params.y == null) {
50+
const err = new this[kConfigurationError]('Missing required parameter: y')
51+
return handleError(err, callback)
52+
}
53+
54+
// check required url components
55+
if (params.y != null && (params.x == null || params.zoom == null || params.field == null || params.index == null)) {
56+
const err = new this[kConfigurationError]('Missing required parameter of the url: x, zoom, field, index')
57+
return handleError(err, callback)
58+
} else if (params.x != null && (params.zoom == null || params.field == null || params.index == null)) {
59+
const err = new this[kConfigurationError]('Missing required parameter of the url: zoom, field, index')
60+
return handleError(err, callback)
61+
} else if (params.zoom != null && (params.field == null || params.index == null)) {
62+
const err = new this[kConfigurationError]('Missing required parameter of the url: field, index')
63+
return handleError(err, callback)
64+
} else if (params.field != null && (params.index == null)) {
65+
const err = new this[kConfigurationError]('Missing required parameter of the url: index')
66+
return handleError(err, callback)
67+
}
68+
69+
let { method, body, index, field, zoom, x, y, ...querystring } = params
70+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
71+
72+
let path = ''
73+
if (method == null) method = body == null ? 'GET' : 'POST'
74+
path = '/' + encodeURIComponent(index) + '/' + '_mvt' + '/' + encodeURIComponent(field) + '/' + encodeURIComponent(zoom) + '/' + encodeURIComponent(x) + '/' + encodeURIComponent(y)
75+
76+
// build request object
77+
const request = {
78+
method,
79+
path,
80+
body: body || '',
81+
querystring
82+
}
83+
84+
return this.transport.request(request, options, callback)
85+
}
86+
87+
module.exports = searchMvtApi

Diff for: api/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const RollupApi = require('./api/rollup')
7474
const scriptsPainlessExecuteApi = require('./api/scripts_painless_execute')
7575
const scrollApi = require('./api/scroll')
7676
const searchApi = require('./api/search')
77+
const searchMvtApi = require('./api/search_mvt')
7778
const searchShardsApi = require('./api/search_shards')
7879
const searchTemplateApi = require('./api/search_template')
7980
const SearchableSnapshotsApi = require('./api/searchable_snapshots')
@@ -200,6 +201,7 @@ ESAPI.prototype.renderSearchTemplate = renderSearchTemplateApi
200201
ESAPI.prototype.scriptsPainlessExecute = scriptsPainlessExecuteApi
201202
ESAPI.prototype.scroll = scrollApi
202203
ESAPI.prototype.search = searchApi
204+
ESAPI.prototype.searchMvt = searchMvtApi
203205
ESAPI.prototype.searchShards = searchShardsApi
204206
ESAPI.prototype.searchTemplate = searchTemplateApi
205207
ESAPI.prototype.termsEnum = termsEnumApi
@@ -397,6 +399,7 @@ Object.defineProperties(ESAPI.prototype, {
397399
}
398400
},
399401
scripts_painless_execute: { get () { return this.scriptsPainlessExecute } },
402+
search_mvt: { get () { return this.searchMvt } },
400403
search_shards: { get () { return this.searchShards } },
401404
search_template: { get () { return this.searchTemplate } },
402405
searchableSnapshots: {

Diff for: api/requestParams.d.ts

+14
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,20 @@ export interface Search<T = RequestBody> extends Generic {
21802180
body?: T;
21812181
}
21822182

2183+
export interface SearchMvt<T = RequestBody> extends Generic {
2184+
index: string | string[];
2185+
field: string;
2186+
zoom: integer;
2187+
x: integer;
2188+
y: integer;
2189+
exact_bounds?: boolean;
2190+
extent?: number;
2191+
grid_precision?: number;
2192+
grid_type?: 'grid' | 'point';
2193+
size?: number;
2194+
body?: T;
2195+
}
2196+
21832197
export interface SearchShards extends Generic {
21842198
index?: string | string[];
21852199
preference?: string;

Diff for: docs/reference.asciidoc

+61
Original file line numberDiff line numberDiff line change
@@ -8993,6 +8993,67 @@ _Default:_ `5`
89938993

89948994
|===
89958995

8996+
[discrete]
8997+
=== searchMvt
8998+
*Stability:* experimental
8999+
[source,ts]
9000+
----
9001+
client.searchMvt({
9002+
index: string | string[],
9003+
field: string,
9004+
zoom: integer,
9005+
x: integer,
9006+
y: integer,
9007+
exact_bounds: boolean,
9008+
extent: number,
9009+
grid_precision: number,
9010+
grid_type: 'grid' | 'point',
9011+
size: number,
9012+
body: object
9013+
})
9014+
----
9015+
link:{ref}/search-vector-tile-api.html[Documentation] +
9016+
[cols=2*]
9017+
|===
9018+
|`index`
9019+
|`string \| string[]` - Comma-separated list of data streams, indices, or aliases to search
9020+
9021+
|`field`
9022+
|`string` - Field containing geospatial data to return
9023+
9024+
|`zoom`
9025+
|`integer` - Zoom level for the vector tile to search
9026+
9027+
|`x`
9028+
|`integer` - X coordinate for the vector tile to search
9029+
9030+
|`y`
9031+
|`integer` - Y coordinate for the vector tile to search
9032+
9033+
|`exact_bounds` or `exactBounds`
9034+
|`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.
9035+
9036+
|`extent`
9037+
|`number` - Size, in pixels, of a side of the vector tile. +
9038+
_Default:_ `4096`
9039+
9040+
|`grid_precision` or `gridPrecision`
9041+
|`number` - Additional zoom levels available through the aggs layer. Accepts 0-8. +
9042+
_Default:_ `8`
9043+
9044+
|`grid_type` or `gridType`
9045+
|`'grid' \| 'point'` - Determines the geometry type for features in the aggs layer. +
9046+
_Default:_ `grid`
9047+
9048+
|`size`
9049+
|`number` - Maximum number of features to return in the hits layer. Accepts 0-10000. +
9050+
_Default:_ `10000`
9051+
9052+
|`body`
9053+
|`object` - Search request body.
9054+
9055+
|===
9056+
89969057
[discrete]
89979058
=== searchShards
89989059

Diff for: index.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,14 @@ declare class Client {
21012101
search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
21022102
search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Search<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
21032103
search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Search<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2104+
search_mvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SearchMvt<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
2105+
search_mvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2106+
search_mvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SearchMvt<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2107+
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
2108+
searchMvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SearchMvt<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
2109+
searchMvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2110+
searchMvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SearchMvt<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2111+
searchMvt<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SearchMvt<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
21042112
search_shards<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SearchShards, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
21052113
search_shards<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
21062114
search_shards<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SearchShards, callback: callbackFn<TResponse, TContext>): TransportRequestCallback

0 commit comments

Comments
 (0)