@opensearch-project/opensearch 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/.dockerignore +5 -0
  2. package/ADMINS.md +34 -0
  3. package/DEVELOPER_GUIDE.md +60 -0
  4. package/LICENSE.txt +201 -0
  5. package/MAINTAINERS.md +73 -0
  6. package/Makefile +27 -0
  7. package/NOTICE.txt +8 -0
  8. package/README.md +183 -0
  9. package/RELEASING.md +34 -0
  10. package/SECURITY.md +3 -0
  11. package/api/api/bulk.js +81 -0
  12. package/api/api/cat.js +525 -0
  13. package/api/api/clear_scroll.js +66 -0
  14. package/api/api/cluster.js +431 -0
  15. package/api/api/count.js +75 -0
  16. package/api/api/create.js +80 -0
  17. package/api/api/dangling_indices.js +126 -0
  18. package/api/api/delete.js +76 -0
  19. package/api/api/delete_by_query.js +82 -0
  20. package/api/api/delete_by_query_rethrottle.js +71 -0
  21. package/api/api/delete_script.js +67 -0
  22. package/api/api/exists.js +76 -0
  23. package/api/api/exists_source.js +85 -0
  24. package/api/api/explain.js +76 -0
  25. package/api/api/features.js +92 -0
  26. package/api/api/field_caps.js +66 -0
  27. package/api/api/get.js +76 -0
  28. package/api/api/get_script.js +67 -0
  29. package/api/api/get_script_context.js +61 -0
  30. package/api/api/get_script_languages.js +61 -0
  31. package/api/api/get_source.js +76 -0
  32. package/api/api/index.js +82 -0
  33. package/api/api/indices.js +1516 -0
  34. package/api/api/info.js +61 -0
  35. package/api/api/ingest.js +211 -0
  36. package/api/api/mget.js +81 -0
  37. package/api/api/msearch.js +81 -0
  38. package/api/api/msearch_template.js +81 -0
  39. package/api/api/mtermvectors.js +75 -0
  40. package/api/api/nodes.js +279 -0
  41. package/api/api/ping.js +61 -0
  42. package/api/api/put_script.js +82 -0
  43. package/api/api/rank_eval.js +72 -0
  44. package/api/api/reindex.js +67 -0
  45. package/api/api/reindex_rethrottle.js +71 -0
  46. package/api/api/render_search_template.js +66 -0
  47. package/api/api/scripts_painless_execute.js +61 -0
  48. package/api/api/scroll.js +66 -0
  49. package/api/api/search.js +75 -0
  50. package/api/api/search_shards.js +66 -0
  51. package/api/api/search_template.js +81 -0
  52. package/api/api/shutdown.js +135 -0
  53. package/api/api/snapshot.js +450 -0
  54. package/api/api/tasks.js +119 -0
  55. package/api/api/terms_enum.js +67 -0
  56. package/api/api/termvectors.js +78 -0
  57. package/api/api/update.js +80 -0
  58. package/api/api/update_by_query.js +78 -0
  59. package/api/api/update_by_query_rethrottle.js +71 -0
  60. package/api/index.js +254 -0
  61. package/api/new.d.ts +716 -0
  62. package/api/requestParams.d.ts +1583 -0
  63. package/api/types.d.ts +9481 -0
  64. package/api/utils.js +69 -0
  65. package/codecov.yml +14 -0
  66. package/index.d.ts +1210 -0
  67. package/index.js +338 -0
  68. package/index.mjs +40 -0
  69. package/lib/Connection.d.ts +107 -0
  70. package/lib/Connection.js +345 -0
  71. package/lib/Helpers.d.ts +135 -0
  72. package/lib/Helpers.js +779 -0
  73. package/lib/Serializer.d.ts +41 -0
  74. package/lib/Serializer.js +105 -0
  75. package/lib/Transport.d.ts +173 -0
  76. package/lib/Transport.js +646 -0
  77. package/lib/errors.d.ts +101 -0
  78. package/lib/errors.js +168 -0
  79. package/lib/pool/BaseConnectionPool.js +269 -0
  80. package/lib/pool/CloudConnectionPool.js +75 -0
  81. package/lib/pool/ConnectionPool.js +257 -0
  82. package/lib/pool/index.d.ts +215 -0
  83. package/lib/pool/index.js +41 -0
  84. package/package.json +102 -0
@@ -0,0 +1,431 @@
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ *
4
+ * The OpenSearch Contributors require contributions made to
5
+ * this file be licensed under the Apache-2.0 license or a
6
+ * compatible open source license.
7
+ *
8
+ * Modifications Copyright OpenSearch Contributors. See
9
+ * GitHub history for details.
10
+ */
11
+
12
+ /*
13
+ * Licensed to Elasticsearch B.V. under one or more contributor
14
+ * license agreements. See the NOTICE file distributed with
15
+ * this work for additional information regarding copyright
16
+ * ownership. Elasticsearch B.V. licenses this file to you under
17
+ * the Apache License, Version 2.0 (the "License"); you may
18
+ * not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing,
24
+ * software distributed under the License is distributed on an
25
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ * KIND, either express or implied. See the License for the
27
+ * specific language governing permissions and limitations
28
+ * under the License.
29
+ */
30
+
31
+ 'use strict'
32
+
33
+ /* eslint camelcase: 0 */
34
+ /* eslint no-unused-vars: 0 */
35
+
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
+ const acceptedQuerystring = ['include_yes_decisions', 'include_disk_info', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'timeout', 'master_timeout', 'wait_for_removal', 'local', 'flat_settings', 'include_defaults', 'expand_wildcards', 'level', 'wait_for_active_shards', 'wait_for_nodes', 'wait_for_events', 'wait_for_no_relocating_shards', 'wait_for_no_initializing_shards', 'wait_for_status', 'node_ids', 'node_names', 'create', 'dry_run', 'explain', 'retry_failed', 'metric', 'wait_for_metadata_version', 'wait_for_timeout', 'ignore_unavailable', 'allow_no_indices']
38
+ const snakeCase = { includeYesDecisions: 'include_yes_decisions', includeDiskInfo: 'include_disk_info', errorTrace: 'error_trace', filterPath: 'filter_path', masterTimeout: 'master_timeout', waitForRemoval: 'wait_for_removal', flatSettings: 'flat_settings', includeDefaults: 'include_defaults', expandWildcards: 'expand_wildcards', waitForActiveShards: 'wait_for_active_shards', waitForNodes: 'wait_for_nodes', waitForEvents: 'wait_for_events', waitForNoRelocatingShards: 'wait_for_no_relocating_shards', waitForNoInitializingShards: 'wait_for_no_initializing_shards', waitForStatus: 'wait_for_status', nodeIds: 'node_ids', nodeNames: 'node_names', dryRun: 'dry_run', retryFailed: 'retry_failed', waitForMetadataVersion: 'wait_for_metadata_version', waitForTimeout: 'wait_for_timeout', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices' }
39
+
40
+ function ClusterApi (transport, ConfigurationError) {
41
+ this.transport = transport
42
+ this[kConfigurationError] = ConfigurationError
43
+ }
44
+
45
+ ClusterApi.prototype.allocationExplain = function clusterAllocationExplainApi (params, options, callback) {
46
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
47
+
48
+ let { method, body, ...querystring } = params
49
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
50
+
51
+ let path = ''
52
+ if (method == null) method = body == null ? 'GET' : 'POST'
53
+ path = '/' + '_cluster' + '/' + 'allocation' + '/' + 'explain'
54
+
55
+ // build request object
56
+ const request = {
57
+ method,
58
+ path,
59
+ body: body || '',
60
+ querystring
61
+ }
62
+
63
+ return this.transport.request(request, options, callback)
64
+ }
65
+
66
+ ClusterApi.prototype.deleteComponentTemplate = function clusterDeleteComponentTemplateApi (params, options, callback) {
67
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
68
+
69
+ // check required parameters
70
+ if (params.name == null) {
71
+ const err = new this[kConfigurationError]('Missing required parameter: name')
72
+ return handleError(err, callback)
73
+ }
74
+
75
+ let { method, body, name, ...querystring } = params
76
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
77
+
78
+ let path = ''
79
+ if (method == null) method = 'DELETE'
80
+ path = '/' + '_component_template' + '/' + encodeURIComponent(name)
81
+
82
+ // build request object
83
+ const request = {
84
+ method,
85
+ path,
86
+ body: body || '',
87
+ querystring
88
+ }
89
+
90
+ return this.transport.request(request, options, callback)
91
+ }
92
+
93
+ ClusterApi.prototype.deleteVotingConfigExclusions = function clusterDeleteVotingConfigExclusionsApi (params, options, callback) {
94
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
95
+
96
+ let { method, body, ...querystring } = params
97
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
98
+
99
+ let path = ''
100
+ if (method == null) method = 'DELETE'
101
+ path = '/' + '_cluster' + '/' + 'voting_config_exclusions'
102
+
103
+ // build request object
104
+ const request = {
105
+ method,
106
+ path,
107
+ body: body || '',
108
+ querystring
109
+ }
110
+
111
+ return this.transport.request(request, options, callback)
112
+ }
113
+
114
+ ClusterApi.prototype.existsComponentTemplate = function clusterExistsComponentTemplateApi (params, options, callback) {
115
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
116
+
117
+ // check required parameters
118
+ if (params.name == null) {
119
+ const err = new this[kConfigurationError]('Missing required parameter: name')
120
+ return handleError(err, callback)
121
+ }
122
+
123
+ let { method, body, name, ...querystring } = params
124
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
125
+
126
+ let path = ''
127
+ if (method == null) method = 'HEAD'
128
+ path = '/' + '_component_template' + '/' + encodeURIComponent(name)
129
+
130
+ // build request object
131
+ const request = {
132
+ method,
133
+ path,
134
+ body: null,
135
+ querystring
136
+ }
137
+
138
+ return this.transport.request(request, options, callback)
139
+ }
140
+
141
+ ClusterApi.prototype.getComponentTemplate = function clusterGetComponentTemplateApi (params, options, callback) {
142
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
143
+
144
+ let { method, body, name, ...querystring } = params
145
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
146
+
147
+ let path = ''
148
+ if ((name) != null) {
149
+ if (method == null) method = 'GET'
150
+ path = '/' + '_component_template' + '/' + encodeURIComponent(name)
151
+ } else {
152
+ if (method == null) method = 'GET'
153
+ path = '/' + '_component_template'
154
+ }
155
+
156
+ // build request object
157
+ const request = {
158
+ method,
159
+ path,
160
+ body: null,
161
+ querystring
162
+ }
163
+
164
+ return this.transport.request(request, options, callback)
165
+ }
166
+
167
+ ClusterApi.prototype.getSettings = function clusterGetSettingsApi (params, options, callback) {
168
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
169
+
170
+ let { method, body, ...querystring } = params
171
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
172
+
173
+ let path = ''
174
+ if (method == null) method = 'GET'
175
+ path = '/' + '_cluster' + '/' + 'settings'
176
+
177
+ // build request object
178
+ const request = {
179
+ method,
180
+ path,
181
+ body: null,
182
+ querystring
183
+ }
184
+
185
+ return this.transport.request(request, options, callback)
186
+ }
187
+
188
+ ClusterApi.prototype.health = function clusterHealthApi (params, options, callback) {
189
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
190
+
191
+ let { method, body, index, ...querystring } = params
192
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
193
+
194
+ let path = ''
195
+ if ((index) != null) {
196
+ if (method == null) method = 'GET'
197
+ path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(index)
198
+ } else {
199
+ if (method == null) method = 'GET'
200
+ path = '/' + '_cluster' + '/' + 'health'
201
+ }
202
+
203
+ // build request object
204
+ const request = {
205
+ method,
206
+ path,
207
+ body: null,
208
+ querystring
209
+ }
210
+
211
+ return this.transport.request(request, options, callback)
212
+ }
213
+
214
+ ClusterApi.prototype.pendingTasks = function clusterPendingTasksApi (params, options, callback) {
215
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
216
+
217
+ let { method, body, ...querystring } = params
218
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
219
+
220
+ let path = ''
221
+ if (method == null) method = 'GET'
222
+ path = '/' + '_cluster' + '/' + 'pending_tasks'
223
+
224
+ // build request object
225
+ const request = {
226
+ method,
227
+ path,
228
+ body: null,
229
+ querystring
230
+ }
231
+
232
+ return this.transport.request(request, options, callback)
233
+ }
234
+
235
+ ClusterApi.prototype.postVotingConfigExclusions = function clusterPostVotingConfigExclusionsApi (params, options, callback) {
236
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
237
+
238
+ let { method, body, ...querystring } = params
239
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
240
+
241
+ let path = ''
242
+ if (method == null) method = 'POST'
243
+ path = '/' + '_cluster' + '/' + 'voting_config_exclusions'
244
+
245
+ // build request object
246
+ const request = {
247
+ method,
248
+ path,
249
+ body: body || '',
250
+ querystring
251
+ }
252
+
253
+ return this.transport.request(request, options, callback)
254
+ }
255
+
256
+ ClusterApi.prototype.putComponentTemplate = function clusterPutComponentTemplateApi (params, options, callback) {
257
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
258
+
259
+ // check required parameters
260
+ if (params.name == null) {
261
+ const err = new this[kConfigurationError]('Missing required parameter: name')
262
+ return handleError(err, callback)
263
+ }
264
+ if (params.body == null) {
265
+ const err = new this[kConfigurationError]('Missing required parameter: body')
266
+ return handleError(err, callback)
267
+ }
268
+
269
+ let { method, body, name, ...querystring } = params
270
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
271
+
272
+ let path = ''
273
+ if (method == null) method = 'PUT'
274
+ path = '/' + '_component_template' + '/' + encodeURIComponent(name)
275
+
276
+ // build request object
277
+ const request = {
278
+ method,
279
+ path,
280
+ body: body || '',
281
+ querystring
282
+ }
283
+
284
+ return this.transport.request(request, options, callback)
285
+ }
286
+
287
+ ClusterApi.prototype.putSettings = function clusterPutSettingsApi (params, options, callback) {
288
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
289
+
290
+ // check required parameters
291
+ if (params.body == null) {
292
+ const err = new this[kConfigurationError]('Missing required parameter: body')
293
+ return handleError(err, callback)
294
+ }
295
+
296
+ let { method, body, ...querystring } = params
297
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
298
+
299
+ let path = ''
300
+ if (method == null) method = 'PUT'
301
+ path = '/' + '_cluster' + '/' + 'settings'
302
+
303
+ // build request object
304
+ const request = {
305
+ method,
306
+ path,
307
+ body: body || '',
308
+ querystring
309
+ }
310
+
311
+ return this.transport.request(request, options, callback)
312
+ }
313
+
314
+ ClusterApi.prototype.remoteInfo = function clusterRemoteInfoApi (params, options, callback) {
315
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
316
+
317
+ let { method, body, ...querystring } = params
318
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
319
+
320
+ let path = ''
321
+ if (method == null) method = 'GET'
322
+ path = '/' + '_remote' + '/' + 'info'
323
+
324
+ // build request object
325
+ const request = {
326
+ method,
327
+ path,
328
+ body: null,
329
+ querystring
330
+ }
331
+
332
+ return this.transport.request(request, options, callback)
333
+ }
334
+
335
+ ClusterApi.prototype.reroute = function clusterRerouteApi (params, options, callback) {
336
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
337
+
338
+ let { method, body, ...querystring } = params
339
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
340
+
341
+ let path = ''
342
+ if (method == null) method = 'POST'
343
+ path = '/' + '_cluster' + '/' + 'reroute'
344
+
345
+ // build request object
346
+ const request = {
347
+ method,
348
+ path,
349
+ body: body || '',
350
+ querystring
351
+ }
352
+
353
+ return this.transport.request(request, options, callback)
354
+ }
355
+
356
+ ClusterApi.prototype.state = function clusterStateApi (params, options, callback) {
357
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
358
+
359
+ // check required url components
360
+ if (params.index != null && (params.metric == null)) {
361
+ const err = new this[kConfigurationError]('Missing required parameter of the url: metric')
362
+ return handleError(err, callback)
363
+ }
364
+
365
+ let { method, body, metric, index, ...querystring } = params
366
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
367
+
368
+ let path = ''
369
+ if ((metric) != null && (index) != null) {
370
+ if (method == null) method = 'GET'
371
+ path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index)
372
+ } else if ((metric) != null) {
373
+ if (method == null) method = 'GET'
374
+ path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric)
375
+ } else {
376
+ if (method == null) method = 'GET'
377
+ path = '/' + '_cluster' + '/' + 'state'
378
+ }
379
+
380
+ // build request object
381
+ const request = {
382
+ method,
383
+ path,
384
+ body: null,
385
+ querystring
386
+ }
387
+
388
+ return this.transport.request(request, options, callback)
389
+ }
390
+
391
+ ClusterApi.prototype.stats = function clusterStatsApi (params, options, callback) {
392
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
393
+
394
+ let { method, body, nodeId, node_id, ...querystring } = params
395
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
396
+
397
+ let path = ''
398
+ if ((node_id || nodeId) != null) {
399
+ if (method == null) method = 'GET'
400
+ path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId)
401
+ } else {
402
+ if (method == null) method = 'GET'
403
+ path = '/' + '_cluster' + '/' + 'stats'
404
+ }
405
+
406
+ // build request object
407
+ const request = {
408
+ method,
409
+ path,
410
+ body: null,
411
+ querystring
412
+ }
413
+
414
+ return this.transport.request(request, options, callback)
415
+ }
416
+
417
+ Object.defineProperties(ClusterApi.prototype, {
418
+ allocation_explain: { get () { return this.allocationExplain } },
419
+ delete_component_template: { get () { return this.deleteComponentTemplate } },
420
+ delete_voting_config_exclusions: { get () { return this.deleteVotingConfigExclusions } },
421
+ exists_component_template: { get () { return this.existsComponentTemplate } },
422
+ get_component_template: { get () { return this.getComponentTemplate } },
423
+ get_settings: { get () { return this.getSettings } },
424
+ pending_tasks: { get () { return this.pendingTasks } },
425
+ post_voting_config_exclusions: { get () { return this.postVotingConfigExclusions } },
426
+ put_component_template: { get () { return this.putComponentTemplate } },
427
+ put_settings: { get () { return this.putSettings } },
428
+ remote_info: { get () { return this.remoteInfo } }
429
+ })
430
+
431
+ module.exports = ClusterApi
@@ -0,0 +1,75 @@
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ *
4
+ * The OpenSearch Contributors require contributions made to
5
+ * this file be licensed under the Apache-2.0 license or a
6
+ * compatible open source license.
7
+ *
8
+ * Modifications Copyright OpenSearch Contributors. See
9
+ * GitHub history for details.
10
+ */
11
+
12
+ /*
13
+ * Licensed to Elasticsearch B.V. under one or more contributor
14
+ * license agreements. See the NOTICE file distributed with
15
+ * this work for additional information regarding copyright
16
+ * ownership. Elasticsearch B.V. licenses this file to you under
17
+ * the Apache License, Version 2.0 (the "License"); you may
18
+ * not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing,
24
+ * software distributed under the License is distributed on an
25
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ * KIND, either express or implied. See the License for the
27
+ * specific language governing permissions and limitations
28
+ * under the License.
29
+ */
30
+
31
+ 'use strict'
32
+
33
+ /* eslint camelcase: 0 */
34
+ /* eslint no-unused-vars: 0 */
35
+
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
+ const acceptedQuerystring = ['ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'min_score', 'preference', 'routing', 'q', 'analyzer', 'analyze_wildcard', 'default_operator', 'df', 'lenient', 'terminate_after', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', minScore: 'min_score', analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', terminateAfter: 'terminate_after', errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function countApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required url components
44
+ if (params.type != null && (params.index == null)) {
45
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index')
46
+ return handleError(err, callback)
47
+ }
48
+
49
+ let { method, body, index, type, ...querystring } = params
50
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
51
+
52
+ let path = ''
53
+ if ((index) != null && (type) != null) {
54
+ if (method == null) method = body == null ? 'GET' : 'POST'
55
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_count'
56
+ } else if ((index) != null) {
57
+ if (method == null) method = body == null ? 'GET' : 'POST'
58
+ path = '/' + encodeURIComponent(index) + '/' + '_count'
59
+ } else {
60
+ if (method == null) method = body == null ? 'GET' : 'POST'
61
+ path = '/' + '_count'
62
+ }
63
+
64
+ // build request object
65
+ const request = {
66
+ method,
67
+ path,
68
+ body: body || '',
69
+ querystring
70
+ }
71
+
72
+ return this.transport.request(request, options, callback)
73
+ }
74
+
75
+ module.exports = countApi
@@ -0,0 +1,80 @@
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ *
4
+ * The OpenSearch Contributors require contributions made to
5
+ * this file be licensed under the Apache-2.0 license or a
6
+ * compatible open source license.
7
+ *
8
+ * Modifications Copyright OpenSearch Contributors. See
9
+ * GitHub history for details.
10
+ */
11
+
12
+ /*
13
+ * Licensed to Elasticsearch B.V. under one or more contributor
14
+ * license agreements. See the NOTICE file distributed with
15
+ * this work for additional information regarding copyright
16
+ * ownership. Elasticsearch B.V. licenses this file to you under
17
+ * the Apache License, Version 2.0 (the "License"); you may
18
+ * not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing,
24
+ * software distributed under the License is distributed on an
25
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ * KIND, either express or implied. See the License for the
27
+ * specific language governing permissions and limitations
28
+ * under the License.
29
+ */
30
+
31
+ 'use strict'
32
+
33
+ /* eslint camelcase: 0 */
34
+ /* eslint no-unused-vars: 0 */
35
+
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
+ const acceptedQuerystring = ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'version', 'version_type', 'pipeline', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { waitForActiveShards: 'wait_for_active_shards', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function createApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required parameters
44
+ if (params.id == null) {
45
+ const err = new this[kConfigurationError]('Missing required parameter: id')
46
+ return handleError(err, callback)
47
+ }
48
+ if (params.index == null) {
49
+ const err = new this[kConfigurationError]('Missing required parameter: index')
50
+ return handleError(err, callback)
51
+ }
52
+ if (params.body == null) {
53
+ const err = new this[kConfigurationError]('Missing required parameter: body')
54
+ return handleError(err, callback)
55
+ }
56
+
57
+ let { method, body, id, index, type, ...querystring } = params
58
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
59
+
60
+ let path = ''
61
+ if ((index) != null && (type) != null && (id) != null) {
62
+ if (method == null) method = 'PUT'
63
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create'
64
+ } else {
65
+ if (method == null) method = 'PUT'
66
+ path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id)
67
+ }
68
+
69
+ // build request object
70
+ const request = {
71
+ method,
72
+ path,
73
+ body: body || '',
74
+ querystring
75
+ }
76
+
77
+ return this.transport.request(request, options, callback)
78
+ }
79
+
80
+ module.exports = createApi