Skip to content

Commit 349b832

Browse files
authored
Support for deprecated paths (#828)
* Updated code generation * API generation * Updated test
1 parent 928746d commit 349b832

31 files changed

+232
-42
lines changed

api/api/clear_scroll.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ function buildClearScroll (opts) {
7878

7979
var path = ''
8080

81-
path = '/' + '_search' + '/' + 'scroll'
81+
if ((scroll_id || scrollId) != null) {
82+
path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId)
83+
} else {
84+
path = '/' + '_search' + '/' + 'scroll'
85+
}
8286

8387
// build request object
8488
const request = {

api/api/count.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ function buildCount (opts) {
9494
options = {}
9595
}
9696

97+
// check required url components
98+
if (params['type'] != null && (params['index'] == null)) {
99+
const err = new ConfigurationError('Missing required parameter of the url: index')
100+
return handleError(err, callback)
101+
}
102+
97103
// validate headers object
98104
if (options.headers != null && typeof options.headers !== 'object') {
99105
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
@@ -115,7 +121,9 @@ function buildCount (opts) {
115121

116122
var path = ''
117123

118-
if ((index) != null) {
124+
if ((index) != null && (type) != null) {
125+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_count'
126+
} else if ((index) != null) {
119127
path = '/' + encodeURIComponent(index) + '/' + '_count'
120128
} else {
121129
path = '/' + '_count'

api/api/create.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ function buildCreate (opts) {
112112

113113
var path = ''
114114

115-
path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id)
115+
if ((index) != null && (type) != null && (id) != null) {
116+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create'
117+
} else {
118+
path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id)
119+
}
116120

117121
// build request object
118122
const request = {

api/api/delete.js

Lines changed: 5 additions & 7 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}`)
@@ -121,7 +115,11 @@ function buildDelete (opts) {
121115

122116
var path = ''
123117

124-
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
118+
if ((index) != null && (type) != null && (id) != null) {
119+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
120+
} else {
121+
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
122+
}
125123

126124
// build request object
127125
const request = {

api/api/delete_by_query.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ function buildDeleteByQuery (opts) {
147147
return handleError(err, callback)
148148
}
149149

150+
// check required url components
151+
if (params['type'] != null && (params['index'] == null)) {
152+
const err = new ConfigurationError('Missing required parameter of the url: index')
153+
return handleError(err, callback)
154+
}
155+
150156
// validate headers object
151157
if (options.headers != null && typeof options.headers !== 'object') {
152158
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
@@ -168,7 +174,11 @@ function buildDeleteByQuery (opts) {
168174

169175
var path = ''
170176

171-
path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query'
177+
if ((index) != null && (type) != null) {
178+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_delete_by_query'
179+
} else {
180+
path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query'
181+
}
172182

173183
// build request object
174184
const request = {

api/api/exists.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ function buildExists (opts) {
119119

120120
var path = ''
121121

122-
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
122+
if ((index) != null && (type) != null && (id) != null) {
123+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
124+
} else {
125+
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
126+
}
123127

124128
// build request object
125129
const request = {

api/api/exists_source.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ function buildExistsSource (opts) {
9696
}
9797

9898
// check required url components
99-
if (params['id'] != null && (params['index'] == null)) {
99+
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
100+
const err = new ConfigurationError('Missing required parameter of the url: type, index')
101+
return handleError(err, callback)
102+
} else if (params['type'] != null && (params['index'] == null)) {
100103
const err = new ConfigurationError('Missing required parameter of the url: index')
101104
return handleError(err, callback)
102105
}
@@ -122,7 +125,11 @@ function buildExistsSource (opts) {
122125

123126
var path = ''
124127

125-
path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id)
128+
if ((index) != null && (type) != null && (id) != null) {
129+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
130+
} else {
131+
path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id)
132+
}
126133

127134
// build request object
128135
const request = {

api/api/explain.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ function buildExplain (opts) {
121121

122122
var path = ''
123123

124-
path = '/' + encodeURIComponent(index) + '/' + '_explain' + '/' + encodeURIComponent(id)
124+
if ((index) != null && (type) != null && (id) != null) {
125+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_explain'
126+
} else {
127+
path = '/' + encodeURIComponent(index) + '/' + '_explain' + '/' + encodeURIComponent(id)
128+
}
125129

126130
// build request object
127131
const request = {

api/api/get.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ function buildGet (opts) {
119119

120120
var path = ''
121121

122-
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
122+
if ((index) != null && (type) != null && (id) != null) {
123+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
124+
} else {
125+
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
126+
}
123127

124128
// build request object
125129
const request = {

api/api/get_source.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ function buildGetSource (opts) {
116116

117117
var path = ''
118118

119-
path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id)
119+
if ((index) != null && (type) != null && (id) != null) {
120+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
121+
} else {
122+
path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id)
123+
}
120124

121125
// build request object
122126
const request = {

0 commit comments

Comments
 (0)