@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,66 @@
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 = ['pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function renderSearchTemplateApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ let { method, body, id, ...querystring } = params
44
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
45
+
46
+ let path = ''
47
+ if ((id) != null) {
48
+ if (method == null) method = body == null ? 'GET' : 'POST'
49
+ path = '/' + '_render' + '/' + 'template' + '/' + encodeURIComponent(id)
50
+ } else {
51
+ if (method == null) method = body == null ? 'GET' : 'POST'
52
+ path = '/' + '_render' + '/' + 'template'
53
+ }
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
+ module.exports = renderSearchTemplateApi
@@ -0,0 +1,61 @@
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 = ['pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function scriptsPainlessExecuteApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ let { method, body, ...querystring } = params
44
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
45
+
46
+ let path = ''
47
+ if (method == null) method = body == null ? 'GET' : 'POST'
48
+ path = '/' + '_scripts' + '/' + 'painless' + '/' + '_execute'
49
+
50
+ // build request object
51
+ const request = {
52
+ method,
53
+ path,
54
+ body: body || '',
55
+ querystring
56
+ }
57
+
58
+ return this.transport.request(request, options, callback)
59
+ }
60
+
61
+ module.exports = scriptsPainlessExecuteApi
@@ -0,0 +1,66 @@
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 = ['scroll', 'scroll_id', 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { scrollId: 'scroll_id', restTotalHitsAsInt: 'rest_total_hits_as_int', errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function scrollApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ let { method, body, scrollId, scroll_id, ...querystring } = params
44
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
45
+
46
+ let path = ''
47
+ if ((scroll_id || scrollId) != null) {
48
+ if (method == null) method = body == null ? 'GET' : 'POST'
49
+ path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId)
50
+ } else {
51
+ if (method == null) method = body == null ? 'GET' : 'POST'
52
+ path = '/' + '_search' + '/' + 'scroll'
53
+ }
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
+ module.exports = scrollApi
@@ -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 = ['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' }
39
+
40
+ function searchApi (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) + '/' + '_search'
56
+ } else if ((index) != null) {
57
+ if (method == null) method = body == null ? 'GET' : 'POST'
58
+ path = '/' + encodeURIComponent(index) + '/' + '_search'
59
+ } else {
60
+ if (method == null) method = body == null ? 'GET' : 'POST'
61
+ path = '/' + '_search'
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 = searchApi
@@ -0,0 +1,66 @@
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 = ['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' }
39
+
40
+ function searchShardsApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ let { method, body, index, ...querystring } = params
44
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
45
+
46
+ let path = ''
47
+ if ((index) != null) {
48
+ if (method == null) method = body == null ? 'GET' : 'POST'
49
+ path = '/' + encodeURIComponent(index) + '/' + '_search_shards'
50
+ } else {
51
+ if (method == null) method = body == null ? 'GET' : 'POST'
52
+ path = '/' + '_search_shards'
53
+ }
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
+ module.exports = searchShardsApi
@@ -0,0 +1,81 @@
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', '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' }
39
+
40
+ function searchTemplateApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required parameters
44
+ if (params.body == null) {
45
+ const err = new this[kConfigurationError]('Missing required parameter: body')
46
+ return handleError(err, callback)
47
+ }
48
+
49
+ // 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)
53
+ }
54
+
55
+ let { method, body, index, type, ...querystring } = params
56
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
57
+
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'
65
+ } else {
66
+ if (method == null) method = body == null ? 'GET' : 'POST'
67
+ path = '/' + '_search' + '/' + 'template'
68
+ }
69
+
70
+ // build request object
71
+ const request = {
72
+ method,
73
+ path,
74
+ body: body || '',
75
+ querystring
76
+ }
77
+
78
+ return this.transport.request(request, options, callback)
79
+ }
80
+
81
+ module.exports = searchTemplateApi
@@ -0,0 +1,135 @@
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 = ['pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function ShutdownApi (transport, ConfigurationError) {
41
+ this.transport = transport
42
+ this[kConfigurationError] = ConfigurationError
43
+ }
44
+
45
+ ShutdownApi.prototype.deleteNode = function shutdownDeleteNodeApi (params, options, callback) {
46
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
47
+
48
+ // check required parameters
49
+ 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)
52
+ }
53
+
54
+ let { method, body, nodeId, node_id, ...querystring } = params
55
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
56
+
57
+ let path = ''
58
+ if (method == null) method = 'DELETE'
59
+ path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'shutdown'
60
+
61
+ // build request object
62
+ const request = {
63
+ method,
64
+ path,
65
+ body: body || '',
66
+ querystring
67
+ }
68
+
69
+ return this.transport.request(request, options, callback)
70
+ }
71
+
72
+ ShutdownApi.prototype.getNode = function shutdownGetNodeApi (params, options, callback) {
73
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
74
+
75
+ let { method, body, nodeId, node_id, ...querystring } = params
76
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
77
+
78
+ let path = ''
79
+ if ((node_id || nodeId) != null) {
80
+ if (method == null) method = 'GET'
81
+ path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'shutdown'
82
+ } else {
83
+ if (method == null) method = 'GET'
84
+ path = '/' + '_nodes' + '/' + 'shutdown'
85
+ }
86
+
87
+ // build request object
88
+ const request = {
89
+ method,
90
+ path,
91
+ body: null,
92
+ querystring
93
+ }
94
+
95
+ return this.transport.request(request, options, callback)
96
+ }
97
+
98
+ ShutdownApi.prototype.putNode = function shutdownPutNodeApi (params, options, callback) {
99
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
100
+
101
+ // check required parameters
102
+ 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)
105
+ }
106
+ if (params.body == null) {
107
+ const err = new this[kConfigurationError]('Missing required parameter: body')
108
+ return handleError(err, callback)
109
+ }
110
+
111
+ let { method, body, nodeId, node_id, ...querystring } = params
112
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
113
+
114
+ let path = ''
115
+ if (method == null) method = 'PUT'
116
+ path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'shutdown'
117
+
118
+ // build request object
119
+ const request = {
120
+ method,
121
+ path,
122
+ body: body || '',
123
+ querystring
124
+ }
125
+
126
+ return this.transport.request(request, options, callback)
127
+ }
128
+
129
+ 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