Skip to content

Commit 14d6401

Browse files
committed
API generation
1 parent f6677c0 commit 14d6401

10 files changed

+3223
-1
lines changed

api/RequestTypes.d.ts

Lines changed: 2569 additions & 0 deletions
Large diffs are not rendered by default.

api/ResponseTypes.d.ts

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
interface SearchResponse<TSource = unknown, TAggregations = unknown> {
6+
took: number
7+
timed_out: boolean
8+
_scroll_id?: string
9+
_shards: Shards
10+
hits: {
11+
total: {
12+
value: number
13+
relation: string
14+
}
15+
max_score: number
16+
hits: Array<{
17+
_index: string
18+
_type: string
19+
_id: string
20+
_score: number
21+
_source: TSource
22+
_version?: number
23+
_explanation?: Explanation
24+
fields?: Record<string, unknown>
25+
highlight?: Record<string, string[]>
26+
inner_hits?: Record<string, unknown>
27+
matched_queries?: string[]
28+
sort?: any[]
29+
}>
30+
}
31+
aggregations?: TAggregations
32+
}
33+
34+
interface Shards {
35+
total: number
36+
successful: number
37+
failed: number
38+
skipped: number
39+
}
40+
41+
interface Explanation {
42+
value: number
43+
description: string
44+
details: Explanation[]
45+
}
46+
47+
interface MSearchResponse<TSource = unknown, TAggregations = unknown> {
48+
responses: Array<SearchResponse<TSource, TAggregations>>
49+
}
50+
51+
interface CreateResponse {
52+
_shards: Shards
53+
_index: string
54+
_type: string
55+
_id: string
56+
_version: number
57+
_seq_no: number
58+
_primary_term: number
59+
result: string
60+
}
61+
62+
interface IndexResponse extends CreateResponse {}
63+
64+
interface DeleteResponse {
65+
_shards: Shards
66+
_index: string
67+
_type: string
68+
_id: string
69+
_version: number
70+
_seq_no: number
71+
_primary_term: number
72+
result: string
73+
}
74+
75+
interface UpdateResponse {
76+
_shards: Shards
77+
_index: string
78+
_type: string
79+
_id: string
80+
_version: number
81+
result: string
82+
}
83+
84+
interface GetResponse<TSource = unknown> {
85+
_index: string
86+
_type: string
87+
_id: string
88+
_version: number
89+
_seq_no: number
90+
_primary_term: number
91+
found: boolean
92+
_source: TSource
93+
}
94+
95+
interface BulkResponse {
96+
took: number
97+
errors: boolean
98+
items: BulkItem[]
99+
}
100+
101+
type BulkItem =
102+
| { index: BulkIndex }
103+
| { create: BulkCreate }
104+
| { update: BulkUpdate }
105+
| { delete: BulkDelete }
106+
107+
interface BulkIndex extends IndexResponse {
108+
status: number
109+
}
110+
111+
interface BulkCreate extends CreateResponse {
112+
status: number
113+
}
114+
115+
interface BulkUpdate extends UpdateResponse {
116+
status: number
117+
}
118+
119+
interface BulkDelete extends DeleteResponse {
120+
status: number
121+
}
122+
123+
export {
124+
SearchResponse,
125+
MSearchResponse,
126+
CreateResponse,
127+
IndexResponse,
128+
DeleteResponse,
129+
UpdateResponse,
130+
GetResponse,
131+
BulkResponse
132+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
'use strict'
6+
7+
/* eslint camelcase: 0 */
8+
/* eslint no-unused-vars: 0 */
9+
10+
function buildClusterExistsComponentTemplate (opts) {
11+
// eslint-disable-next-line no-unused-vars
12+
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
13+
14+
const acceptedQuerystring = [
15+
'master_timeout',
16+
'local',
17+
'pretty',
18+
'human',
19+
'error_trace',
20+
'source',
21+
'filter_path'
22+
]
23+
24+
const snakeCase = {
25+
masterTimeout: 'master_timeout',
26+
errorTrace: 'error_trace',
27+
filterPath: 'filter_path'
28+
}
29+
30+
/**
31+
* Perform a cluster.exists_component_template request
32+
* Returns information about whether a particular component template exist
33+
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
34+
*/
35+
return function clusterExistsComponentTemplate (params, options, callback) {
36+
options = options || {}
37+
if (typeof options === 'function') {
38+
callback = options
39+
options = {}
40+
}
41+
if (typeof params === 'function' || params == null) {
42+
callback = params
43+
params = {}
44+
options = {}
45+
}
46+
47+
// check required parameters
48+
if (params['name'] == null) {
49+
const err = new ConfigurationError('Missing required parameter: name')
50+
return handleError(err, callback)
51+
}
52+
53+
// validate headers object
54+
if (options.headers != null && typeof options.headers !== 'object') {
55+
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
56+
return handleError(err, callback)
57+
}
58+
59+
var warnings = []
60+
var { method, body, name, ...querystring } = params
61+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
62+
63+
var ignore = options.ignore
64+
if (typeof ignore === 'number') {
65+
options.ignore = [ignore]
66+
}
67+
68+
var path = ''
69+
70+
if (method == null) method = 'HEAD'
71+
path = '/' + '_component_template' + '/' + encodeURIComponent(name)
72+
73+
// build request object
74+
const request = {
75+
method,
76+
path,
77+
body: null,
78+
querystring
79+
}
80+
81+
options.warnings = warnings.length === 0 ? null : warnings
82+
return makeRequest(request, options, callback)
83+
}
84+
}
85+
86+
module.exports = buildClusterExistsComponentTemplate
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
'use strict'
6+
7+
/* eslint camelcase: 0 */
8+
/* eslint no-unused-vars: 0 */
9+
10+
function buildSearchableSnapshotsClearCache (opts) {
11+
// eslint-disable-next-line no-unused-vars
12+
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
13+
14+
const acceptedQuerystring = [
15+
'ignore_unavailable',
16+
'allow_no_indices',
17+
'expand_wildcards',
18+
'index'
19+
]
20+
21+
const snakeCase = {
22+
ignoreUnavailable: 'ignore_unavailable',
23+
allowNoIndices: 'allow_no_indices',
24+
expandWildcards: 'expand_wildcards'
25+
26+
}
27+
28+
/**
29+
* Perform a searchable_snapshots.clear_cache request
30+
* https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-clear-cache.html
31+
*/
32+
return function searchableSnapshotsClearCache (params, options, callback) {
33+
options = options || {}
34+
if (typeof options === 'function') {
35+
callback = options
36+
options = {}
37+
}
38+
if (typeof params === 'function' || params == null) {
39+
callback = params
40+
params = {}
41+
options = {}
42+
}
43+
44+
// validate headers object
45+
if (options.headers != null && typeof options.headers !== 'object') {
46+
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
47+
return handleError(err, callback)
48+
}
49+
50+
var warnings = []
51+
var { method, body, index, ...querystring } = params
52+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
53+
54+
var ignore = options.ignore
55+
if (typeof ignore === 'number') {
56+
options.ignore = [ignore]
57+
}
58+
59+
var path = ''
60+
61+
if ((index) != null) {
62+
if (method == null) method = 'POST'
63+
path = '/' + encodeURIComponent(index) + '/' + '_searchable_snapshots' + '/' + 'cache' + '/' + 'clear'
64+
} else {
65+
if (method == null) method = 'POST'
66+
path = '/' + '_searchable_snapshots' + '/' + 'cache' + '/' + 'clear'
67+
}
68+
69+
// build request object
70+
const request = {
71+
method,
72+
path,
73+
body: body || '',
74+
querystring
75+
}
76+
77+
options.warnings = warnings.length === 0 ? null : warnings
78+
return makeRequest(request, options, callback)
79+
}
80+
}
81+
82+
module.exports = buildSearchableSnapshotsClearCache

api/api/searchable_snapshots.mount.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
'use strict'
6+
7+
/* eslint camelcase: 0 */
8+
/* eslint no-unused-vars: 0 */
9+
10+
function buildSearchableSnapshotsMount (opts) {
11+
// eslint-disable-next-line no-unused-vars
12+
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
13+
14+
const acceptedQuerystring = [
15+
'master_timeout',
16+
'wait_for_completion'
17+
]
18+
19+
const snakeCase = {
20+
masterTimeout: 'master_timeout',
21+
waitForCompletion: 'wait_for_completion'
22+
}
23+
24+
/**
25+
* Perform a searchable_snapshots.mount request
26+
* https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-mount-snapshot
27+
*/
28+
return function searchableSnapshotsMount (params, options, callback) {
29+
options = options || {}
30+
if (typeof options === 'function') {
31+
callback = options
32+
options = {}
33+
}
34+
if (typeof params === 'function' || params == null) {
35+
callback = params
36+
params = {}
37+
options = {}
38+
}
39+
40+
// check required parameters
41+
if (params['repository'] == null) {
42+
const err = new ConfigurationError('Missing required parameter: repository')
43+
return handleError(err, callback)
44+
}
45+
if (params['snapshot'] == null) {
46+
const err = new ConfigurationError('Missing required parameter: snapshot')
47+
return handleError(err, callback)
48+
}
49+
if (params['body'] == null) {
50+
const err = new ConfigurationError('Missing required parameter: body')
51+
return handleError(err, callback)
52+
}
53+
54+
// check required url components
55+
if (params['snapshot'] != null && (params['repository'] == null)) {
56+
const err = new ConfigurationError('Missing required parameter of the url: repository')
57+
return handleError(err, callback)
58+
}
59+
60+
// validate headers object
61+
if (options.headers != null && typeof options.headers !== 'object') {
62+
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
63+
return handleError(err, callback)
64+
}
65+
66+
var warnings = []
67+
var { method, body, repository, snapshot, ...querystring } = params
68+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
69+
70+
var ignore = options.ignore
71+
if (typeof ignore === 'number') {
72+
options.ignore = [ignore]
73+
}
74+
75+
var path = ''
76+
77+
if (method == null) method = 'POST'
78+
path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_mount'
79+
80+
// build request object
81+
const request = {
82+
method,
83+
path,
84+
body: body || '',
85+
querystring
86+
}
87+
88+
options.warnings = warnings.length === 0 ? null : warnings
89+
return makeRequest(request, options, callback)
90+
}
91+
}
92+
93+
module.exports = buildSearchableSnapshotsMount

0 commit comments

Comments
 (0)