@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,92 @@
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 = ['master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function FeaturesApi (transport, ConfigurationError) {
41
+ this.transport = transport
42
+ this[kConfigurationError] = ConfigurationError
43
+ }
44
+
45
+ FeaturesApi.prototype.getFeatures = function featuresGetFeaturesApi (params, options, callback) {
46
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
47
+
48
+ let { method, body, ...querystring } = params
49
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
50
+
51
+ let path = ''
52
+ if (method == null) method = 'GET'
53
+ path = '/' + '_features'
54
+
55
+ // build request object
56
+ const request = {
57
+ method,
58
+ path,
59
+ body: null,
60
+ querystring
61
+ }
62
+
63
+ return this.transport.request(request, options, callback)
64
+ }
65
+
66
+ FeaturesApi.prototype.resetFeatures = function featuresResetFeaturesApi (params, options, callback) {
67
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
68
+
69
+ let { method, body, ...querystring } = params
70
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
71
+
72
+ let path = ''
73
+ if (method == null) method = 'POST'
74
+ path = '/' + '_features' + '/' + '_reset'
75
+
76
+ // build request object
77
+ const request = {
78
+ method,
79
+ path,
80
+ body: body || '',
81
+ querystring
82
+ }
83
+
84
+ return this.transport.request(request, options, callback)
85
+ }
86
+
87
+ Object.defineProperties(FeaturesApi.prototype, {
88
+ get_features: { get () { return this.getFeatures } },
89
+ reset_features: { get () { return this.resetFeatures } }
90
+ })
91
+
92
+ module.exports = FeaturesApi
@@ -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 = ['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' }
39
+
40
+ function fieldCapsApi (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) + '/' + '_field_caps'
50
+ } else {
51
+ if (method == null) method = body == null ? 'GET' : 'POST'
52
+ path = '/' + '_field_caps'
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 = fieldCapsApi
package/api/api/get.js ADDED
@@ -0,0 +1,76 @@
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 = ['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' }
39
+
40
+ function getApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required parameters
44
+ if (params.id == null) {
45
+ const err = new this[kConfigurationError]('Missing required parameter: id')
46
+ return handleError(err, callback)
47
+ }
48
+ if (params.index == null) {
49
+ const err = new this[kConfigurationError]('Missing required parameter: index')
50
+ return handleError(err, callback)
51
+ }
52
+
53
+ let { method, body, id, index, type, ...querystring } = params
54
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
55
+
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)
60
+ } else {
61
+ if (method == null) method = 'GET'
62
+ path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
63
+ }
64
+
65
+ // build request object
66
+ const request = {
67
+ method,
68
+ path,
69
+ body: null,
70
+ querystring
71
+ }
72
+
73
+ return this.transport.request(request, options, callback)
74
+ }
75
+
76
+ module.exports = getApi
@@ -0,0 +1,67 @@
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 = ['master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function getScriptApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required parameters
44
+ if (params.id == null) {
45
+ const err = new this[kConfigurationError]('Missing required parameter: id')
46
+ return handleError(err, callback)
47
+ }
48
+
49
+ let { method, body, id, ...querystring } = params
50
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
51
+
52
+ let path = ''
53
+ if (method == null) method = 'GET'
54
+ path = '/' + '_scripts' + '/' + encodeURIComponent(id)
55
+
56
+ // build request object
57
+ const request = {
58
+ method,
59
+ path,
60
+ body: null,
61
+ querystring
62
+ }
63
+
64
+ return this.transport.request(request, options, callback)
65
+ }
66
+
67
+ module.exports = getScriptApi
@@ -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 getScriptContextApi (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 = 'GET'
48
+ path = '/' + '_script_context'
49
+
50
+ // build request object
51
+ const request = {
52
+ method,
53
+ path,
54
+ body: null,
55
+ querystring
56
+ }
57
+
58
+ return this.transport.request(request, options, callback)
59
+ }
60
+
61
+ module.exports = getScriptContextApi
@@ -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 getScriptLanguagesApi (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 = 'GET'
48
+ path = '/' + '_script_language'
49
+
50
+ // build request object
51
+ const request = {
52
+ method,
53
+ path,
54
+ body: null,
55
+ querystring
56
+ }
57
+
58
+ return this.transport.request(request, options, callback)
59
+ }
60
+
61
+ module.exports = getScriptLanguagesApi
@@ -0,0 +1,76 @@
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', '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' }
39
+
40
+ function getSourceApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required parameters
44
+ if (params.id == null) {
45
+ const err = new this[kConfigurationError]('Missing required parameter: id')
46
+ return handleError(err, callback)
47
+ }
48
+ if (params.index == null) {
49
+ const err = new this[kConfigurationError]('Missing required parameter: index')
50
+ return handleError(err, callback)
51
+ }
52
+
53
+ let { method, body, id, index, type, ...querystring } = params
54
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
55
+
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'
60
+ } else {
61
+ if (method == null) method = 'GET'
62
+ path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id)
63
+ }
64
+
65
+ // build request object
66
+ const request = {
67
+ method,
68
+ path,
69
+ body: null,
70
+ querystring
71
+ }
72
+
73
+ return this.transport.request(request, options, callback)
74
+ }
75
+
76
+ module.exports = getSourceApi
@@ -0,0 +1,82 @@
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ *
4
+ * The OpenSearch Contributors require contributions made to
5
+ * this file be licensed under the Apache-2.0 license or a
6
+ * compatible open source license.
7
+ *
8
+ * Modifications Copyright OpenSearch Contributors. See
9
+ * GitHub history for details.
10
+ */
11
+
12
+ /*
13
+ * Licensed to Elasticsearch B.V. under one or more contributor
14
+ * license agreements. See the NOTICE file distributed with
15
+ * this work for additional information regarding copyright
16
+ * ownership. Elasticsearch B.V. licenses this file to you under
17
+ * the Apache License, Version 2.0 (the "License"); you may
18
+ * not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing,
24
+ * software distributed under the License is distributed on an
25
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ * KIND, either express or implied. See the License for the
27
+ * specific language governing permissions and limitations
28
+ * under the License.
29
+ */
30
+
31
+ 'use strict'
32
+
33
+ /* eslint camelcase: 0 */
34
+ /* eslint no-unused-vars: 0 */
35
+
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
+ const acceptedQuerystring = ['wait_for_active_shards', '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' }
39
+
40
+ function indexApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required parameters
44
+ if (params.index == null) {
45
+ const err = new this[kConfigurationError]('Missing required parameter: index')
46
+ return handleError(err, callback)
47
+ }
48
+ if (params.body == null) {
49
+ const err = new this[kConfigurationError]('Missing required parameter: body')
50
+ return handleError(err, callback)
51
+ }
52
+
53
+ let { method, body, id, index, type, ...querystring } = params
54
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
55
+
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)
66
+ } else {
67
+ if (method == null) method = 'POST'
68
+ path = '/' + encodeURIComponent(index) + '/' + '_doc'
69
+ }
70
+
71
+ // build request object
72
+ const request = {
73
+ method,
74
+ path,
75
+ body: body || '',
76
+ querystring
77
+ }
78
+
79
+ return this.transport.request(request, options, callback)
80
+ }
81
+
82
+ module.exports = indexApi