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 = {

api/api/graph.explore.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ function buildGraphExplore (opts) {
5656
options = {}
5757
}
5858

59+
// check required url components
60+
if (params['type'] != null && (params['index'] == null)) {
61+
const err = new ConfigurationError('Missing required parameter of the url: index')
62+
return handleError(err, callback)
63+
}
64+
5965
// validate headers object
6066
if (options.headers != null && typeof options.headers !== 'object') {
6167
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
@@ -77,7 +83,11 @@ function buildGraphExplore (opts) {
7783

7884
var path = ''
7985

80-
path = '/' + encodeURIComponent(index) + '/' + '_graph' + '/' + 'explore'
86+
if ((index) != null && (type) != null) {
87+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_graph' + '/' + 'explore'
88+
} else {
89+
path = '/' + encodeURIComponent(index) + '/' + '_graph' + '/' + 'explore'
90+
}
8191

8292
// build request object
8393
const request = {

api/api/index.js

Lines changed: 5 additions & 7 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}`)
@@ -123,8 +117,12 @@ function buildIndex (opts) {
123117

124118
var path = ''
125119

126-
if ((index) != null && (id) != null) {
120+
if ((index) != null && (type) != null && (id) != null) {
121+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
122+
} else if ((index) != null && (id) != null) {
127123
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
124+
} else if ((index) != null && (type) != null) {
125+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type)
128126
} else {
129127
path = '/' + encodeURIComponent(index) + '/' + '_doc'
130128
}

api/api/indices.get_field_mapping.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,12 @@ function buildIndicesGetFieldMapping (opts) {
106106

107107
var path = ''
108108

109-
if ((index) != null && (fields) != null) {
109+
if ((index) != null && (type) != null && (fields) != null) {
110+
path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type) + '/' + 'field' + '/' + encodeURIComponent(fields)
111+
} else if ((index) != null && (fields) != null) {
110112
path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields)
113+
} else if ((type) != null && (fields) != null) {
114+
path = '/' + '_mapping' + '/' + encodeURIComponent(type) + '/' + 'field' + '/' + encodeURIComponent(fields)
111115
} else {
112116
path = '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields)
113117
}

api/api/indices.get_mapping.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ function buildIndicesGetMapping (opts) {
101101

102102
var path = ''
103103

104-
if ((index) != null) {
104+
if ((index) != null && (type) != null) {
105+
path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type)
106+
} else if ((index) != null) {
105107
path = '/' + encodeURIComponent(index) + '/' + '_mapping'
108+
} else if ((type) != null) {
109+
path = '/' + '_mapping' + '/' + encodeURIComponent(type)
106110
} else {
107111
path = '/' + '_mapping'
108112
}

api/api/indices.put_mapping.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,23 @@ function buildIndicesPutMapping (opts) {
102102

103103
var path = ''
104104

105-
path = '/' + encodeURIComponent(index) + '/' + '_mapping'
105+
if ((index) != null && (type) != null) {
106+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mapping'
107+
} else if ((index) != null && (type) != null) {
108+
path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type)
109+
} else if ((index) != null && (type) != null) {
110+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mappings'
111+
} else if ((index) != null && (type) != null) {
112+
path = '/' + encodeURIComponent(index) + '/' + '_mappings' + '/' + encodeURIComponent(type)
113+
} else if ((type) != null) {
114+
path = '/' + '_mappings' + '/' + encodeURIComponent(type)
115+
} else if ((type) != null) {
116+
path = '/' + '_mapping' + '/' + encodeURIComponent(type)
117+
} else if ((index) != null) {
118+
path = '/' + encodeURIComponent(index) + '/' + '_mapping'
119+
} else {
120+
path = '/' + encodeURIComponent(index) + '/' + '_mappings'
121+
}
106122

107123
// build request object
108124
const request = {

api/api/indices.validate_query.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ function buildIndicesValidateQuery (opts) {
8888
options = {}
8989
}
9090

91+
// check required url components
92+
if (params['type'] != null && (params['index'] == null)) {
93+
const err = new ConfigurationError('Missing required parameter of the url: index')
94+
return handleError(err, callback)
95+
}
96+
9197
// validate headers object
9298
if (options.headers != null && typeof options.headers !== 'object') {
9399
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
@@ -109,7 +115,9 @@ function buildIndicesValidateQuery (opts) {
109115

110116
var path = ''
111117

112-
if ((index) != null) {
118+
if ((index) != null && (type) != null) {
119+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_validate' + '/' + 'query'
120+
} else if ((index) != null) {
113121
path = '/' + encodeURIComponent(index) + '/' + '_validate' + '/' + 'query'
114122
} else {
115123
path = '/' + '_validate' + '/' + 'query'

api/api/mget.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ function buildMget (opts) {
8383
return handleError(err, callback)
8484
}
8585

86+
// check required url components
87+
if (params['type'] != null && (params['index'] == null)) {
88+
const err = new ConfigurationError('Missing required parameter of the url: index')
89+
return handleError(err, callback)
90+
}
91+
8692
// validate headers object
8793
if (options.headers != null && typeof options.headers !== 'object') {
8894
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
@@ -104,7 +110,9 @@ function buildMget (opts) {
104110

105111
var path = ''
106112

107-
if ((index) != null) {
113+
if ((index) != null && (type) != null) {
114+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mget'
115+
} else if ((index) != null) {
108116
path = '/' + encodeURIComponent(index) + '/' + '_mget'
109117
} else {
110118
path = '/' + '_mget'

api/api/monitoring.bulk.js

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

8787
var path = ''
8888

89-
path = '/' + '_monitoring' + '/' + 'bulk'
89+
if ((type) != null) {
90+
path = '/' + '_monitoring' + '/' + encodeURIComponent(type) + '/' + 'bulk'
91+
} else {
92+
path = '/' + '_monitoring' + '/' + 'bulk'
93+
}
9094

9195
// build request object
9296
const request = {

api/api/msearch.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ function buildMsearch (opts) {
8585
return handleError(err, callback)
8686
}
8787

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+
8894
// validate headers object
8995
if (options.headers != null && typeof options.headers !== 'object') {
9096
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
@@ -106,7 +112,9 @@ function buildMsearch (opts) {
106112

107113
var path = ''
108114

109-
if ((index) != null) {
115+
if ((index) != null && (type) != null) {
116+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch'
117+
} else if ((index) != null) {
110118
path = '/' + encodeURIComponent(index) + '/' + '_msearch'
111119
} else {
112120
path = '/' + '_msearch'

api/api/msearch_template.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ function buildMsearchTemplate (opts) {
7979
return handleError(err, callback)
8080
}
8181

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+
8288
// validate headers object
8389
if (options.headers != null && typeof options.headers !== 'object') {
8490
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
@@ -100,7 +106,9 @@ function buildMsearchTemplate (opts) {
100106

101107
var path = ''
102108

103-
if ((index) != null) {
109+
if ((index) != null && (type) != null) {
110+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' + '/' + 'template'
111+
} else if ((index) != null) {
104112
path = '/' + encodeURIComponent(index) + '/' + '_msearch' + '/' + 'template'
105113
} else {
106114
path = '/' + '_msearch' + '/' + 'template'

0 commit comments

Comments
 (0)