Skip to content

Commit c922661

Browse files
committed
API generation
1 parent 597dd28 commit c922661

11 files changed

+122
-22
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
@@ -84,14 +85,20 @@ function buildMsearch (opts) {
8485
return handleError(err, callback)
8586
}
8687

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

93100
var warnings = []
94-
var { method, body, index, ...querystring } = params
101+
var { method, body, index, type, ...querystring } = params
95102
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
96103

97104
if (method == null) {
@@ -105,7 +112,9 @@ function buildMsearch (opts) {
105112

106113
var path = ''
107114

108-
if ((index) != null) {
115+
if ((index) != null && (type) != null) {
116+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch'
117+
} else if ((index) != null) {
109118
path = '/' + encodeURIComponent(index) + '/' + '_msearch'
110119
} else {
111120
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
@@ -78,14 +79,20 @@ function buildMsearchTemplate (opts) {
7879
return handleError(err, callback)
7980
}
8081

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

8794
var warnings = []
88-
var { method, body, index, ...querystring } = params
95+
var { method, body, index, type, ...querystring } = params
8996
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
9097

9198
if (method == null) {
@@ -99,7 +106,9 @@ function buildMsearchTemplate (opts) {
99106

100107
var path = ''
101108

102-
if ((index) != null) {
109+
if ((index) != null && (type) != null) {
110+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' + '/' + 'template'
111+
} else if ((index) != null) {
103112
path = '/' + encodeURIComponent(index) + '/' + '_msearch' + '/' + 'template'
104113
} else {
105114
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 {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
@@ -172,14 +173,20 @@ function buildSearch (opts) {
172173
options = {}
173174
}
174175

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

181188
var warnings = []
182-
var { method, body, index, ...querystring } = params
189+
var { method, body, index, type, ...querystring } = params
183190
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
184191

185192
if (method == null) {
@@ -193,7 +200,9 @@ function buildSearch (opts) {
193200

194201
var path = ''
195202

196-
if ((index) != null) {
203+
if ((index) != null && (type) != null) {
204+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search'
205+
} else if ((index) != null) {
197206
path = '/' + encodeURIComponent(index) + '/' + '_search'
198207
} else {
199208
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)
@@ -97,14 +98,20 @@ function buildSearchTemplate (opts) {
9798
return handleError(err, callback)
9899
}
99100

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

106113
var warnings = []
107-
var { method, body, index, ...querystring } = params
114+
var { method, body, index, type, ...querystring } = params
108115
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
109116

110117
if (method == null) {
@@ -118,7 +125,9 @@ function buildSearchTemplate (opts) {
118125

119126
var path = ''
120127

121-
if ((index) != null) {
128+
if ((index) != null && (type) != null) {
129+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + '/' + 'template'
130+
} else if ((index) != null) {
122131
path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template'
123132
} else {
124133
path = '/' + '_search' + '/' + 'template'

api/api/termvectors.js

Lines changed: 7 additions & 2 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.
@@ -98,7 +99,7 @@ function buildTermvectors (opts) {
9899
}
99100

100101
var warnings = []
101-
var { method, body, index, id, ...querystring } = params
102+
var { method, body, index, type, id, ...querystring } = params
102103
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
103104

104105
if (method == null) {
@@ -112,8 +113,12 @@ function buildTermvectors (opts) {
112113

113114
var path = ''
114115

115-
if ((index) != null && (id) != null) {
116+
if ((index) != null && (type) != null && (id) != null) {
117+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_termvectors'
118+
} else if ((index) != null && (id) != null) {
116119
path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id)
120+
} else if ((index) != null && (type) != null) {
121+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_termvectors'
117122
} else {
118123
path = '/' + encodeURIComponent(index) + '/' + '_termvectors'
119124
}

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)