@opensearch-project/opensearch 1.1.0 → 2.1.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 (94) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.json +31 -0
  3. package/.prettierrc.json +5 -0
  4. package/.whitesource +15 -0
  5. package/ADMINS.md +13 -31
  6. package/CHANGELOG.md +24 -0
  7. package/COMPATIBILITY.md +27 -0
  8. package/DEVELOPER_GUIDE.md +22 -5
  9. package/MAINTAINERS.md +15 -70
  10. package/Makefile +2 -12
  11. package/README.md +19 -123
  12. package/RELEASING.md +3 -3
  13. package/SECURITY.md +1 -1
  14. package/USER_GUIDE.md +197 -0
  15. package/api/api/bulk.js +54 -28
  16. package/api/api/cat.js +355 -266
  17. package/api/api/clear_scroll.js +18 -19
  18. package/api/api/cluster.js +367 -221
  19. package/api/api/count.js +56 -26
  20. package/api/api/create.js +51 -26
  21. package/api/api/dangling_indices.js +96 -53
  22. package/api/api/delete.js +50 -24
  23. package/api/api/delete_by_query.js +89 -27
  24. package/api/api/delete_by_query_rethrottle.js +34 -21
  25. package/api/api/delete_script.js +32 -19
  26. package/api/api/exists.js +56 -24
  27. package/api/api/exists_source.js +61 -29
  28. package/api/api/explain.js +61 -24
  29. package/api/api/features.js +57 -37
  30. package/api/api/field_caps.js +37 -20
  31. package/api/api/get.js +56 -24
  32. package/api/api/get_script.js +31 -19
  33. package/api/api/get_script_context.js +16 -17
  34. package/api/api/get_script_languages.js +16 -17
  35. package/api/api/get_source.js +56 -24
  36. package/api/api/index.js +61 -30
  37. package/api/api/indices.js +1069 -859
  38. package/api/api/info.js +16 -17
  39. package/api/api/ingest.js +133 -98
  40. package/api/api/mget.js +51 -28
  41. package/api/api/msearch.js +50 -28
  42. package/api/api/msearch_template.js +54 -28
  43. package/api/api/mtermvectors.js +49 -26
  44. package/api/api/nodes.js +282 -156
  45. package/api/api/ping.js +16 -17
  46. package/api/api/put_script.js +41 -27
  47. package/api/api/rank_eval.js +38 -22
  48. package/api/api/reindex.js +39 -19
  49. package/api/api/reindex_rethrottle.js +33 -21
  50. package/api/api/render_search_template.js +19 -20
  51. package/api/api/scripts_painless_execute.js +16 -17
  52. package/api/api/scroll.js +32 -19
  53. package/api/api/search.js +109 -26
  54. package/api/api/search_shards.js +37 -20
  55. package/api/api/search_template.js +65 -28
  56. package/api/api/shutdown.js +67 -56
  57. package/api/api/snapshot.js +348 -226
  58. package/api/api/tasks.js +66 -48
  59. package/api/api/terms_enum.js +18 -19
  60. package/api/api/termvectors.js +58 -28
  61. package/api/api/update.js +65 -26
  62. package/api/api/update_by_query.js +90 -25
  63. package/api/api/update_by_query_rethrottle.js +34 -21
  64. package/api/index.js +268 -181
  65. package/api/new.d.ts +2043 -531
  66. package/api/opensearch_dashboards.d.ts +240 -238
  67. package/api/requestParams.d.ts +302 -71
  68. package/api/types.d.ts +6205 -5721
  69. package/api/utils.js +23 -24
  70. package/codecov.yml +2 -2
  71. package/index.d.ts +5203 -1037
  72. package/index.js +154 -143
  73. package/index.mjs +10 -11
  74. package/jenkins/release.JenkinsFile +11 -0
  75. package/lib/Connection.d.ts +38 -28
  76. package/lib/Connection.js +166 -170
  77. package/lib/Helpers.d.ts +108 -68
  78. package/lib/Helpers.js +401 -378
  79. package/lib/Serializer.d.ts +3 -4
  80. package/lib/Serializer.js +40 -41
  81. package/lib/Transport.d.ts +39 -15
  82. package/lib/Transport.js +381 -337
  83. package/lib/aws/AwsSigv4Signer.js +167 -0
  84. package/lib/aws/errors.js +24 -0
  85. package/lib/aws/index.d.ts +39 -0
  86. package/lib/aws/index.js +19 -0
  87. package/lib/errors.d.ts +26 -9
  88. package/lib/errors.js +76 -73
  89. package/lib/pool/BaseConnectionPool.js +101 -99
  90. package/lib/pool/CloudConnectionPool.js +17 -18
  91. package/lib/pool/ConnectionPool.js +106 -107
  92. package/lib/pool/index.d.ts +9 -8
  93. package/lib/pool/index.js +7 -8
  94. package/package.json +37 -15
package/api/api/tasks.js CHANGED
@@ -1,12 +1,11 @@
1
1
  /*
2
+ * Copyright OpenSearch Contributors
2
3
  * SPDX-License-Identifier: Apache-2.0
3
4
  *
4
5
  * The OpenSearch Contributors require contributions made to
5
6
  * this file be licensed under the Apache-2.0 license or a
6
7
  * compatible open source license.
7
8
  *
8
- * Modifications Copyright OpenSearch Contributors. See
9
- * GitHub history for details.
10
9
  */
11
10
 
12
11
  /*
@@ -28,33 +27,52 @@
28
27
  * under the License.
29
28
  */
30
29
 
31
- 'use strict'
30
+ 'use strict';
32
31
 
33
32
  /* eslint camelcase: 0 */
34
33
  /* eslint no-unused-vars: 0 */
35
34
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['nodes', 'actions', 'parent_task_id', 'wait_for_completion', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'timeout', 'detailed', 'group_by']
38
- const snakeCase = { parentTaskId: 'parent_task_id', waitForCompletion: 'wait_for_completion', errorTrace: 'error_trace', filterPath: 'filter_path', groupBy: 'group_by' }
39
-
40
- function TasksApi (transport, ConfigurationError) {
41
- this.transport = transport
42
- this[kConfigurationError] = ConfigurationError
35
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
+ const acceptedQuerystring = [
37
+ 'nodes',
38
+ 'actions',
39
+ 'parent_task_id',
40
+ 'wait_for_completion',
41
+ 'pretty',
42
+ 'human',
43
+ 'error_trace',
44
+ 'source',
45
+ 'filter_path',
46
+ 'timeout',
47
+ 'detailed',
48
+ 'group_by',
49
+ ];
50
+ const snakeCase = {
51
+ parentTaskId: 'parent_task_id',
52
+ waitForCompletion: 'wait_for_completion',
53
+ errorTrace: 'error_trace',
54
+ filterPath: 'filter_path',
55
+ groupBy: 'group_by',
56
+ };
57
+
58
+ function TasksApi(transport, ConfigurationError) {
59
+ this.transport = transport;
60
+ this[kConfigurationError] = ConfigurationError;
43
61
  }
44
62
 
45
- TasksApi.prototype.cancel = function tasksCancelApi (params, options, callback) {
46
- ;[params, options, callback] = normalizeArguments(params, options, callback)
63
+ TasksApi.prototype.cancel = function tasksCancelApi(params, options, callback) {
64
+ [params, options, callback] = normalizeArguments(params, options, callback);
47
65
 
48
- let { method, body, taskId, task_id, ...querystring } = params
49
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
66
+ let { method, body, taskId, task_id, ...querystring } = params;
67
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
50
68
 
51
- let path = ''
69
+ let path = '';
52
70
  if ((task_id || taskId) != null) {
53
- if (method == null) method = 'POST'
54
- path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_cancel'
71
+ if (method == null) method = 'POST';
72
+ path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_cancel';
55
73
  } else {
56
- if (method == null) method = 'POST'
57
- path = '/' + '_tasks' + '/' + '_cancel'
74
+ if (method == null) method = 'POST';
75
+ path = '/' + '_tasks' + '/' + '_cancel';
58
76
  }
59
77
 
60
78
  // build request object
@@ -62,58 +80,58 @@ TasksApi.prototype.cancel = function tasksCancelApi (params, options, callback)
62
80
  method,
63
81
  path,
64
82
  body: body || '',
65
- querystring
66
- }
83
+ querystring,
84
+ };
67
85
 
68
- return this.transport.request(request, options, callback)
69
- }
86
+ return this.transport.request(request, options, callback);
87
+ };
70
88
 
71
- TasksApi.prototype.get = function tasksGetApi (params, options, callback) {
72
- ;[params, options, callback] = normalizeArguments(params, options, callback)
89
+ TasksApi.prototype.get = function tasksGetApi(params, options, callback) {
90
+ [params, options, callback] = normalizeArguments(params, options, callback);
73
91
 
74
92
  // check required parameters
75
93
  if (params.task_id == null && params.taskId == null) {
76
- const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId')
77
- return handleError(err, callback)
94
+ const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId');
95
+ return handleError(err, callback);
78
96
  }
79
97
 
80
- let { method, body, taskId, task_id, ...querystring } = params
81
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
98
+ let { method, body, taskId, task_id, ...querystring } = params;
99
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
82
100
 
83
- let path = ''
84
- if (method == null) method = 'GET'
85
- path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId)
101
+ let path = '';
102
+ if (method == null) method = 'GET';
103
+ path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId);
86
104
 
87
105
  // build request object
88
106
  const request = {
89
107
  method,
90
108
  path,
91
109
  body: null,
92
- querystring
93
- }
110
+ querystring,
111
+ };
94
112
 
95
- return this.transport.request(request, options, callback)
96
- }
113
+ return this.transport.request(request, options, callback);
114
+ };
97
115
 
98
- TasksApi.prototype.list = function tasksListApi (params, options, callback) {
99
- ;[params, options, callback] = normalizeArguments(params, options, callback)
116
+ TasksApi.prototype.list = function tasksListApi(params, options, callback) {
117
+ [params, options, callback] = normalizeArguments(params, options, callback);
100
118
 
101
- let { method, body, ...querystring } = params
102
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
119
+ let { method, body, ...querystring } = params;
120
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
103
121
 
104
- let path = ''
105
- if (method == null) method = 'GET'
106
- path = '/' + '_tasks'
122
+ let path = '';
123
+ if (method == null) method = 'GET';
124
+ path = '/' + '_tasks';
107
125
 
108
126
  // build request object
109
127
  const request = {
110
128
  method,
111
129
  path,
112
130
  body: null,
113
- querystring
114
- }
131
+ querystring,
132
+ };
115
133
 
116
- return this.transport.request(request, options, callback)
117
- }
134
+ return this.transport.request(request, options, callback);
135
+ };
118
136
 
119
- module.exports = TasksApi
137
+ module.exports = TasksApi;
@@ -1,12 +1,11 @@
1
1
  /*
2
+ * Copyright OpenSearch Contributors
2
3
  * SPDX-License-Identifier: Apache-2.0
3
4
  *
4
5
  * The OpenSearch Contributors require contributions made to
5
6
  * this file be licensed under the Apache-2.0 license or a
6
7
  * compatible open source license.
7
8
  *
8
- * Modifications Copyright OpenSearch Contributors. See
9
- * GitHub history for details.
10
9
  */
11
10
 
12
11
  /*
@@ -28,40 +27,40 @@
28
27
  * under the License.
29
28
  */
30
29
 
31
- 'use strict'
30
+ 'use strict';
32
31
 
33
32
  /* eslint camelcase: 0 */
34
33
  /* eslint no-unused-vars: 0 */
35
34
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' }
35
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
+ const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'];
37
+ const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' };
39
38
 
40
- function termsEnumApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
39
+ function termsEnumApi(params, options, callback) {
40
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
41
 
43
42
  // check required parameters
44
43
  if (params.index == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: index')
46
- return handleError(err, callback)
44
+ const err = new this[kConfigurationError]('Missing required parameter: index');
45
+ return handleError(err, callback);
47
46
  }
48
47
 
49
- let { method, body, index, ...querystring } = params
50
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
48
+ let { method, body, index, ...querystring } = params;
49
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
51
50
 
52
- let path = ''
53
- if (method == null) method = body == null ? 'GET' : 'POST'
54
- path = '/' + encodeURIComponent(index) + '/' + '_terms_enum'
51
+ let path = '';
52
+ if (method == null) method = body == null ? 'GET' : 'POST';
53
+ path = '/' + encodeURIComponent(index) + '/' + '_terms_enum';
55
54
 
56
55
  // build request object
57
56
  const request = {
58
57
  method,
59
58
  path,
60
59
  body: body || '',
61
- querystring
62
- }
60
+ querystring,
61
+ };
63
62
 
64
- return this.transport.request(request, options, callback)
63
+ return this.transport.request(request, options, callback);
65
64
  }
66
65
 
67
- module.exports = termsEnumApi
66
+ module.exports = termsEnumApi;
@@ -1,12 +1,11 @@
1
1
  /*
2
+ * Copyright OpenSearch Contributors
2
3
  * SPDX-License-Identifier: Apache-2.0
3
4
  *
4
5
  * The OpenSearch Contributors require contributions made to
5
6
  * this file be licensed under the Apache-2.0 license or a
6
7
  * compatible open source license.
7
8
  *
8
- * Modifications Copyright OpenSearch Contributors. See
9
- * GitHub history for details.
10
9
  */
11
10
 
12
11
  /*
@@ -28,40 +27,71 @@
28
27
  * under the License.
29
28
  */
30
29
 
31
- 'use strict'
30
+ 'use strict';
32
31
 
33
32
  /* eslint camelcase: 0 */
34
33
  /* eslint no-unused-vars: 0 */
35
34
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['term_statistics', 'field_statistics', 'fields', 'offsets', 'positions', 'payloads', 'preference', 'routing', 'realtime', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { termStatistics: 'term_statistics', fieldStatistics: 'field_statistics', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' }
35
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
+ const acceptedQuerystring = [
37
+ 'term_statistics',
38
+ 'field_statistics',
39
+ 'fields',
40
+ 'offsets',
41
+ 'positions',
42
+ 'payloads',
43
+ 'preference',
44
+ 'routing',
45
+ 'realtime',
46
+ 'version',
47
+ 'version_type',
48
+ 'pretty',
49
+ 'human',
50
+ 'error_trace',
51
+ 'source',
52
+ 'filter_path',
53
+ ];
54
+ const snakeCase = {
55
+ termStatistics: 'term_statistics',
56
+ fieldStatistics: 'field_statistics',
57
+ versionType: 'version_type',
58
+ errorTrace: 'error_trace',
59
+ filterPath: 'filter_path',
60
+ };
39
61
 
40
- function termvectorsApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
62
+ function termvectorsApi(params, options, callback) {
63
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
64
 
43
65
  // check required parameters
44
66
  if (params.index == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: index')
46
- return handleError(err, callback)
67
+ const err = new this[kConfigurationError]('Missing required parameter: index');
68
+ return handleError(err, callback);
47
69
  }
48
70
 
49
- let { method, body, index, id, type, ...querystring } = params
50
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
71
+ let { method, body, index, id, type, ...querystring } = params;
72
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
51
73
 
52
- let path = ''
53
- if ((index) != null && (type) != null && (id) != null) {
54
- if (method == null) method = body == null ? 'GET' : 'POST'
55
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_termvectors'
56
- } else if ((index) != null && (id) != null) {
57
- if (method == null) method = body == null ? 'GET' : 'POST'
58
- path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id)
59
- } else if ((index) != null && (type) != null) {
60
- if (method == null) method = body == null ? 'GET' : 'POST'
61
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_termvectors'
74
+ let path = '';
75
+ if (index != null && type != null && id != null) {
76
+ if (method == null) method = body == null ? 'GET' : 'POST';
77
+ path =
78
+ '/' +
79
+ encodeURIComponent(index) +
80
+ '/' +
81
+ encodeURIComponent(type) +
82
+ '/' +
83
+ encodeURIComponent(id) +
84
+ '/' +
85
+ '_termvectors';
86
+ } else if (index != null && id != null) {
87
+ if (method == null) method = body == null ? 'GET' : 'POST';
88
+ path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id);
89
+ } else if (index != null && type != null) {
90
+ if (method == null) method = body == null ? 'GET' : 'POST';
91
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_termvectors';
62
92
  } else {
63
- if (method == null) method = body == null ? 'GET' : 'POST'
64
- path = '/' + encodeURIComponent(index) + '/' + '_termvectors'
93
+ if (method == null) method = body == null ? 'GET' : 'POST';
94
+ path = '/' + encodeURIComponent(index) + '/' + '_termvectors';
65
95
  }
66
96
 
67
97
  // build request object
@@ -69,10 +99,10 @@ function termvectorsApi (params, options, callback) {
69
99
  method,
70
100
  path,
71
101
  body: body || '',
72
- querystring
73
- }
102
+ querystring,
103
+ };
74
104
 
75
- return this.transport.request(request, options, callback)
105
+ return this.transport.request(request, options, callback);
76
106
  }
77
107
 
78
- module.exports = termvectorsApi
108
+ module.exports = termvectorsApi;
package/api/api/update.js CHANGED
@@ -1,12 +1,11 @@
1
1
  /*
2
+ * Copyright OpenSearch Contributors
2
3
  * SPDX-License-Identifier: Apache-2.0
3
4
  *
4
5
  * The OpenSearch Contributors require contributions made to
5
6
  * this file be licensed under the Apache-2.0 license or a
6
7
  * compatible open source license.
7
8
  *
8
- * Modifications Copyright OpenSearch Contributors. See
9
- * GitHub history for details.
10
9
  */
11
10
 
12
11
  /*
@@ -28,42 +27,82 @@
28
27
  * under the License.
29
28
  */
30
29
 
31
- 'use strict'
30
+ 'use strict';
32
31
 
33
32
  /* eslint camelcase: 0 */
34
33
  /* eslint no-unused-vars: 0 */
35
34
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['wait_for_active_shards', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'lang', 'refresh', 'retry_on_conflict', 'routing', 'timeout', 'if_seq_no', 'if_primary_term', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', retryOnConflict: 'retry_on_conflict', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' }
35
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
+ const acceptedQuerystring = [
37
+ 'wait_for_active_shards',
38
+ '_source',
39
+ '_source_excludes',
40
+ '_source_exclude',
41
+ '_source_includes',
42
+ '_source_include',
43
+ 'lang',
44
+ 'refresh',
45
+ 'retry_on_conflict',
46
+ 'routing',
47
+ 'timeout',
48
+ 'if_seq_no',
49
+ 'if_primary_term',
50
+ 'require_alias',
51
+ 'pretty',
52
+ 'human',
53
+ 'error_trace',
54
+ 'source',
55
+ 'filter_path',
56
+ ];
57
+ const snakeCase = {
58
+ waitForActiveShards: 'wait_for_active_shards',
59
+ _sourceExcludes: '_source_excludes',
60
+ _sourceExclude: '_source_exclude',
61
+ _sourceIncludes: '_source_includes',
62
+ _sourceInclude: '_source_include',
63
+ retryOnConflict: 'retry_on_conflict',
64
+ ifSeqNo: 'if_seq_no',
65
+ ifPrimaryTerm: 'if_primary_term',
66
+ requireAlias: 'require_alias',
67
+ errorTrace: 'error_trace',
68
+ filterPath: 'filter_path',
69
+ };
39
70
 
40
- function updateApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
71
+ function updateApi(params, options, callback) {
72
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
73
 
43
74
  // check required parameters
44
75
  if (params.id == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: id')
46
- return handleError(err, callback)
76
+ const err = new this[kConfigurationError]('Missing required parameter: id');
77
+ return handleError(err, callback);
47
78
  }
48
79
  if (params.index == null) {
49
- const err = new this[kConfigurationError]('Missing required parameter: index')
50
- return handleError(err, callback)
80
+ const err = new this[kConfigurationError]('Missing required parameter: index');
81
+ return handleError(err, callback);
51
82
  }
52
83
  if (params.body == null) {
53
- const err = new this[kConfigurationError]('Missing required parameter: body')
54
- return handleError(err, callback)
84
+ const err = new this[kConfigurationError]('Missing required parameter: body');
85
+ return handleError(err, callback);
55
86
  }
56
87
 
57
- let { method, body, id, index, type, ...querystring } = params
58
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
88
+ let { method, body, id, index, type, ...querystring } = params;
89
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
59
90
 
60
- let path = ''
61
- if ((index) != null && (type) != null && (id) != null) {
62
- if (method == null) method = 'POST'
63
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_update'
91
+ let path = '';
92
+ if (index != null && type != null && id != null) {
93
+ if (method == null) method = 'POST';
94
+ path =
95
+ '/' +
96
+ encodeURIComponent(index) +
97
+ '/' +
98
+ encodeURIComponent(type) +
99
+ '/' +
100
+ encodeURIComponent(id) +
101
+ '/' +
102
+ '_update';
64
103
  } else {
65
- if (method == null) method = 'POST'
66
- path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id)
104
+ if (method == null) method = 'POST';
105
+ path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id);
67
106
  }
68
107
 
69
108
  // build request object
@@ -71,10 +110,10 @@ function updateApi (params, options, callback) {
71
110
  method,
72
111
  path,
73
112
  body: body || '',
74
- querystring
75
- }
113
+ querystring,
114
+ };
76
115
 
77
- return this.transport.request(request, options, callback)
116
+ return this.transport.request(request, options, callback);
78
117
  }
79
118
 
80
- module.exports = updateApi
119
+ module.exports = updateApi;
@@ -1,12 +1,11 @@
1
1
  /*
2
+ * Copyright OpenSearch Contributors
2
3
  * SPDX-License-Identifier: Apache-2.0
3
4
  *
4
5
  * The OpenSearch Contributors require contributions made to
5
6
  * this file be licensed under the Apache-2.0 license or a
6
7
  * compatible open source license.
7
8
  *
8
- * Modifications Copyright OpenSearch Contributors. See
9
- * GitHub history for details.
10
9
  */
11
10
 
12
11
  /*
@@ -28,40 +27,106 @@
28
27
  * under the License.
29
28
  */
30
29
 
31
- 'use strict'
30
+ 'use strict';
32
31
 
33
32
  /* eslint camelcase: 0 */
34
33
  /* eslint no-unused-vars: 0 */
35
34
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['analyzer', 'analyze_wildcard', 'default_operator', 'df', 'from', 'ignore_unavailable', 'allow_no_indices', 'conflicts', 'expand_wildcards', 'lenient', 'pipeline', 'preference', 'q', 'routing', 'scroll', 'search_type', 'search_timeout', 'size', 'max_docs', 'sort', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'terminate_after', 'stats', 'version', 'version_type', 'request_cache', 'refresh', 'timeout', 'wait_for_active_shards', 'scroll_size', 'wait_for_completion', 'requests_per_second', 'slices', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', searchTimeout: 'search_timeout', maxDocs: 'max_docs', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', terminateAfter: 'terminate_after', versionType: 'version_type', requestCache: 'request_cache', waitForActiveShards: 'wait_for_active_shards', scrollSize: 'scroll_size', waitForCompletion: 'wait_for_completion', requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' }
35
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
+ const acceptedQuerystring = [
37
+ 'analyzer',
38
+ 'analyze_wildcard',
39
+ 'default_operator',
40
+ 'df',
41
+ 'from',
42
+ 'ignore_unavailable',
43
+ 'allow_no_indices',
44
+ 'conflicts',
45
+ 'expand_wildcards',
46
+ 'lenient',
47
+ 'pipeline',
48
+ 'preference',
49
+ 'q',
50
+ 'routing',
51
+ 'scroll',
52
+ 'search_type',
53
+ 'search_timeout',
54
+ 'size',
55
+ 'max_docs',
56
+ 'sort',
57
+ '_source',
58
+ '_source_excludes',
59
+ '_source_exclude',
60
+ '_source_includes',
61
+ '_source_include',
62
+ 'terminate_after',
63
+ 'stats',
64
+ 'version',
65
+ 'version_type',
66
+ 'request_cache',
67
+ 'refresh',
68
+ 'timeout',
69
+ 'wait_for_active_shards',
70
+ 'scroll_size',
71
+ 'wait_for_completion',
72
+ 'requests_per_second',
73
+ 'slices',
74
+ 'pretty',
75
+ 'human',
76
+ 'error_trace',
77
+ 'source',
78
+ 'filter_path',
79
+ ];
80
+ const snakeCase = {
81
+ analyzeWildcard: 'analyze_wildcard',
82
+ defaultOperator: 'default_operator',
83
+ ignoreUnavailable: 'ignore_unavailable',
84
+ allowNoIndices: 'allow_no_indices',
85
+ expandWildcards: 'expand_wildcards',
86
+ searchType: 'search_type',
87
+ searchTimeout: 'search_timeout',
88
+ maxDocs: 'max_docs',
89
+ _sourceExcludes: '_source_excludes',
90
+ _sourceExclude: '_source_exclude',
91
+ _sourceIncludes: '_source_includes',
92
+ _sourceInclude: '_source_include',
93
+ terminateAfter: 'terminate_after',
94
+ versionType: 'version_type',
95
+ requestCache: 'request_cache',
96
+ waitForActiveShards: 'wait_for_active_shards',
97
+ scrollSize: 'scroll_size',
98
+ waitForCompletion: 'wait_for_completion',
99
+ requestsPerSecond: 'requests_per_second',
100
+ errorTrace: 'error_trace',
101
+ filterPath: 'filter_path',
102
+ };
39
103
 
40
- function updateByQueryApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
104
+ function updateByQueryApi(params, options, callback) {
105
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
106
 
43
107
  // check required parameters
44
108
  if (params.index == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: index')
46
- return handleError(err, callback)
109
+ const err = new this[kConfigurationError]('Missing required parameter: index');
110
+ return handleError(err, callback);
47
111
  }
48
112
 
49
113
  // check required url components
50
- if (params.type != null && (params.index == null)) {
51
- const err = new this[kConfigurationError]('Missing required parameter of the url: index')
52
- return handleError(err, callback)
114
+ if (params.type != null && params.index == null) {
115
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index');
116
+ return handleError(err, callback);
53
117
  }
54
118
 
55
- let { method, body, index, type, ...querystring } = params
56
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
119
+ let { method, body, index, type, ...querystring } = params;
120
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
57
121
 
58
- let path = ''
59
- if ((index) != null && (type) != null) {
60
- if (method == null) method = 'POST'
61
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_update_by_query'
122
+ let path = '';
123
+ if (index != null && type != null) {
124
+ if (method == null) method = 'POST';
125
+ path =
126
+ '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_update_by_query';
62
127
  } else {
63
- if (method == null) method = 'POST'
64
- path = '/' + encodeURIComponent(index) + '/' + '_update_by_query'
128
+ if (method == null) method = 'POST';
129
+ path = '/' + encodeURIComponent(index) + '/' + '_update_by_query';
65
130
  }
66
131
 
67
132
  // build request object
@@ -69,10 +134,10 @@ function updateByQueryApi (params, options, callback) {
69
134
  method,
70
135
  path,
71
136
  body: body || '',
72
- querystring
73
- }
137
+ querystring,
138
+ };
74
139
 
75
- return this.transport.request(request, options, callback)
140
+ return this.transport.request(request, options, callback);
76
141
  }
77
142
 
78
- module.exports = updateByQueryApi
143
+ module.exports = updateByQueryApi;