@opensearch-project/opensearch 1.0.0 → 2.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 (86) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.json +26 -0
  3. package/.prettierrc.json +5 -0
  4. package/.whitesource +15 -0
  5. package/ADMINS.md +18 -11
  6. package/COMPATIBILITY.md +24 -0
  7. package/DEVELOPER_GUIDE.md +22 -5
  8. package/MAINTAINERS.md +23 -18
  9. package/README.md +102 -106
  10. package/RELEASING.md +3 -3
  11. package/SECURITY.md +1 -1
  12. package/api/api/bulk.js +53 -26
  13. package/api/api/cat.js +354 -264
  14. package/api/api/clear_scroll.js +17 -17
  15. package/api/api/cluster.js +366 -219
  16. package/api/api/count.js +55 -24
  17. package/api/api/create.js +50 -24
  18. package/api/api/dangling_indices.js +95 -51
  19. package/api/api/delete.js +49 -22
  20. package/api/api/delete_by_query.js +88 -25
  21. package/api/api/delete_by_query_rethrottle.js +33 -19
  22. package/api/api/delete_script.js +31 -17
  23. package/api/api/exists.js +55 -22
  24. package/api/api/exists_source.js +60 -27
  25. package/api/api/explain.js +60 -22
  26. package/api/api/features.js +56 -35
  27. package/api/api/field_caps.js +36 -18
  28. package/api/api/get.js +55 -22
  29. package/api/api/get_script.js +30 -17
  30. package/api/api/get_script_context.js +15 -15
  31. package/api/api/get_script_languages.js +15 -15
  32. package/api/api/get_source.js +55 -22
  33. package/api/api/index.js +60 -28
  34. package/api/api/indices.js +1068 -857
  35. package/api/api/info.js +15 -15
  36. package/api/api/ingest.js +132 -96
  37. package/api/api/mget.js +50 -26
  38. package/api/api/msearch.js +49 -26
  39. package/api/api/msearch_template.js +53 -26
  40. package/api/api/mtermvectors.js +48 -24
  41. package/api/api/nodes.js +281 -154
  42. package/api/api/ping.js +15 -15
  43. package/api/api/put_script.js +40 -25
  44. package/api/api/rank_eval.js +37 -20
  45. package/api/api/reindex.js +38 -17
  46. package/api/api/reindex_rethrottle.js +32 -19
  47. package/api/api/render_search_template.js +18 -18
  48. package/api/api/scripts_painless_execute.js +15 -15
  49. package/api/api/scroll.js +31 -17
  50. package/api/api/search.js +108 -24
  51. package/api/api/search_shards.js +36 -18
  52. package/api/api/search_template.js +64 -26
  53. package/api/api/shutdown.js +66 -54
  54. package/api/api/snapshot.js +347 -224
  55. package/api/api/tasks.js +65 -46
  56. package/api/api/terms_enum.js +17 -17
  57. package/api/api/termvectors.js +57 -26
  58. package/api/api/update.js +64 -24
  59. package/api/api/update_by_query.js +89 -23
  60. package/api/api/update_by_query_rethrottle.js +33 -19
  61. package/api/index.js +267 -179
  62. package/api/new.d.ts +2042 -529
  63. package/api/opensearch_dashboards.d.ts +275 -0
  64. package/api/requestParams.d.ts +301 -69
  65. package/api/types.d.ts +6204 -5719
  66. package/api/utils.js +22 -22
  67. package/codecov.yml +2 -2
  68. package/index.d.ts +4779 -934
  69. package/index.js +153 -140
  70. package/index.mjs +9 -9
  71. package/lib/Connection.d.ts +37 -26
  72. package/lib/Connection.js +163 -168
  73. package/lib/Helpers.d.ts +103 -63
  74. package/lib/Helpers.js +398 -371
  75. package/lib/Serializer.d.ts +2 -2
  76. package/lib/Serializer.js +39 -39
  77. package/lib/Transport.d.ts +30 -12
  78. package/lib/Transport.js +383 -324
  79. package/lib/errors.d.ts +25 -7
  80. package/lib/errors.js +75 -71
  81. package/lib/pool/BaseConnectionPool.js +100 -97
  82. package/lib/pool/CloudConnectionPool.js +16 -16
  83. package/lib/pool/ConnectionPool.js +105 -105
  84. package/lib/pool/index.d.ts +8 -6
  85. package/lib/pool/index.js +6 -6
  86. package/package.json +13 -8
@@ -28,28 +28,46 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
35
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['fields', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'include_unmapped', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', includeUnmapped: 'include_unmapped', errorTrace: 'error_trace', filterPath: 'filter_path' }
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
37
+ const acceptedQuerystring = [
38
+ 'fields',
39
+ 'ignore_unavailable',
40
+ 'allow_no_indices',
41
+ 'expand_wildcards',
42
+ 'include_unmapped',
43
+ 'pretty',
44
+ 'human',
45
+ 'error_trace',
46
+ 'source',
47
+ 'filter_path',
48
+ ];
49
+ const snakeCase = {
50
+ ignoreUnavailable: 'ignore_unavailable',
51
+ allowNoIndices: 'allow_no_indices',
52
+ expandWildcards: 'expand_wildcards',
53
+ includeUnmapped: 'include_unmapped',
54
+ errorTrace: 'error_trace',
55
+ filterPath: 'filter_path',
56
+ };
39
57
 
40
- function fieldCapsApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
58
+ function fieldCapsApi(params, options, callback) {
59
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
60
 
43
- let { method, body, index, ...querystring } = params
44
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
61
+ let { method, body, index, ...querystring } = params;
62
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
45
63
 
46
- let path = ''
47
- if ((index) != null) {
48
- if (method == null) method = body == null ? 'GET' : 'POST'
49
- path = '/' + encodeURIComponent(index) + '/' + '_field_caps'
64
+ let path = '';
65
+ if (index != null) {
66
+ if (method == null) method = body == null ? 'GET' : 'POST';
67
+ path = '/' + encodeURIComponent(index) + '/' + '_field_caps';
50
68
  } else {
51
- if (method == null) method = body == null ? 'GET' : 'POST'
52
- path = '/' + '_field_caps'
69
+ if (method == null) method = body == null ? 'GET' : 'POST';
70
+ path = '/' + '_field_caps';
53
71
  }
54
72
 
55
73
  // build request object
@@ -57,10 +75,10 @@ function fieldCapsApi (params, options, callback) {
57
75
  method,
58
76
  path,
59
77
  body: body || '',
60
- querystring
61
- }
78
+ querystring,
79
+ };
62
80
 
63
- return this.transport.request(request, options, callback)
81
+ return this.transport.request(request, options, callback);
64
82
  }
65
83
 
66
- module.exports = fieldCapsApi
84
+ module.exports = fieldCapsApi;
package/api/api/get.js CHANGED
@@ -28,38 +28,71 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
35
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' }
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
37
+ const acceptedQuerystring = [
38
+ 'stored_fields',
39
+ 'preference',
40
+ 'realtime',
41
+ 'refresh',
42
+ 'routing',
43
+ '_source',
44
+ '_source_excludes',
45
+ '_source_exclude',
46
+ '_source_includes',
47
+ '_source_include',
48
+ 'version',
49
+ 'version_type',
50
+ 'pretty',
51
+ 'human',
52
+ 'error_trace',
53
+ 'source',
54
+ 'filter_path',
55
+ ];
56
+ const snakeCase = {
57
+ storedFields: 'stored_fields',
58
+ _sourceExcludes: '_source_excludes',
59
+ _sourceExclude: '_source_exclude',
60
+ _sourceIncludes: '_source_includes',
61
+ _sourceInclude: '_source_include',
62
+ versionType: 'version_type',
63
+ errorTrace: 'error_trace',
64
+ filterPath: 'filter_path',
65
+ };
39
66
 
40
- function getApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
67
+ function getApi(params, options, callback) {
68
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
69
 
43
70
  // check required parameters
44
71
  if (params.id == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: id')
46
- return handleError(err, callback)
72
+ const err = new this[kConfigurationError]('Missing required parameter: id');
73
+ return handleError(err, callback);
47
74
  }
48
75
  if (params.index == null) {
49
- const err = new this[kConfigurationError]('Missing required parameter: index')
50
- return handleError(err, callback)
76
+ const err = new this[kConfigurationError]('Missing required parameter: index');
77
+ return handleError(err, callback);
51
78
  }
52
79
 
53
- let { method, body, id, index, type, ...querystring } = params
54
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
80
+ let { method, body, id, index, type, ...querystring } = params;
81
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
55
82
 
56
- let path = ''
57
- if ((index) != null && (type) != null && (id) != null) {
58
- if (method == null) method = 'GET'
59
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
83
+ let path = '';
84
+ if (index != null && type != null && id != null) {
85
+ if (method == null) method = 'GET';
86
+ path =
87
+ '/' +
88
+ encodeURIComponent(index) +
89
+ '/' +
90
+ encodeURIComponent(type) +
91
+ '/' +
92
+ encodeURIComponent(id);
60
93
  } else {
61
- if (method == null) method = 'GET'
62
- path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
94
+ if (method == null) method = 'GET';
95
+ path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id);
63
96
  }
64
97
 
65
98
  // build request object
@@ -67,10 +100,10 @@ function getApi (params, options, callback) {
67
100
  method,
68
101
  path,
69
102
  body: null,
70
- querystring
71
- }
103
+ querystring,
104
+ };
72
105
 
73
- return this.transport.request(request, options, callback)
106
+ return this.transport.request(request, options, callback);
74
107
  }
75
108
 
76
- module.exports = getApi
109
+ module.exports = getApi;
@@ -28,40 +28,53 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
35
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' }
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
37
+ const acceptedQuerystring = [
38
+ 'cluster_manager_timeout',
39
+ 'master_timeout',
40
+ 'pretty',
41
+ 'human',
42
+ 'error_trace',
43
+ 'source',
44
+ 'filter_path',
45
+ ];
46
+ const snakeCase = {
47
+ clusterManagerTimeout: 'cluster_manager_timeout',
48
+ masterTimeout: 'master_timeout',
49
+ errorTrace: 'error_trace',
50
+ filterPath: 'filter_path',
51
+ };
39
52
 
40
- function getScriptApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
53
+ function getScriptApi(params, options, callback) {
54
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
55
 
43
56
  // check required parameters
44
57
  if (params.id == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: id')
46
- return handleError(err, callback)
58
+ const err = new this[kConfigurationError]('Missing required parameter: id');
59
+ return handleError(err, callback);
47
60
  }
48
61
 
49
- let { method, body, id, ...querystring } = params
50
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
62
+ let { method, body, id, ...querystring } = params;
63
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
51
64
 
52
- let path = ''
53
- if (method == null) method = 'GET'
54
- path = '/' + '_scripts' + '/' + encodeURIComponent(id)
65
+ let path = '';
66
+ if (method == null) method = 'GET';
67
+ path = '/' + '_scripts' + '/' + encodeURIComponent(id);
55
68
 
56
69
  // build request object
57
70
  const request = {
58
71
  method,
59
72
  path,
60
73
  body: null,
61
- querystring
62
- }
74
+ querystring,
75
+ };
63
76
 
64
- return this.transport.request(request, options, callback)
77
+ return this.transport.request(request, options, callback);
65
78
  }
66
79
 
67
- module.exports = getScriptApi
80
+ module.exports = getScriptApi;
@@ -28,34 +28,34 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
35
 
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' }
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' };
39
39
 
40
- function getScriptContextApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
40
+ function getScriptContextApi(params, options, callback) {
41
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
42
 
43
- let { method, body, ...querystring } = params
44
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
43
+ let { method, body, ...querystring } = params;
44
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
45
45
 
46
- let path = ''
47
- if (method == null) method = 'GET'
48
- path = '/' + '_script_context'
46
+ let path = '';
47
+ if (method == null) method = 'GET';
48
+ path = '/' + '_script_context';
49
49
 
50
50
  // build request object
51
51
  const request = {
52
52
  method,
53
53
  path,
54
54
  body: null,
55
- querystring
56
- }
55
+ querystring,
56
+ };
57
57
 
58
- return this.transport.request(request, options, callback)
58
+ return this.transport.request(request, options, callback);
59
59
  }
60
60
 
61
- module.exports = getScriptContextApi
61
+ module.exports = getScriptContextApi;
@@ -28,34 +28,34 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
35
 
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' }
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' };
39
39
 
40
- function getScriptLanguagesApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
40
+ function getScriptLanguagesApi(params, options, callback) {
41
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
42
 
43
- let { method, body, ...querystring } = params
44
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
43
+ let { method, body, ...querystring } = params;
44
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
45
45
 
46
- let path = ''
47
- if (method == null) method = 'GET'
48
- path = '/' + '_script_language'
46
+ let path = '';
47
+ if (method == null) method = 'GET';
48
+ path = '/' + '_script_language';
49
49
 
50
50
  // build request object
51
51
  const request = {
52
52
  method,
53
53
  path,
54
54
  body: null,
55
- querystring
56
- }
55
+ querystring,
56
+ };
57
57
 
58
- return this.transport.request(request, options, callback)
58
+ return this.transport.request(request, options, callback);
59
59
  }
60
60
 
61
- module.exports = getScriptLanguagesApi
61
+ module.exports = getScriptLanguagesApi;
@@ -28,38 +28,71 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
35
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' }
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
37
+ const acceptedQuerystring = [
38
+ 'preference',
39
+ 'realtime',
40
+ 'refresh',
41
+ 'routing',
42
+ '_source',
43
+ '_source_excludes',
44
+ '_source_exclude',
45
+ '_source_includes',
46
+ '_source_include',
47
+ 'version',
48
+ 'version_type',
49
+ 'pretty',
50
+ 'human',
51
+ 'error_trace',
52
+ 'source',
53
+ 'filter_path',
54
+ ];
55
+ const snakeCase = {
56
+ _sourceExcludes: '_source_excludes',
57
+ _sourceExclude: '_source_exclude',
58
+ _sourceIncludes: '_source_includes',
59
+ _sourceInclude: '_source_include',
60
+ versionType: 'version_type',
61
+ errorTrace: 'error_trace',
62
+ filterPath: 'filter_path',
63
+ };
39
64
 
40
- function getSourceApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
65
+ function getSourceApi(params, options, callback) {
66
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
67
 
43
68
  // check required parameters
44
69
  if (params.id == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: id')
46
- return handleError(err, callback)
70
+ const err = new this[kConfigurationError]('Missing required parameter: id');
71
+ return handleError(err, callback);
47
72
  }
48
73
  if (params.index == null) {
49
- const err = new this[kConfigurationError]('Missing required parameter: index')
50
- return handleError(err, callback)
74
+ const err = new this[kConfigurationError]('Missing required parameter: index');
75
+ return handleError(err, callback);
51
76
  }
52
77
 
53
- let { method, body, id, index, type, ...querystring } = params
54
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
78
+ let { method, body, id, index, type, ...querystring } = params;
79
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
55
80
 
56
- let path = ''
57
- if ((index) != null && (type) != null && (id) != null) {
58
- if (method == null) method = 'GET'
59
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
81
+ let path = '';
82
+ if (index != null && type != null && id != null) {
83
+ if (method == null) method = 'GET';
84
+ path =
85
+ '/' +
86
+ encodeURIComponent(index) +
87
+ '/' +
88
+ encodeURIComponent(type) +
89
+ '/' +
90
+ encodeURIComponent(id) +
91
+ '/' +
92
+ '_source';
60
93
  } else {
61
- if (method == null) method = 'GET'
62
- path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id)
94
+ if (method == null) method = 'GET';
95
+ path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id);
63
96
  }
64
97
 
65
98
  // build request object
@@ -67,10 +100,10 @@ function getSourceApi (params, options, callback) {
67
100
  method,
68
101
  path,
69
102
  body: null,
70
- querystring
71
- }
103
+ querystring,
104
+ };
72
105
 
73
- return this.transport.request(request, options, callback)
106
+ return this.transport.request(request, options, callback);
74
107
  }
75
108
 
76
- module.exports = getSourceApi
109
+ module.exports = getSourceApi;
package/api/api/index.js CHANGED
@@ -28,44 +28,76 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
35
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['wait_for_active_shards', 'op_type', 'refresh', 'routing', 'timeout', 'version', 'version_type', 'if_seq_no', 'if_primary_term', 'pipeline', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { waitForActiveShards: 'wait_for_active_shards', opType: 'op_type', versionType: 'version_type', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' }
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
37
+ const acceptedQuerystring = [
38
+ 'wait_for_active_shards',
39
+ 'op_type',
40
+ 'refresh',
41
+ 'routing',
42
+ 'timeout',
43
+ 'version',
44
+ 'version_type',
45
+ 'if_seq_no',
46
+ 'if_primary_term',
47
+ 'pipeline',
48
+ 'require_alias',
49
+ 'pretty',
50
+ 'human',
51
+ 'error_trace',
52
+ 'source',
53
+ 'filter_path',
54
+ ];
55
+ const snakeCase = {
56
+ waitForActiveShards: 'wait_for_active_shards',
57
+ opType: 'op_type',
58
+ versionType: 'version_type',
59
+ ifSeqNo: 'if_seq_no',
60
+ ifPrimaryTerm: 'if_primary_term',
61
+ requireAlias: 'require_alias',
62
+ errorTrace: 'error_trace',
63
+ filterPath: 'filter_path',
64
+ };
39
65
 
40
- function indexApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
66
+ function indexApi(params, options, callback) {
67
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
68
 
43
69
  // check required parameters
44
70
  if (params.index == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: index')
46
- return handleError(err, callback)
71
+ const err = new this[kConfigurationError]('Missing required parameter: index');
72
+ return handleError(err, callback);
47
73
  }
48
74
  if (params.body == null) {
49
- const err = new this[kConfigurationError]('Missing required parameter: body')
50
- return handleError(err, callback)
75
+ const err = new this[kConfigurationError]('Missing required parameter: body');
76
+ return handleError(err, callback);
51
77
  }
52
78
 
53
- let { method, body, id, index, type, ...querystring } = params
54
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
79
+ let { method, body, id, index, type, ...querystring } = params;
80
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
55
81
 
56
- let path = ''
57
- if ((index) != null && (type) != null && (id) != null) {
58
- if (method == null) method = 'PUT'
59
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
60
- } else if ((index) != null && (id) != null) {
61
- if (method == null) method = 'PUT'
62
- path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
63
- } else if ((index) != null && (type) != null) {
64
- if (method == null) method = 'POST'
65
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type)
82
+ let path = '';
83
+ if (index != null && type != null && id != null) {
84
+ if (method == null) method = 'PUT';
85
+ path =
86
+ '/' +
87
+ encodeURIComponent(index) +
88
+ '/' +
89
+ encodeURIComponent(type) +
90
+ '/' +
91
+ encodeURIComponent(id);
92
+ } else if (index != null && id != null) {
93
+ if (method == null) method = 'PUT';
94
+ path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id);
95
+ } else if (index != null && type != null) {
96
+ if (method == null) method = 'POST';
97
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type);
66
98
  } else {
67
- if (method == null) method = 'POST'
68
- path = '/' + encodeURIComponent(index) + '/' + '_doc'
99
+ if (method == null) method = 'POST';
100
+ path = '/' + encodeURIComponent(index) + '/' + '_doc';
69
101
  }
70
102
 
71
103
  // build request object
@@ -73,10 +105,10 @@ function indexApi (params, options, callback) {
73
105
  method,
74
106
  path,
75
107
  body: body || '',
76
- querystring
77
- }
108
+ querystring,
109
+ };
78
110
 
79
- return this.transport.request(request, options, callback)
111
+ return this.transport.request(request, options, callback);
80
112
  }
81
113
 
82
- module.exports = indexApi
114
+ module.exports = indexApi;