Skip to content

Commit 30c3afe

Browse files
committed
API generation
1 parent 0efa0df commit 30c3afe

File tree

11 files changed

+116
-53
lines changed

11 files changed

+116
-53
lines changed

api/api/delete_by_query.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function buildDeleteByQuery (opts) {
2929
* Perform a [delete_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html) request
3030
*
3131
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
32+
* @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
3233
* @param {string} analyzer - The analyzer to use for the query string
3334
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
3435
* @param {enum} default_operator - The default operator for query string query (AND or OR)
@@ -150,14 +151,20 @@ function buildDeleteByQuery (opts) {
150151
return handleError(err, callback)
151152
}
152153

154+
// check required url components
155+
if (params['type'] != null && (params['index'] == null)) {
156+
const err = new ConfigurationError('Missing required parameter of the url: index')
157+
return handleError(err, callback)
158+
}
159+
153160
// validate headers object
154161
if (options.headers != null && typeof options.headers !== 'object') {
155162
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
156163
return handleError(err, callback)
157164
}
158165

159166
var warnings = []
160-
var { method, body, index, ...querystring } = params
167+
var { method, body, index, type, ...querystring } = params
161168
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
162169

163170
if (method == null) {
@@ -171,7 +178,11 @@ function buildDeleteByQuery (opts) {
171178

172179
var path = ''
173180

174-
path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query'
181+
if ((index) != null && (type) != null) {
182+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_delete_by_query'
183+
} else {
184+
path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query'
185+
}
175186

176187
// build request object
177188
const request = {

api/api/get.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ function buildGet (opts) {
5757
'_source_excludes',
5858
'_source_exclude',
5959
'_source_includes',
60-
<<<<<<< HEAD
60+
'_source_include',
6161
'_source_exclude',
62-
=======
63-
>>>>>>> 844206e... Patch deprecated parameters (#851)
6462
'_source_include',
6563
'version',
6664
'version_type',
@@ -76,10 +74,8 @@ function buildGet (opts) {
7674
_sourceExcludes: '_source_excludes',
7775
_sourceExclude: '_source_exclude',
7876
_sourceIncludes: '_source_includes',
79-
<<<<<<< HEAD
77+
_sourceInclude: '_source_include',
8078
_sourceExclude: '_source_exclude',
81-
=======
82-
>>>>>>> 844206e... Patch deprecated parameters (#851)
8379
_sourceInclude: '_source_include',
8480
versionType: 'version_type',
8581
errorTrace: 'error_trace',

api/api/msearch.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function buildMsearch (opts) {
2929
* Perform a [msearch](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html) request
3030
*
3131
* @param {list} index - A comma-separated list of index names to use as default
32+
* @param {list} type - A comma-separated list of document types to use as default
3233
* @param {enum} search_type - Search operation type
3334
* @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute
3435
* @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response
@@ -81,14 +82,20 @@ function buildMsearch (opts) {
8182
return handleError(err, callback)
8283
}
8384

85+
// check required url components
86+
if (params['type'] != null && (params['index'] == null)) {
87+
const err = new ConfigurationError('Missing required parameter of the url: index')
88+
return handleError(err, callback)
89+
}
90+
8491
// validate headers object
8592
if (options.headers != null && typeof options.headers !== 'object') {
8693
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
8794
return handleError(err, callback)
8895
}
8996

9097
var warnings = []
91-
var { method, body, index, ...querystring } = params
98+
var { method, body, index, type, ...querystring } = params
9299
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
93100

94101
if (method == null) {
@@ -102,7 +109,9 @@ function buildMsearch (opts) {
102109

103110
var path = ''
104111

105-
if ((index) != null) {
112+
if ((index) != null && (type) != null) {
113+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch'
114+
} else if ((index) != null) {
106115
path = '/' + encodeURIComponent(index) + '/' + '_msearch'
107116
} else {
108117
path = '/' + '_msearch'

api/api/msearch_template.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function buildMsearchTemplate (opts) {
2929
* Perform a [msearch_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) request
3030
*
3131
* @param {list} index - A comma-separated list of index names to use as default
32+
* @param {list} type - A comma-separated list of document types to use as default
3233
* @param {enum} search_type - Search operation type
3334
* @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response
3435
* @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute
@@ -75,14 +76,20 @@ function buildMsearchTemplate (opts) {
7576
return handleError(err, callback)
7677
}
7778

79+
// check required url components
80+
if (params['type'] != null && (params['index'] == null)) {
81+
const err = new ConfigurationError('Missing required parameter of the url: index')
82+
return handleError(err, callback)
83+
}
84+
7885
// validate headers object
7986
if (options.headers != null && typeof options.headers !== 'object') {
8087
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
8188
return handleError(err, callback)
8289
}
8390

8491
var warnings = []
85-
var { method, body, index, ...querystring } = params
92+
var { method, body, index, type, ...querystring } = params
8693
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
8794

8895
if (method == null) {
@@ -96,7 +103,9 @@ function buildMsearchTemplate (opts) {
96103

97104
var path = ''
98105

99-
if ((index) != null) {
106+
if ((index) != null && (type) != null) {
107+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' + '/' + 'template'
108+
} else if ((index) != null) {
100109
path = '/' + encodeURIComponent(index) + '/' + '_msearch' + '/' + 'template'
101110
} else {
102111
path = '/' + '_msearch' + '/' + 'template'

api/api/mtermvectors.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function buildMtermvectors (opts) {
2929
* Perform a [mtermvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html) request
3030
*
3131
* @param {string} index - The index in which the document resides.
32+
* @param {string} type - The type of the document.
3233
* @param {list} ids - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body
3334
* @param {boolean} term_statistics - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
3435
* @param {boolean} field_statistics - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
@@ -86,14 +87,20 @@ function buildMtermvectors (opts) {
8687
options = {}
8788
}
8889

90+
// check required url components
91+
if (params['type'] != null && (params['index'] == null)) {
92+
const err = new ConfigurationError('Missing required parameter of the url: index')
93+
return handleError(err, callback)
94+
}
95+
8996
// validate headers object
9097
if (options.headers != null && typeof options.headers !== 'object') {
9198
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
9299
return handleError(err, callback)
93100
}
94101

95102
var warnings = []
96-
var { method, body, index, ...querystring } = params
103+
var { method, body, index, type, ...querystring } = params
97104
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
98105

99106
if (method == null) {
@@ -107,7 +114,9 @@ function buildMtermvectors (opts) {
107114

108115
var path = ''
109116

110-
if ((index) != null) {
117+
if ((index) != null && (type) != null) {
118+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mtermvectors'
119+
} else if ((index) != null) {
111120
path = '/' + encodeURIComponent(index) + '/' + '_mtermvectors'
112121
} else {
113122
path = '/' + '_mtermvectors'

api/api/search.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function buildSearch (opts) {
2929
* Perform a [search](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html) request
3030
*
3131
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
32+
* @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
3233
* @param {string} analyzer - The analyzer to use for the query string
3334
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
3435
* @param {enum} default_operator - The default operator for query string query (AND or OR)
@@ -169,14 +170,20 @@ function buildSearch (opts) {
169170
options = {}
170171
}
171172

173+
// check required url components
174+
if (params['type'] != null && (params['index'] == null)) {
175+
const err = new ConfigurationError('Missing required parameter of the url: index')
176+
return handleError(err, callback)
177+
}
178+
172179
// validate headers object
173180
if (options.headers != null && typeof options.headers !== 'object') {
174181
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
175182
return handleError(err, callback)
176183
}
177184

178185
var warnings = []
179-
var { method, body, index, ...querystring } = params
186+
var { method, body, index, type, ...querystring } = params
180187
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
181188

182189
if (method == null) {
@@ -190,7 +197,9 @@ function buildSearch (opts) {
190197

191198
var path = ''
192199

193-
if ((index) != null) {
200+
if ((index) != null && (type) != null) {
201+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search'
202+
} else if ((index) != null) {
194203
path = '/' + encodeURIComponent(index) + '/' + '_search'
195204
} else {
196205
path = '/' + '_search'

api/api/search_template.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function buildSearchTemplate (opts) {
2929
* Perform a [search_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request
3030
*
3131
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
32+
* @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
3233
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
3334
* @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled
3435
* @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
@@ -94,14 +95,20 @@ function buildSearchTemplate (opts) {
9495
return handleError(err, callback)
9596
}
9697

98+
// check required url components
99+
if (params['type'] != null && (params['index'] == null)) {
100+
const err = new ConfigurationError('Missing required parameter of the url: index')
101+
return handleError(err, callback)
102+
}
103+
97104
// validate headers object
98105
if (options.headers != null && typeof options.headers !== 'object') {
99106
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
100107
return handleError(err, callback)
101108
}
102109

103110
var warnings = []
104-
var { method, body, index, ...querystring } = params
111+
var { method, body, index, type, ...querystring } = params
105112
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
106113

107114
if (method == null) {
@@ -115,7 +122,9 @@ function buildSearchTemplate (opts) {
115122

116123
var path = ''
117124

118-
if ((index) != null) {
125+
if ((index) != null && (type) != null) {
126+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + '/' + 'template'
127+
} else if ((index) != null) {
119128
path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template'
120129
} else {
121130
path = '/' + '_search' + '/' + 'template'

api/api/termvectors.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function buildTermvectors (opts) {
2929
* Perform a [termvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html) request
3030
*
3131
* @param {string} index - The index in which the document resides.
32+
* @param {string} type - The type of the document.
3233
* @param {string} id - The id of the document, when not specified a doc param should be supplied.
3334
* @param {boolean} term_statistics - Specifies if total term frequency and document frequency should be returned.
3435
* @param {boolean} field_statistics - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.
@@ -102,7 +103,7 @@ function buildTermvectors (opts) {
102103
}
103104

104105
var warnings = []
105-
var { method, body, index, id, ...querystring } = params
106+
var { method, body, index, type, id, ...querystring } = params
106107
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
107108

108109
if (method == null) {
@@ -116,13 +117,8 @@ function buildTermvectors (opts) {
116117

117118
var path = ''
118119

119-
<<<<<<< HEAD
120120
if ((index) != null && (type) != null && (id) != null) {
121121
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_termvectors'
122-
=======
123-
if ((index) != null && (id) != null) {
124-
path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id)
125-
>>>>>>> 844206e... Patch deprecated parameters (#851)
126122
} else {
127123
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_termvectors'
128124
}

api/api/update_by_query.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function buildUpdateByQuery (opts) {
2929
* Perform a [update_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html) request
3030
*
3131
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
32+
* @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
3233
* @param {string} analyzer - The analyzer to use for the query string
3334
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
3435
* @param {enum} default_operator - The default operator for query string query (AND or OR)
@@ -151,14 +152,20 @@ function buildUpdateByQuery (opts) {
151152
return handleError(err, callback)
152153
}
153154

155+
// check required url components
156+
if (params['type'] != null && (params['index'] == null)) {
157+
const err = new ConfigurationError('Missing required parameter of the url: index')
158+
return handleError(err, callback)
159+
}
160+
154161
// validate headers object
155162
if (options.headers != null && typeof options.headers !== 'object') {
156163
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
157164
return handleError(err, callback)
158165
}
159166

160167
var warnings = []
161-
var { method, body, index, ...querystring } = params
168+
var { method, body, index, type, ...querystring } = params
162169
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
163170

164171
if (method == null) {
@@ -172,7 +179,11 @@ function buildUpdateByQuery (opts) {
172179

173180
var path = ''
174181

175-
path = '/' + encodeURIComponent(index) + '/' + '_update_by_query'
182+
if ((index) != null && (type) != null) {
183+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_update_by_query'
184+
} else {
185+
path = '/' + encodeURIComponent(index) + '/' + '_update_by_query'
186+
}
176187

177188
// build request object
178189
const request = {

0 commit comments

Comments
 (0)