Skip to content

Commit c96c41d

Browse files
committed
API generation
1 parent ab3e809 commit c96c41d

10 files changed

+230
-57
lines changed

api/api/features.js

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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 = ['master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
27+
const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' }
28+
29+
function FeaturesApi (transport, ConfigurationError) {
30+
this.transport = transport
31+
this[kConfigurationError] = ConfigurationError
32+
}
33+
34+
FeaturesApi.prototype.getFeatures = function featuresGetFeaturesApi (params, options, callback) {
35+
;[params, options, callback] = normalizeArguments(params, options, callback)
36+
37+
let { method, body, ...querystring } = params
38+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
39+
40+
let path = ''
41+
if (method == null) method = 'GET'
42+
path = '/' + '_features'
43+
44+
// build request object
45+
const request = {
46+
method,
47+
path,
48+
body: null,
49+
querystring
50+
}
51+
52+
return this.transport.request(request, options, callback)
53+
}
54+
55+
FeaturesApi.prototype.resetFeatures = function featuresResetFeaturesApi (params, options, callback) {
56+
;[params, options, callback] = normalizeArguments(params, options, callback)
57+
58+
let { method, body, ...querystring } = params
59+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
60+
61+
let path = ''
62+
if (method == null) method = 'POST'
63+
path = '/' + '_features' + '/' + '_reset'
64+
65+
// build request object
66+
const request = {
67+
method,
68+
path,
69+
body: body || '',
70+
querystring
71+
}
72+
73+
return this.transport.request(request, options, callback)
74+
}
75+
76+
Object.defineProperties(FeaturesApi.prototype, {
77+
get_features: { get () { return this.getFeatures } },
78+
reset_features: { get () { return this.resetFeatures } }
79+
})
80+
81+
module.exports = FeaturesApi

api/api/ingest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/* eslint no-unused-vars: 0 */
2424

2525
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
26-
const acceptedQuerystring = ['master_timeout', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'verbose']
26+
const acceptedQuerystring = ['master_timeout', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'summary', 'verbose']
2727
const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' }
2828

2929
function IngestApi (transport, ConfigurationError) {

api/api/ml.js

+27
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,32 @@ MlApi.prototype.postData = function mlPostDataApi (params, options, callback) {
11581158
return this.transport.request(request, options, callback)
11591159
}
11601160

1161+
MlApi.prototype.previewDataFrameAnalytics = function mlPreviewDataFrameAnalyticsApi (params, options, callback) {
1162+
;[params, options, callback] = normalizeArguments(params, options, callback)
1163+
1164+
let { method, body, id, ...querystring } = params
1165+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
1166+
1167+
let path = ''
1168+
if ((id) != null) {
1169+
if (method == null) method = body == null ? 'GET' : 'POST'
1170+
path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_preview'
1171+
} else {
1172+
if (method == null) method = body == null ? 'GET' : 'POST'
1173+
path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + '_preview'
1174+
}
1175+
1176+
// build request object
1177+
const request = {
1178+
method,
1179+
path,
1180+
body: body || '',
1181+
querystring
1182+
}
1183+
1184+
return this.transport.request(request, options, callback)
1185+
}
1186+
11611187
MlApi.prototype.previewDatafeed = function mlPreviewDatafeedApi (params, options, callback) {
11621188
;[params, options, callback] = normalizeArguments(params, options, callback)
11631189

@@ -1901,6 +1927,7 @@ Object.defineProperties(MlApi.prototype, {
19011927
open_job: { get () { return this.openJob } },
19021928
post_calendar_events: { get () { return this.postCalendarEvents } },
19031929
post_data: { get () { return this.postData } },
1930+
preview_data_frame_analytics: { get () { return this.previewDataFrameAnalytics } },
19041931
preview_datafeed: { get () { return this.previewDatafeed } },
19051932
put_calendar: { get () { return this.putCalendar } },
19061933
put_calendar_job: { get () { return this.putCalendarJob } },

api/api/nodes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
/* eslint no-unused-vars: 0 */
2424

2525
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
26-
const acceptedQuerystring = ['interval', 'snapshots', 'threads', 'ignore_idle_threads', 'type', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'flat_settings', 'completion_fields', 'fielddata_fields', 'fields', 'groups', 'level', 'types', 'include_segment_file_sizes']
27-
const snakeCase = { ignoreIdleThreads: 'ignore_idle_threads', errorTrace: 'error_trace', filterPath: 'filter_path', flatSettings: 'flat_settings', completionFields: 'completion_fields', fielddataFields: 'fielddata_fields', includeSegmentFileSizes: 'include_segment_file_sizes' }
26+
const acceptedQuerystring = ['interval', 'snapshots', 'threads', 'ignore_idle_threads', 'type', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'flat_settings', 'completion_fields', 'fielddata_fields', 'fields', 'groups', 'level', 'types', 'include_segment_file_sizes', 'include_unloaded_segments']
27+
const snakeCase = { ignoreIdleThreads: 'ignore_idle_threads', errorTrace: 'error_trace', filterPath: 'filter_path', flatSettings: 'flat_settings', completionFields: 'completion_fields', fielddataFields: 'fielddata_fields', includeSegmentFileSizes: 'include_segment_file_sizes', includeUnloadedSegments: 'include_unloaded_segments' }
2828

2929
function NodesApi (transport, ConfigurationError) {
3030
this.transport = transport

api/api/snapshot.js

-22
Original file line numberDiff line numberDiff line change
@@ -275,27 +275,6 @@ SnapshotApi.prototype.get = function snapshotGetApi (params, options, callback)
275275
return this.transport.request(request, options, callback)
276276
}
277277

278-
SnapshotApi.prototype.getFeatures = function snapshotGetFeaturesApi (params, options, callback) {
279-
;[params, options, callback] = normalizeArguments(params, options, callback)
280-
281-
let { method, body, ...querystring } = params
282-
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
283-
284-
let path = ''
285-
if (method == null) method = 'GET'
286-
path = '/' + '_snapshottable_features'
287-
288-
// build request object
289-
const request = {
290-
method,
291-
path,
292-
body: null,
293-
querystring
294-
}
295-
296-
return this.transport.request(request, options, callback)
297-
}
298-
299278
SnapshotApi.prototype.getRepository = function snapshotGetRepositoryApi (params, options, callback) {
300279
;[params, options, callback] = normalizeArguments(params, options, callback)
301280

@@ -425,7 +404,6 @@ Object.defineProperties(SnapshotApi.prototype, {
425404
cleanup_repository: { get () { return this.cleanupRepository } },
426405
create_repository: { get () { return this.createRepository } },
427406
delete_repository: { get () { return this.deleteRepository } },
428-
get_features: { get () { return this.getFeatures } },
429407
get_repository: { get () { return this.getRepository } },
430408
verify_repository: { get () { return this.verifyRepository } }
431409
})

api/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const deleteScriptApi = require('./api/delete_script')
3333
const existsApi = require('./api/exists')
3434
const existsSourceApi = require('./api/exists_source')
3535
const explainApi = require('./api/explain')
36+
const FeaturesApi = require('./api/features')
3637
const fieldCapsApi = require('./api/field_caps')
3738
const getApi = require('./api/get')
3839
const getScriptApi = require('./api/get_script')
@@ -94,6 +95,7 @@ const { kConfigurationError } = require('./utils')
9495
const kCat = Symbol('Cat')
9596
const kCluster = Symbol('Cluster')
9697
const kDanglingIndices = Symbol('DanglingIndices')
98+
const kFeatures = Symbol('Features')
9799
const kIndices = Symbol('Indices')
98100
const kIngest = Symbol('Ingest')
99101
const kNodes = Symbol('Nodes')
@@ -127,6 +129,7 @@ function ESAPI (opts) {
127129
this[kCat] = null
128130
this[kCluster] = null
129131
this[kDanglingIndices] = null
132+
this[kFeatures] = null
130133
this[kIndices] = null
131134
this[kIngest] = null
132135
this[kNodes] = null
@@ -228,6 +231,14 @@ Object.defineProperties(ESAPI.prototype, {
228231
delete_by_query_rethrottle: { get () { return this.deleteByQueryRethrottle } },
229232
delete_script: { get () { return this.deleteScript } },
230233
exists_source: { get () { return this.existsSource } },
234+
features: {
235+
get () {
236+
if (this[kFeatures] === null) {
237+
this[kFeatures] = new FeaturesApi(this.transport, this[kConfigurationError])
238+
}
239+
return this[kFeatures]
240+
}
241+
},
231242
field_caps: { get () { return this.fieldCaps } },
232243
get_script: { get () { return this.getScript } },
233244
get_script_context: { get () { return this.getScriptContext } },

api/kibana.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ interface KibanaClient {
176176
exists<TResponse = boolean, TContext = Context>(params?: RequestParams.Exists, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
177177
existsSource<TResponse = boolean, TContext = Context>(params?: RequestParams.ExistsSource, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
178178
explain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.Explain<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
179+
features: {
180+
getFeatures<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.FeaturesGetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
181+
resetFeatures<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.FeaturesResetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
182+
}
179183
fieldCaps<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.FieldCaps<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
180184
get<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.Get, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
181185
getScript<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.GetScript, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
@@ -318,6 +322,7 @@ interface KibanaClient {
318322
openJob<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.MlOpenJob, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
319323
postCalendarEvents<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlPostCalendarEvents<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
320324
postData<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlPostData<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
325+
previewDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlPreviewDataFrameAnalytics<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
321326
previewDatafeed<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.MlPreviewDatafeed, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
322327
putCalendar<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlPutCalendar<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
323328
putCalendarJob<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.MlPutCalendarJob, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
@@ -433,7 +438,6 @@ interface KibanaClient {
433438
delete<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotDelete, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
434439
deleteRepository<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotDeleteRepository, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
435440
get<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotGet, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
436-
getFeatures<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotGetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
437441
getRepository<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotGetRepository, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
438442
restore<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotRestore<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
439443
status<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotStatus, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>

api/requestParams.d.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ export interface CatNodes extends Generic {
278278
s?: string | string[];
279279
time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos';
280280
v?: boolean;
281+
include_unloaded_segments?: boolean;
281282
}
282283

283284
export interface CatPendingTasks extends Generic {
@@ -792,6 +793,13 @@ export interface Explain<T = RequestBody> extends Generic {
792793
body?: T;
793794
}
794795

796+
export interface FeaturesGetFeatures extends Generic {
797+
master_timeout?: string;
798+
}
799+
800+
export interface FeaturesResetFeatures extends Generic {
801+
}
802+
795803
export interface FieldCaps<T = RequestBody> extends Generic {
796804
index?: string | string[];
797805
fields?: string | string[];
@@ -1356,6 +1364,7 @@ export interface IngestDeletePipeline extends Generic {
13561364

13571365
export interface IngestGetPipeline extends Generic {
13581366
id?: string;
1367+
summary?: boolean;
13591368
master_timeout?: string;
13601369
}
13611370

@@ -1714,6 +1723,11 @@ export interface MlPostData<T = RequestBody> extends Generic {
17141723
body: T;
17151724
}
17161725

1726+
export interface MlPreviewDataFrameAnalytics<T = RequestBody> extends Generic {
1727+
id?: string;
1728+
body?: T;
1729+
}
1730+
17171731
export interface MlPreviewDatafeed extends Generic {
17181732
datafeed_id: string;
17191733
}
@@ -1933,6 +1947,7 @@ export interface NodesStats extends Generic {
19331947
types?: string | string[];
19341948
timeout?: string;
19351949
include_segment_file_sizes?: boolean;
1950+
include_unloaded_segments?: boolean;
19361951
}
19371952

19381953
export interface NodesUsage extends Generic {
@@ -2367,10 +2382,6 @@ export interface SnapshotGet extends Generic {
23672382
verbose?: boolean;
23682383
}
23692384

2370-
export interface SnapshotGetFeatures extends Generic {
2371-
master_timeout?: string;
2372-
}
2373-
23742385
export interface SnapshotGetRepository extends Generic {
23752386
repository?: string | string[];
23762387
master_timeout?: string;

0 commit comments

Comments
 (0)