Skip to content

Commit 12e88d6

Browse files
committed
Support for deprecated paths (#828)
* Updated code generation * API generation * Updated test
1 parent dbfeb5d commit 12e88d6

File tree

6 files changed

+29
-13
lines changed

6 files changed

+29
-13
lines changed

api/api/delete.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ function buildDelete (opts) {
9494
return handleError(err, callback)
9595
}
9696

97-
// check required url components
98-
if (params['id'] != null && (params['index'] == null)) {
99-
const err = new ConfigurationError('Missing required parameter of the url: index')
100-
return handleError(err, callback)
101-
}
102-
10397
// validate headers object
10498
if (options.headers != null && typeof options.headers !== 'object') {
10599
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)

api/api/index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ function buildIndex (opts) {
9696
return handleError(err, callback)
9797
}
9898

99-
// check required url components
100-
if (params['id'] != null && (params['index'] == null)) {
101-
const err = new ConfigurationError('Missing required parameter of the url: index')
102-
return handleError(err, callback)
103-
}
104-
10599
// validate headers object
106100
if (options.headers != null && typeof options.headers !== 'object') {
107101
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)

api/api/indices.put_mapping.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,23 @@ function buildIndicesPutMapping (opts) {
111111
} else if ((index) != null && (type) != null) {
112112
path = '/' + encodeURIComponent(index) + '/' + '_mappings' + '/' + encodeURIComponent(type)
113113
} else if ((type) != null) {
114+
<<<<<<< HEAD
114115
path = '/' + '_mapping' + '/' + encodeURIComponent(type)
115116
} else if ((type) != null) {
116117
path = '/' + '_mappings' + '/' + encodeURIComponent(type)
117118
} else if ((index) != null) {
118119
path = '/' + encodeURIComponent(index) + '/' + '_mappings'
119120
} else {
120121
path = '/' + encodeURIComponent(index) + '/' + '_mapping'
122+
=======
123+
path = '/' + '_mappings' + '/' + encodeURIComponent(type)
124+
} else if ((type) != null) {
125+
path = '/' + '_mapping' + '/' + encodeURIComponent(type)
126+
} else if ((index) != null) {
127+
path = '/' + encodeURIComponent(index) + '/' + '_mapping'
128+
} else {
129+
path = '/' + encodeURIComponent(index) + '/' + '_mappings'
130+
>>>>>>> 349b832... Support for deprecated paths (#828)
121131
}
122132

123133
// build request object

api/api/nodes.hot_threads.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,14 @@ function buildNodesHotThreads (opts) {
101101
} else if ((node_id || nodeId) != null) {
102102
path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads'
103103
} else if ((node_id || nodeId) != null) {
104+
<<<<<<< HEAD
104105
path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hotthreads'
105106
} else if ((node_id || nodeId) != null) {
107+
=======
108+
>>>>>>> 349b832... Support for deprecated paths (#828)
106109
path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads'
110+
} else if ((node_id || nodeId) != null) {
111+
path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hotthreads'
107112
} else {
108113
path = '/' + '_cluster' + '/' + 'nodes' + '/' + 'hotthreads'
109114
}

scripts/utils/generateApis.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* under the License.
1818
*/
1919

20+
/* eslint camelcase: 0 */
21+
2022
'use strict'
2123

2224
const dedent = require('dedent')
@@ -33,13 +35,15 @@ const noPathValidation = [
3335
'explain',
3436
'get',
3537
'get_source',
38+
'index',
3639
'indices.get_alias',
3740
'indices.exists_alias',
3841
'indices.get_field_mapping',
3942
'indices.get_mapping',
4043
'indices.get_settings',
4144
'indices.put_mapping',
4245
'indices.stats',
46+
'delete',
4347
'nodes.info',
4448
'nodes.stats',
4549
'nodes.usage',
@@ -66,10 +70,16 @@ function generate (spec, common) {
6670
.replace(/_([a-z])/g, k => k[1].toUpperCase())
6771

6872
const methods = spec[api].methods
69-
const { paths, parts, params } = spec[api].url
73+
const { paths, deprecated_paths, parts, params } = spec[api].url
7074
const acceptedQuerystring = []
7175
const required = []
7276

77+
if (deprecated_paths) {
78+
for (const p of deprecated_paths) {
79+
paths.push(p.path)
80+
}
81+
}
82+
7383
for (const key in parts) {
7484
if (parts[key].required) {
7585
required.push(key)

test/integration/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const esFolder = join(__dirname, '..', '..', 'elasticsearch')
3434
const yamlFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'test')
3535
const xPackYamlFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resources', 'rest-api-spec', 'test')
3636
const customSkips = [
37+
// TODO: remove this once 'arbitrary_key' is implemented
38+
// https://github.com/elastic/elasticsearch/pull/41492
39+
'indices.split/30_copy_settings.yml',
3740
// skipping because we are booting ES with `discovery.type=single-node`
3841
// and this test will fail because of this configuration
3942
'nodes.stats/30_discovery.yml',

0 commit comments

Comments
 (0)