@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/search.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,37 +27,121 @@
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', 'ccs_minimize_roundtrips', 'default_operator', 'df', 'explain', 'stored_fields', 'docvalue_fields', 'from', 'ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'lenient', 'preference', 'q', 'routing', 'scroll', 'search_type', 'size', 'sort', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'terminate_after', 'stats', 'suggest_field', 'suggest_mode', 'suggest_size', 'suggest_text', 'timeout', 'track_scores', 'track_total_hits', 'allow_partial_search_results', 'typed_keys', 'version', 'seq_no_primary_term', 'request_cache', 'batched_reduce_size', 'max_concurrent_shard_requests', 'pre_filter_shard_size', 'rest_total_hits_as_int', 'min_compatible_shard_node', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { analyzeWildcard: 'analyze_wildcard', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', defaultOperator: 'default_operator', storedFields: 'stored_fields', docvalueFields: 'docvalue_fields', ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', terminateAfter: 'terminate_after', suggestField: 'suggest_field', suggestMode: 'suggest_mode', suggestSize: 'suggest_size', suggestText: 'suggest_text', trackScores: 'track_scores', trackTotalHits: 'track_total_hits', allowPartialSearchResults: 'allow_partial_search_results', typedKeys: 'typed_keys', seqNoPrimaryTerm: 'seq_no_primary_term', requestCache: 'request_cache', batchedReduceSize: 'batched_reduce_size', maxConcurrentShardRequests: 'max_concurrent_shard_requests', preFilterShardSize: 'pre_filter_shard_size', restTotalHitsAsInt: 'rest_total_hits_as_int', minCompatibleShardNode: 'min_compatible_shard_node', errorTrace: 'error_trace', filterPath: 'filter_path' }
35
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
+ const acceptedQuerystring = [
37
+ 'analyzer',
38
+ 'analyze_wildcard',
39
+ 'ccs_minimize_roundtrips',
40
+ 'default_operator',
41
+ 'df',
42
+ 'explain',
43
+ 'stored_fields',
44
+ 'docvalue_fields',
45
+ 'from',
46
+ 'ignore_unavailable',
47
+ 'ignore_throttled',
48
+ 'allow_no_indices',
49
+ 'expand_wildcards',
50
+ 'lenient',
51
+ 'preference',
52
+ 'q',
53
+ 'routing',
54
+ 'scroll',
55
+ 'search_type',
56
+ 'size',
57
+ 'sort',
58
+ '_source',
59
+ '_source_excludes',
60
+ '_source_exclude',
61
+ '_source_includes',
62
+ '_source_include',
63
+ 'terminate_after',
64
+ 'stats',
65
+ 'suggest_field',
66
+ 'suggest_mode',
67
+ 'suggest_size',
68
+ 'suggest_text',
69
+ 'timeout',
70
+ 'track_scores',
71
+ 'track_total_hits',
72
+ 'allow_partial_search_results',
73
+ 'typed_keys',
74
+ 'version',
75
+ 'seq_no_primary_term',
76
+ 'request_cache',
77
+ 'batched_reduce_size',
78
+ 'max_concurrent_shard_requests',
79
+ 'pre_filter_shard_size',
80
+ 'rest_total_hits_as_int',
81
+ 'min_compatible_shard_node',
82
+ 'pretty',
83
+ 'human',
84
+ 'error_trace',
85
+ 'source',
86
+ 'filter_path',
87
+ ];
88
+ const snakeCase = {
89
+ analyzeWildcard: 'analyze_wildcard',
90
+ ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips',
91
+ defaultOperator: 'default_operator',
92
+ storedFields: 'stored_fields',
93
+ docvalueFields: 'docvalue_fields',
94
+ ignoreUnavailable: 'ignore_unavailable',
95
+ ignoreThrottled: 'ignore_throttled',
96
+ allowNoIndices: 'allow_no_indices',
97
+ expandWildcards: 'expand_wildcards',
98
+ searchType: 'search_type',
99
+ _sourceExcludes: '_source_excludes',
100
+ _sourceExclude: '_source_exclude',
101
+ _sourceIncludes: '_source_includes',
102
+ _sourceInclude: '_source_include',
103
+ terminateAfter: 'terminate_after',
104
+ suggestField: 'suggest_field',
105
+ suggestMode: 'suggest_mode',
106
+ suggestSize: 'suggest_size',
107
+ suggestText: 'suggest_text',
108
+ trackScores: 'track_scores',
109
+ trackTotalHits: 'track_total_hits',
110
+ allowPartialSearchResults: 'allow_partial_search_results',
111
+ typedKeys: 'typed_keys',
112
+ seqNoPrimaryTerm: 'seq_no_primary_term',
113
+ requestCache: 'request_cache',
114
+ batchedReduceSize: 'batched_reduce_size',
115
+ maxConcurrentShardRequests: 'max_concurrent_shard_requests',
116
+ preFilterShardSize: 'pre_filter_shard_size',
117
+ restTotalHitsAsInt: 'rest_total_hits_as_int',
118
+ minCompatibleShardNode: 'min_compatible_shard_node',
119
+ errorTrace: 'error_trace',
120
+ filterPath: 'filter_path',
121
+ };
39
122
 
40
- function searchApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
123
+ function searchApi(params, options, callback) {
124
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
125
 
43
126
  // 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)
127
+ if (params.type != null && params.index == null) {
128
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index');
129
+ return handleError(err, callback);
47
130
  }
48
131
 
49
- let { method, body, index, type, ...querystring } = params
50
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
132
+ let { method, body, index, type, ...querystring } = params;
133
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
51
134
 
52
- let path = ''
53
- if ((index) != null && (type) != null) {
54
- if (method == null) method = body == null ? 'GET' : 'POST'
55
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search'
56
- } else if ((index) != null) {
57
- if (method == null) method = body == null ? 'GET' : 'POST'
58
- path = '/' + encodeURIComponent(index) + '/' + '_search'
135
+ let path = '';
136
+ if (index != null && type != null) {
137
+ if (method == null) method = body == null ? 'GET' : 'POST';
138
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search';
139
+ } else if (index != null) {
140
+ if (method == null) method = body == null ? 'GET' : 'POST';
141
+ path = '/' + encodeURIComponent(index) + '/' + '_search';
59
142
  } else {
60
- if (method == null) method = body == null ? 'GET' : 'POST'
61
- path = '/' + '_search'
143
+ if (method == null) method = body == null ? 'GET' : 'POST';
144
+ path = '/' + '_search';
62
145
  }
63
146
 
64
147
  // build request object
@@ -66,10 +149,10 @@ function searchApi (params, options, callback) {
66
149
  method,
67
150
  path,
68
151
  body: body || '',
69
- querystring
70
- }
152
+ querystring,
153
+ };
71
154
 
72
- return this.transport.request(request, options, callback)
155
+ return this.transport.request(request, options, callback);
73
156
  }
74
157
 
75
- module.exports = searchApi
158
+ module.exports = searchApi;
@@ -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,28 +27,46 @@
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 = ['preference', 'routing', 'local', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path' }
35
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
+ const acceptedQuerystring = [
37
+ 'preference',
38
+ 'routing',
39
+ 'local',
40
+ 'ignore_unavailable',
41
+ 'allow_no_indices',
42
+ 'expand_wildcards',
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
+ errorTrace: 'error_trace',
54
+ filterPath: 'filter_path',
55
+ };
39
56
 
40
- function searchShardsApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
57
+ function searchShardsApi(params, options, callback) {
58
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
59
 
43
- let { method, body, index, ...querystring } = params
44
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
60
+ let { method, body, index, ...querystring } = params;
61
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
45
62
 
46
- let path = ''
47
- if ((index) != null) {
48
- if (method == null) method = body == null ? 'GET' : 'POST'
49
- path = '/' + encodeURIComponent(index) + '/' + '_search_shards'
63
+ let path = '';
64
+ if (index != null) {
65
+ if (method == null) method = body == null ? 'GET' : 'POST';
66
+ path = '/' + encodeURIComponent(index) + '/' + '_search_shards';
50
67
  } else {
51
- if (method == null) method = body == null ? 'GET' : 'POST'
52
- path = '/' + '_search_shards'
68
+ if (method == null) method = body == null ? 'GET' : 'POST';
69
+ path = '/' + '_search_shards';
53
70
  }
54
71
 
55
72
  // build request object
@@ -57,10 +74,10 @@ function searchShardsApi (params, options, callback) {
57
74
  method,
58
75
  path,
59
76
  body: body || '',
60
- querystring
61
- }
77
+ querystring,
78
+ };
62
79
 
63
- return this.transport.request(request, options, callback)
80
+ return this.transport.request(request, options, callback);
64
81
  }
65
82
 
66
- module.exports = searchShardsApi
83
+ module.exports = searchShardsApi;
@@ -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,43 +27,81 @@
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 = ['ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'preference', 'routing', 'scroll', 'search_type', 'explain', 'profile', 'typed_keys', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', typedKeys: 'typed_keys', restTotalHitsAsInt: 'rest_total_hits_as_int', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' }
35
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
+ const acceptedQuerystring = [
37
+ 'ignore_unavailable',
38
+ 'ignore_throttled',
39
+ 'allow_no_indices',
40
+ 'expand_wildcards',
41
+ 'preference',
42
+ 'routing',
43
+ 'scroll',
44
+ 'search_type',
45
+ 'explain',
46
+ 'profile',
47
+ 'typed_keys',
48
+ 'rest_total_hits_as_int',
49
+ 'ccs_minimize_roundtrips',
50
+ 'pretty',
51
+ 'human',
52
+ 'error_trace',
53
+ 'source',
54
+ 'filter_path',
55
+ ];
56
+ const snakeCase = {
57
+ ignoreUnavailable: 'ignore_unavailable',
58
+ ignoreThrottled: 'ignore_throttled',
59
+ allowNoIndices: 'allow_no_indices',
60
+ expandWildcards: 'expand_wildcards',
61
+ searchType: 'search_type',
62
+ typedKeys: 'typed_keys',
63
+ restTotalHitsAsInt: 'rest_total_hits_as_int',
64
+ ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips',
65
+ errorTrace: 'error_trace',
66
+ filterPath: 'filter_path',
67
+ };
39
68
 
40
- function searchTemplateApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
69
+ function searchTemplateApi(params, options, callback) {
70
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
71
 
43
72
  // check required parameters
44
73
  if (params.body == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: body')
46
- return handleError(err, callback)
74
+ const err = new this[kConfigurationError]('Missing required parameter: body');
75
+ return handleError(err, callback);
47
76
  }
48
77
 
49
78
  // 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)
79
+ if (params.type != null && params.index == null) {
80
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index');
81
+ return handleError(err, callback);
53
82
  }
54
83
 
55
- let { method, body, index, type, ...querystring } = params
56
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
84
+ let { method, body, index, type, ...querystring } = params;
85
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
57
86
 
58
- let path = ''
59
- if ((index) != null && (type) != null) {
60
- if (method == null) method = body == null ? 'GET' : 'POST'
61
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + '/' + 'template'
62
- } else if ((index) != null) {
63
- if (method == null) method = body == null ? 'GET' : 'POST'
64
- path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template'
87
+ let path = '';
88
+ if (index != null && type != null) {
89
+ if (method == null) method = body == null ? 'GET' : 'POST';
90
+ path =
91
+ '/' +
92
+ encodeURIComponent(index) +
93
+ '/' +
94
+ encodeURIComponent(type) +
95
+ '/' +
96
+ '_search' +
97
+ '/' +
98
+ 'template';
99
+ } else if (index != null) {
100
+ if (method == null) method = body == null ? 'GET' : 'POST';
101
+ path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template';
65
102
  } else {
66
- if (method == null) method = body == null ? 'GET' : 'POST'
67
- path = '/' + '_search' + '/' + 'template'
103
+ if (method == null) method = body == null ? 'GET' : 'POST';
104
+ path = '/' + '_search' + '/' + 'template';
68
105
  }
69
106
 
70
107
  // build request object
@@ -72,10 +109,10 @@ function searchTemplateApi (params, options, callback) {
72
109
  method,
73
110
  path,
74
111
  body: body || '',
75
- querystring
76
- }
112
+ querystring,
113
+ };
77
114
 
78
- return this.transport.request(request, options, callback)
115
+ return this.transport.request(request, options, callback);
79
116
  }
80
117
 
81
- module.exports = searchTemplateApi
118
+ module.exports = searchTemplateApi;
@@ -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,60 +27,60 @@
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 ShutdownApi (transport, ConfigurationError) {
41
- this.transport = transport
42
- this[kConfigurationError] = ConfigurationError
39
+ function ShutdownApi(transport, ConfigurationError) {
40
+ this.transport = transport;
41
+ this[kConfigurationError] = ConfigurationError;
43
42
  }
44
43
 
45
- ShutdownApi.prototype.deleteNode = function shutdownDeleteNodeApi (params, options, callback) {
46
- ;[params, options, callback] = normalizeArguments(params, options, callback)
44
+ ShutdownApi.prototype.deleteNode = function shutdownDeleteNodeApi(params, options, callback) {
45
+ [params, options, callback] = normalizeArguments(params, options, callback);
47
46
 
48
47
  // check required parameters
49
48
  if (params.node_id == null && params.nodeId == null) {
50
- const err = new this[kConfigurationError]('Missing required parameter: node_id or nodeId')
51
- return handleError(err, callback)
49
+ const err = new this[kConfigurationError]('Missing required parameter: node_id or nodeId');
50
+ return handleError(err, callback);
52
51
  }
53
52
 
54
- let { method, body, nodeId, node_id, ...querystring } = params
55
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
53
+ let { method, body, nodeId, node_id, ...querystring } = params;
54
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
56
55
 
57
- let path = ''
58
- if (method == null) method = 'DELETE'
59
- path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'shutdown'
56
+ let path = '';
57
+ if (method == null) method = 'DELETE';
58
+ path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'shutdown';
60
59
 
61
60
  // build request object
62
61
  const request = {
63
62
  method,
64
63
  path,
65
64
  body: body || '',
66
- querystring
67
- }
65
+ querystring,
66
+ };
68
67
 
69
- return this.transport.request(request, options, callback)
70
- }
68
+ return this.transport.request(request, options, callback);
69
+ };
71
70
 
72
- ShutdownApi.prototype.getNode = function shutdownGetNodeApi (params, options, callback) {
73
- ;[params, options, callback] = normalizeArguments(params, options, callback)
71
+ ShutdownApi.prototype.getNode = function shutdownGetNodeApi(params, options, callback) {
72
+ [params, options, callback] = normalizeArguments(params, options, callback);
74
73
 
75
- let { method, body, nodeId, node_id, ...querystring } = params
76
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
74
+ let { method, body, nodeId, node_id, ...querystring } = params;
75
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
77
76
 
78
- let path = ''
77
+ let path = '';
79
78
  if ((node_id || nodeId) != null) {
80
- if (method == null) method = 'GET'
81
- path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'shutdown'
79
+ if (method == null) method = 'GET';
80
+ path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'shutdown';
82
81
  } else {
83
- if (method == null) method = 'GET'
84
- path = '/' + '_nodes' + '/' + 'shutdown'
82
+ if (method == null) method = 'GET';
83
+ path = '/' + '_nodes' + '/' + 'shutdown';
85
84
  }
86
85
 
87
86
  // build request object
@@ -89,47 +88,59 @@ ShutdownApi.prototype.getNode = function shutdownGetNodeApi (params, options, ca
89
88
  method,
90
89
  path,
91
90
  body: null,
92
- querystring
93
- }
91
+ querystring,
92
+ };
94
93
 
95
- return this.transport.request(request, options, callback)
96
- }
94
+ return this.transport.request(request, options, callback);
95
+ };
97
96
 
98
- ShutdownApi.prototype.putNode = function shutdownPutNodeApi (params, options, callback) {
99
- ;[params, options, callback] = normalizeArguments(params, options, callback)
97
+ ShutdownApi.prototype.putNode = function shutdownPutNodeApi(params, options, callback) {
98
+ [params, options, callback] = normalizeArguments(params, options, callback);
100
99
 
101
100
  // check required parameters
102
101
  if (params.node_id == null && params.nodeId == null) {
103
- const err = new this[kConfigurationError]('Missing required parameter: node_id or nodeId')
104
- return handleError(err, callback)
102
+ const err = new this[kConfigurationError]('Missing required parameter: node_id or nodeId');
103
+ return handleError(err, callback);
105
104
  }
106
105
  if (params.body == null) {
107
- const err = new this[kConfigurationError]('Missing required parameter: body')
108
- return handleError(err, callback)
106
+ const err = new this[kConfigurationError]('Missing required parameter: body');
107
+ return handleError(err, callback);
109
108
  }
110
109
 
111
- let { method, body, nodeId, node_id, ...querystring } = params
112
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
110
+ let { method, body, nodeId, node_id, ...querystring } = params;
111
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
113
112
 
114
- let path = ''
115
- if (method == null) method = 'PUT'
116
- path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'shutdown'
113
+ let path = '';
114
+ if (method == null) method = 'PUT';
115
+ path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'shutdown';
117
116
 
118
117
  // build request object
119
118
  const request = {
120
119
  method,
121
120
  path,
122
121
  body: body || '',
123
- querystring
124
- }
122
+ querystring,
123
+ };
125
124
 
126
- return this.transport.request(request, options, callback)
127
- }
125
+ return this.transport.request(request, options, callback);
126
+ };
128
127
 
129
128
  Object.defineProperties(ShutdownApi.prototype, {
130
- delete_node: { get () { return this.deleteNode } },
131
- get_node: { get () { return this.getNode } },
132
- put_node: { get () { return this.putNode } }
133
- })
134
-
135
- module.exports = ShutdownApi
129
+ delete_node: {
130
+ get() {
131
+ return this.deleteNode;
132
+ },
133
+ },
134
+ get_node: {
135
+ get() {
136
+ return this.getNode;
137
+ },
138
+ },
139
+ put_node: {
140
+ get() {
141
+ return this.putNode;
142
+ },
143
+ },
144
+ });
145
+
146
+ module.exports = ShutdownApi;