Compare commits

...

162 Commits
5.x ... v7.7.0

Author SHA1 Message Date
c343302772 [Backport 7.x] Fix 1153 (#1161) 2020-05-14 09:57:44 +02:00
f9f5d91332 Bumped v7.7.0 2020-05-14 09:56:36 +02:00
51169d5efa Support for Elasticsearch 7.7 (#1192) 2020-05-14 09:55:54 +02:00
be6257380e Add Node.js v14 to test matrix (#1172) 2020-04-23 16:53:40 +02:00
5555ea5c7b [Backport 7.x] Added testing documentation (#1151)
* Added testing documentation

* Fix title

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
2020-04-10 17:38:02 +02:00
e2c68a0bd0 Run workflow also on community pull requests 2020-04-03 09:07:05 +02:00
a28f9c36e4 Bumped v7.6.1 2020-03-13 14:48:25 +01:00
a9a905409e [Backport 7.x] ApiKey should take precedence over basic auth (#1117)
* ApiKey should take precedence over basic auth

* Updated docs

* Updated test

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
2020-03-13 13:41:57 +01:00
ca23e0b23a [Backport 7.x] Secure json parsing (#1113)
* Safe json parsing

* Updated test

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
2020-03-13 09:29:40 +01:00
db67c526e4 API generation 2020-03-11 19:12:21 +01:00
cf5f3c55e0 typo (#1109) 2020-03-11 19:10:32 +01:00
d18f877c77 [DOCS] Fixes out-dated monitoring links (#1096) 2020-03-11 19:10:25 +01:00
917a4e338f Updated api reference header comment (#1049) 2020-03-11 19:07:45 +01:00
9852906c23 Migrate to GitHub Actions (#1104)
* Create nodejs.yml

* Run only on push

* Renamed jobs

* Removed .travis.yml

* Split coverage job and cleanup

* Skip flaky test

* Code coverage reporting

* Renamed codecov file

* Added backport action

* Updated integration test configuration

* Removed unused dependencies

* Fixes
2020-03-10 09:12:30 +01:00
711625edf2 Updates .ci folder to latest incarnation (#1103)
* Updates .ci folder to latest incarnation

The .ci folder cleanup some of its cleanup/wait routines so that they
can be reused. It also significantly reduced the available environment
variable toggles. In lieu of those toggles `run-repository.sh` can now
start multiple nodes using `NUMBER_OF_NODES`

* update certs
2020-03-10 09:12:28 +01:00
372f91c76d Updated LICENSE 2020-03-04 11:04:14 +01:00
53e29db80e Bumped v7.6.0 2020-02-12 14:01:09 +01:00
8bd5c4c4ce Support for Elasticsearch 7.6 (#1075) 2020-02-12 11:17:56 +01:00
d19313a72c Update integration test runner (#1085)
* Improved user and roles handling

* Avoid deleting internal indices

* Updated skip version handling

* Fix leftover

* Improved indices and aliases cleanup

* Clean also internal indices

* Restore previous index/alias cleanup

* Ignore 404
2020-02-11 10:51:08 +01:00
874b04f819 Added integration test stats (#1083) 2020-02-06 12:11:14 +01:00
a91e5375ac Fix link 2020-02-04 12:10:02 +01:00
b99654602a API generation 2020-02-04 11:03:15 +01:00
733070963b Added new examples (#1031)
* Added new examples

* Fixed examples links
2020-02-04 11:02:40 +01:00
726d1824bd Bumped v7.5.1 2020-02-04 11:00:57 +01:00
e94eefe8a2 API generation 2020-02-04 10:36:58 +01:00
cd61e30bb3 Add examples to reference (#1076)
* Updated examples urls

* Added links to examples

* Updated docs generation script to include code examples

* Fixes

* Skip index api

* Fix link

* Fix url generation

* API generation

* Fix new line

* API generation

* Fix leftover

* API generation
2020-02-04 10:35:59 +01:00
21683e6826 Skip compression in case of empty string body (#1080)
* Fix #1069

* Updated test

* Updated test
2020-02-04 10:30:49 +01:00
647546a4e5 Merge branch '7.x' of https://github.com/elastic/elasticsearch-js into 7.x 2020-02-04 10:30:03 +01:00
1a6c36e291 Fix typo in NoLivingConnectionsError (#1045)
Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
2020-02-04 10:29:59 +01:00
a34c6dd3a7 [7.x][DOCS] Fine-tunes the Node.Js client Typescript and examples sections. (#1079) 2020-02-03 17:24:28 +01:00
2a59c634f7 Move to latest .ci script structure (#1042)
Introduces a dedicated `run-repository.sh` for the repository custom
bits.

This allows us to keep `run-elasticsearch.sh` and `run-tests` in sync
through file copying or patches easier.

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
2020-01-31 12:00:35 +01:00
2d9bfd6730 [7.x][DOCS] Fine-tunes the Node.Js client extend the client sec… (#1065) 2020-01-29 18:09:15 +01:00
68730dc0e6 Renamed log skip function (#1061) 2020-01-23 09:24:54 +01:00
0f60d78e5d Improve integration test execution time (#1005)
* Integration test: Add limit of 3 minutes per yaml file

* Monitor all test files that take more than 1m to execute

* Set the threshold to 30s

* Refactored integration test runner

* Better time reporting

* Updated test time limits

* Updated CI script

* Run oss only in oss build

* Run only oss test

* Revert "Run only oss test"

This reverts commit fd3a07d42d.
2020-01-23 08:31:38 +01:00
0455b76fb8 [7.x][DOCS] Fine-tunes the Node.Js client observability section (#1056) 2020-01-16 14:31:29 +01:00
63a68fb615 [7.x][DOCS] Fine-tunes the Node.Js client child client section (#1058) 2020-01-16 14:30:28 +01:00
d58365eb70 Change TransportRequestOptions.ignore to number[] (#1053) 2020-01-15 18:25:41 +01:00
51568ed505 ClientOptions["cloud"] should have optional auth fields (#1032) 2020-01-07 12:09:42 +01:00
be7c9f5e9d Return super in example Transport subclass (#980)
If called without a callback, the request method returns a Promise, so
when calling into super.request, the result should be returned to
maintain promise behavior.
2019-12-19 13:37:35 +01:00
35b03aed17 [7.x][DOCS] Fine-tunes the Node.Js client authentication section. (#1018) 2019-12-13 09:30:46 +01:00
c51fbfaafd [7.x][DOCS] Fine-tunes the Node.Js client breaking changes section. (#1013) 2019-12-05 13:20:56 +01:00
95847f030c Bumped v7.5.0 2019-12-03 14:32:55 +01:00
c0000aa207 Support for Elasticsearch 7.5 (#1015)
* API generation

* X-Opaque-Id support (#997)

* Added X-Opaque-Id support

* Updated type definitions

* Updated test

* Updated docs

* Skip data_frame_transform_deprecated.* apis

* API generation

* Fix docs link

* Fix CI configuration

* Added enrich_user to default roles

* Added transform_admin ad transform_user to default roles
2019-12-03 14:31:59 +01:00
da7220ad8a [7.x][DOCS] Fine-tunes the Node.js client API reference section. (#1007) 2019-11-25 16:01:47 +01:00
b52b96b95e Merge branch '7.x' of https://github.com/elastic/elasticsearch-js into 7.x 2019-11-22 20:29:58 +01:00
79c9c8e03c Removed ml api from reference.asciidoc to fix CI in https://github.com/elastic/elasticsearch/pull/49504 2019-11-22 20:29:42 +01:00
0e1f526f55 [7.x][DOCS] Fine-tunes the Node.js client configuration section (#999) 2019-10-30 14:45:42 +01:00
a4460b719d Use ES 7.4.0 2019-10-28 14:51:29 +01:00
44698e5b44 Removed mbp job 2019-10-28 14:45:44 +01:00
077a13e39d Updated jobs/defaults.yml to use the new job matrix 2019-10-28 14:44:35 +01:00
ed8caabf69 New CI configuration (#996)
* Removed old files

* Updated README

* New CI configuration

* Updated run-test script
2019-10-28 14:44:23 +01:00
c30e4cdb95 Move back to jjbb (#995)
* Removed Jenkins pipelines configuration

* Restored jjbb definitions
2019-10-28 14:42:23 +01:00
3eac66e47a [7.x] [DOCS] Fine-tunes the Node.js client usage section (#989)
* [DOCS] Fine-tunes the Node.js client introduction (#985)

* Revert "[DOCS] Fine-tunes the Node.js client introduction (#985)"

This reverts commit 8d08bb9665.

* [7.x] [DOCS] Fine-tunes the Node.js client usage section.
2019-10-15 15:10:41 +02:00
2e9825808f [7.x] [DOCS] Fine-tunes the Node.js client introduction (#986) 2019-10-11 09:59:15 +02:00
7f7635a44b Bumped v7.4.0 2019-10-02 11:19:12 +02:00
7472c5ee94 Support for Elasticsearch 7.4 (#979)
* Update code generation (#969)

* Updated code generation scripts to use the new spec

* API generation

* Fix bad link

* Updated API reference doc (#945)

* Updated API reference doc

* Updated docs script

* Fix issue; node roles are defaulting to true when undefined (fal… (#967)

* Fix issue; nodeFilter was unable to filter because master, data, and ingest role were true if even they were false on the node.

* Test nodesToHost of BaseConnectionPool correctly maps node roles

* API generation

* Docker: use 7.4-SNAPSHOT

* API generation

* Use 7.4 stable
2019-10-02 11:17:32 +02:00
69805d8393 [7.x] [DOCS] Update docs for 'synced flush' and 'SLM' APIs (#972) (#976) 2019-09-28 16:19:19 +02:00
6d8544dff2 Fix inaccurate description sniffEndpoint (#959) 2019-09-16 17:42:05 +02:00
b056f7d796 Add body and querystring to RequestOptions (#957) 2019-09-11 11:30:28 +02:00
1e3bdc68f8 Updated cron job definition (#939)
* Updated cron job definition

* Update .ci/Jenkinsfile

Co-Authored-By: Victor Martinez <victormartinezrubio@gmail.com>
2019-08-13 10:55:24 +02:00
c790fae5f1 Updated .travis.yml (#938) 2019-08-09 14:08:20 +02:00
8d4aa038be Use Jenkins pipelines (#937) 2019-08-09 12:13:27 +02:00
e371bd2d5e Disable travis cache (#929) 2019-08-02 11:49:53 +02:00
5f0d0fd8db Updated error handling in bulk example (#927) 2019-08-01 12:20:56 +02:00
75d58a895f Bumped v7.3.0 2019-08-01 10:12:55 +02:00
74f933a2a6 API generation 2019-08-01 10:10:05 +02:00
8c78f47ac3 Support for Elasticsearch 7.3 (#928) 2019-08-01 10:09:16 +02:00
823c209c32 API generation 2019-07-25 11:14:14 +02:00
6ec653e7ac Better reference code examples (#920)
* Updated documentation genertation script to build small code snippets

* Updated docs reference

* Removed slm doc

* Add commas and remove empty objects
2019-07-25 11:13:12 +02:00
29ad0735c2 Updated automatically the main typings file with the generated t… (#919)
* Updated automatically the main typings file with the generated types

* Removed useless log
2019-07-25 11:12:32 +02:00
f74123fb53 fix(Typings): sniffInterval can also be boolean (#914) 2019-07-22 10:40:22 +02:00
f10d55f32d Updated test matrix 2019-07-17 18:40:11 +02:00
2ceb04697b Fix typo in comments (#912) 2019-07-17 17:05:16 +02:00
4d5a79cae0 Improve README (#909)
* Updated README

* Updated asciidoc intro

* Updated intro title

* Update README.md

Co-Authored-By: Lisa Cawley <lcawley@elastic.co>

* Update README.md

Co-Authored-By: Lisa Cawley <lcawley@elastic.co>

* Update README.md

Co-Authored-By: Lisa Cawley <lcawley@elastic.co>

* Update README.md

Co-Authored-By: Lisa Cawley <lcawley@elastic.co>

* Update README.md

Co-Authored-By: Lisa Cawley <lcawley@elastic.co>

* Update docs/introduction.asciidoc

Co-Authored-By: Lisa Cawley <lcawley@elastic.co>

* Update docs/introduction.asciidoc

Co-Authored-By: Lisa Cawley <lcawley@elastic.co>

* Updated asciidoc intro
2019-07-17 10:30:13 +02:00
52416cd072 Added support for arbitrary_key (#910) 2019-07-16 12:21:39 +02:00
eb069b10a2 Update deepmerge requirement from ^3.2.0 to ^4.0.0 (#898) 2019-07-15 16:54:31 +02:00
715aee4dd1 Update tap requirement from ^13.0.1 to ^14.4.1 (#900) 2019-07-15 16:54:31 +02:00
94679a2001 Update @types/node requirement from ^11.13.7 to ^12.6.2 (#899) 2019-07-15 16:54:31 +02:00
0df026d3ff Update standard requirement from ^12.0.1 to ^13.0.2 (#906) 2019-07-15 16:54:31 +02:00
33ad918e2e Merge branch '7.x' of https://github.com/elastic/elasticsearch-js into 7.x 2019-07-10 15:48:09 +02:00
af8f3feaf9 Improve integration test (#859)
* CI: Added junit plugin

* Updated .gitignore

* Added integration test reporter

* Updated integration testing suite

* Updated ci config

* Updated report file path

* Use refresh 'true' instead of 'wait_for'

* Disable junit reporting

* Refresh one single time

* Update security index name

* Updated skip test handling and use class syntax

* Updated test script

* Disable test timeout

* Added command to automatically remove an old snapshot

* Disable timeout in integration test script

* Updated logs and cleaned up git handling

* Fixed shouldSkip utility

* Updated cleanup code

* Updated cleanup code pt 2

* Rename Platinum to XPack
2019-07-10 15:47:57 +02:00
63c62b6b68 Updated travis configuration (#894)
* Updated travis configuration

* Run license checker only in Linux

* Fixed script

* Fix windows test
2019-07-08 16:30:15 +02:00
3942ed722c Bumped v7.2.0 2019-07-05 11:39:08 +02:00
2e62e4ac58 Merge branch '7.x' of https://github.com/elastic/elasticsearch-js into 7.x 2019-07-04 14:43:15 +02:00
060d4ae5fc Remove auth data from inspect and toJSON in connection class (#887)
* Remove auth data from inspect and toJSON in connection class

* Updated test
2019-07-04 14:43:01 +02:00
b0861fae0d Support for 7.2 (#884)
* API generation

* Add 7.2.0 to testing matrix

* Use 7.2.0-SNAPSHOT

* API generation

* Updated custom skips

* Updated ES version

* Updated esDefaultRoles
2019-07-04 11:27:14 +02:00
0918df8e7d Updated type definitions (#882)
* Updated type definitions

* Updated test
2019-06-19 09:15:31 +02:00
e86a6371c5 Support branch for code generation (#883) 2019-06-18 15:46:22 +02:00
53e326275b Added cloud configuration example (#880)
* Added cloud configuration example

* Used cloud example from auth docs and added link
2019-06-14 10:13:01 +02:00
48e277fd07 [DOCS] Fixes typo (#877) 2019-06-12 08:42:01 +02:00
40603cde72 Merge branch '7.x' of https://github.com/elastic/elasticsearch-js into 7.x 2019-06-03 12:28:57 +02:00
896c742407 Docs: added missing configuration options (#870) 2019-06-03 12:28:50 +02:00
22880d4659 Added ES 7.1 2019-05-22 17:53:08 +02:00
21a84654f6 Bumped v7.1.0 2019-05-22 12:18:55 +02:00
bb0ff22fd2 Support for non-friendly chars in url username and password (#858)
* Support for non-friendly chars in url username and password
- Added auth option to Connection class
- Updated pool.addConnection

* Updated test
2019-05-20 17:10:17 +02:00
9897ba8831 Patch #855 2019-05-17 09:07:01 -04:00
c922661fda API generation 2019-05-16 16:53:38 -04:00
597dd28340 Patch deprecated parameters (#851)
* Updated code generation

* API generation

* API generation

* Updated code generation
2019-05-16 16:53:05 -04:00
cc0dc10c64 missing comma (#854) 2019-05-16 09:39:11 -04:00
9c5394ecdb Bumped v7.0.1 2019-05-14 17:49:52 -04:00
96a103b305 Added toJSON method to Connection class (#849)
* Added toJSON method to Connection class

* Updated test

* Updated typings
2019-05-14 12:01:21 -04:00
3e9ae8b29c Fix #803 (#846) 2019-05-14 12:01:21 -04:00
064807c5a9 Fix 843 (#845)
* Fix #843

* Updated test
2019-05-10 10:56:06 +02:00
72b67fe4d7 Bumped v7.0.0 2019-05-09 15:33:58 +02:00
6f2767628c Fix 841 (#842)
* Added errors to exported members

* Updated test
2019-05-09 14:57:33 +02:00
96137788db Bumped v7.0.0-rc.3 2019-05-06 12:05:27 +02:00
8136846a78 API generation 2019-05-06 12:04:41 +02:00
62e9805311 Updated installation instructions (#840) 2019-05-06 12:02:08 +02:00
907f9d085c Added User-Agent header (#807)
* Added User-Agent header

* Updated test

* Updated user-agent format

* Updated test
2019-05-06 09:59:55 +02:00
0c1fb22631 API generation 2019-05-03 19:03:34 +02:00
132072b8ab Simplify API wrappers (#839)
* Updated code generation

* API generation

* Updated test

* Updated code generation

* API generation

* API generation
2019-05-03 19:03:09 +02:00
99ada00747 API generation 2019-05-03 17:26:07 +02:00
b1458e3511 Improve observability (#834)
* API generation

* Added correlation id support

* Updated docs

* Updated test

* Updated code generation

* API generation

* Updated code generation

* Added support for client name and custom context object

* Updated docs

* Updated test

* Fix docs

* Updated docs

* Added id support also for sniffing

* Updated test

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Apply suggestions

* Update docs/configuration.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/configuration.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Apply suggestions

* Updated README.md

* Fixed test

* Addressed suggestions
2019-05-03 17:25:25 +02:00
9dacd9d9ee Better handling of hostname/ip:port format (#837)
* Better handling of hostname/ip:port format

* Updated test
2019-05-03 17:25:04 +02:00
d6577b7fa1 Updated installation instructions (#835)
* Updated installation instructions

* Added a note about Elasticsearch master
2019-05-03 17:25:04 +02:00
ddb72d6e50 Fix resurrect timeout formula (#833)
* Fixes #827

* Updated test
2019-04-29 09:19:53 +02:00
9bb2d237e4 Node v12 and bumped dependencies (#832)
* Node v12

* Bumped dependencies

* Disable automatic code coverage
2019-04-26 17:26:14 +02:00
4099532617 Updated .travis.yml (#831) 2019-04-26 15:04:17 +02:00
37544399ce API generation 2019-04-26 15:03:20 +02:00
12e88d6f87 Support for deprecated paths (#828)
* Updated code generation

* API generation

* Updated test
2019-04-26 15:02:49 +02:00
dbfeb5d1a9 Update RequestEvent to use parameterized type T (#822)
Updated `RequestEvent` to use parameterized type `T`.  In reference to:

https://github.com/elastic/elasticsearch-js/pull/819#issuecomment-484594841
2019-04-19 10:07:17 +02:00
84a837ce11 Bumped v7.0.0-rc.2 2019-04-17 14:16:43 +02:00
dc009dc3a5 Use Elasticsearch 7.0.0 (#820) 2019-04-17 14:13:04 +02:00
d4f4b47d7e Updated typings (#819) 2019-04-17 11:24:28 +02:00
cfd4e70fb9 Drop Node.js v6 support (#818)
Node.js v6 will go EOL at the end of April 2019, and already two of the production dependencies of the client have already dropped support for it, and soon others will do *(as well as development dependencies)*.

Furthermore, since Node.js will go in EOL it will never get security patches, plus, also OpenSSL-1.0.2 will go EOL [this year](https://github.com/nodejs/Release#release-schedule); to avoid risks for the client users it is better to drop support for Node.js v6 right away.
2019-04-17 11:24:28 +02:00
68f8b7bb5f Fix a typo in usage example (#806) 2019-04-11 08:27:57 +02:00
777e438482 API generation 2019-04-10 11:44:12 +02:00
29beb44bf5 Improve typings (#813)
The ApiResponse now accepts a generics that defaults to any, same for every API method that might need a body.
2019-04-10 11:43:14 +02:00
ef3126b361 Custom http agent support (#810) 2019-04-10 11:42:51 +02:00
6cc2b21ce2 Use Elasticsearch 7.0.0-rc2 2019-04-09 12:10:10 +02:00
02c656c364 Support for publish_address as hostname/ip:port (#804) 2019-04-09 12:06:22 +02:00
77fcca871f Updated README.md 2019-04-01 09:50:23 +02:00
ca0b33a2b0 Handle bulk errors in examples 2019-04-01 09:08:58 +02:00
74c37e5b2d Generated reference 2019-03-29 18:08:28 +01:00
0e47cb88eb Docs: Fix ingest doc links (#801)
The ingest docs in Elasticsearch doing point to the actual ingest APIs.
This makes up generate links to the real APIs instead, fixing some
broken links in the 5.x docs in the process.
2019-03-29 18:07:55 +01:00
f97208214e Generated reference 2019-03-29 15:46:44 +01:00
6f4a8bbe6a Docs: Handle more funny cases from ES api spec (#800)
Handles a few "special" doc urls from ES's api spec files. These are
only a problem in 6.x but we'd like to keep the generateDocs script the
same across all branches for easier backporting.
2019-03-29 15:46:17 +01:00
c0264393a1 Update asciidoc config 2019-03-29 15:41:57 +01:00
92bcf46ab4 Generated reference 2019-03-29 08:51:54 +01:00
af544e8a55 Docs: Fix the API reference (#799) 2019-03-29 08:50:57 +01:00
fbf804869f Bumped v7.0.0-rc.1 2019-03-28 19:28:09 +01:00
f3422a6f43 Fix docs (#796)
Follow up of https://github.com/elastic/docs/pull/701.
2019-03-28 17:36:08 +01:00
f2c43a843b Updated CONTRIBUTING.md (#794)
As titled, also renamed the script files for a better DX.
2019-03-28 10:11:04 +01:00
1f6c68df9c v7.0.0-rc1 support 🚀 (#792)
Support for Elasticsearch `v7.0.0-rc1`
2019-03-28 08:32:24 +01:00
c7675708de Added CONTRIBUTING.md and CODE_OF_CONDUCT.md 2019-03-27 16:48:12 +01:00
e897d8f050 Improved integration test runner 2019-03-27 15:00:21 +01:00
4537308c38 Doc updates (#791)
Updates for better displaying the documentation in the website.
2019-03-27 07:45:31 +01:00
3a1bb9377a Merge branch 'master' into 7.x 2019-03-26 12:06:04 +01:00
e185a0b08c Remove url in jenkins job configuration 2019-03-21 11:16:21 -04:00
9b111ee664 CI config (#786)
* Updated ci config

* Minor fixes

* Minor fixes

* Added Node v11
2019-03-21 11:03:35 +01:00
367f16c0ba Updated ci config 2019-03-19 14:16:56 +01:00
1d61cba014 Inspect Connection (#784)
Handles `console.log` and `utils.inspect` invocations for a better debugging experience.

`agent` and `ssl` are hidden since they made the logs very hard to read.
The user can still access them with `instance.agent` and `instance.ssl`.
2019-03-19 09:53:43 +01:00
358474bca8 Feat: Support bundlers (#783)
With this change, we support code bundlers, such as webpack.
Fixes: https://github.com/elastic/elasticsearch-js/issues/781
2019-03-19 09:53:43 +01:00
c0027b3958 Added a note about the new client 2019-03-19 09:53:43 +01:00
68c4dd29fb feat: add support for querystring in options object (#779)
In very few cases, some API uses the same key for both url and query params, such as the bulk method.
The client is not designed to handle such cases since accepts both url and query keys in the same object, and the url parameter will always take precedence.
This pr fixes this edge case by adding a `querystring` key in the options object.

Fixes: https://github.com/elastic/elasticsearch-js/pull/778

```js
client.bulk({
  index: 'index',
  type: '_doc',
  body: [...]
}, {
  querystring: {
    type: '_doc'
  }
}, console.log)
```
2019-03-19 09:53:43 +01:00
a3e3d57247 Updated coverage script 2019-03-15 17:49:24 +01:00
c3966cacab Added codecov badge 2019-03-15 17:49:24 +01:00
048933f106 Updated ignore files 2019-03-15 17:49:24 +01:00
91935905b6 Added codecov (#777) 2019-03-15 17:49:24 +01:00
0f5ac8127c Updated README 2019-03-14 18:33:22 +01:00
99e1dc3b39 API generation 2019-03-13 14:13:53 +01:00
e98cab1a34 Revert d4d7d0bef5 2019-03-13 14:13:32 +01:00
484 changed files with 37876 additions and 25719 deletions

View File

@ -1,20 +1,20 @@
-----BEGIN CERTIFICATE-----
MIIDSTCCAjGgAwIBAgIUIwN+0zglsexRKwE1RGHvlCcmrdwwDQYJKoZIhvcNAQEL
BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l
cmF0ZWQgQ0EwHhcNMTkwMjEzMDcyMjQwWhcNMjIwMjEyMDcyMjQwWjA0MTIwMAYD
VQQDEylFbGFzdGljIENlcnRpZmljYXRlIFRvb2wgQXV0b2dlbmVyYXRlZCBDQTCC
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANILs0JO0e7x29zeVx21qalK
XKdX+AMlGJPH75wWO/Jq6YHtxt1wYIg762krOBXfG6JsFSOIwIv5VrzGGRGjSPt9
OXQyXrDDiQvsBT3rpzLNdDs7KMl2tZswwv7w9ujgud0cYnS1MOpn81rfPc73DvMg
xuhplofDx6fn3++PjVRU2FNiIVWyEoaxRjCeGPMBubKZYaYbQA6vYM4Z+ByG727B
AyAER3t7xmvYti/EoO2hv2HQk5zgcj/Oq3AJKhnt8LH8fnfm3TnYNM1htvXqhN05
vsvhvm2PHfnA5qLlSr/3W0aI/U/PqfsFDCgyRV097sMIaKkmavb0Ue7aQ7lgtp0C
AwEAAaNTMFEwHQYDVR0OBBYEFDRKlCMowWR1rwxE0d1lTEQe5O71MB8GA1UdIwQY
MBaAFDRKlCMowWR1rwxE0d1lTEQe5O71MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI
hvcNAQELBQADggEBAKbCJ95EBpeuvF70KEt6QU70k/SH1NRvM9YzKryV0D975Jvu
HOSm9HgSTULeAUFZIa4oYyf3QUfVoI+2T/aQrfXA3gfrJWsHURkyNmiHOFAbYHqi
xA6i249G2GTEjc1+le/M2N2CcDKAmurW6vSGK4upXQbPd6KmnhHREX74zkWjnOa+
+tibbSSOCT4Tmja2DbBxAPuivU9IB1g/hIUmbYQqKffQrBJA0658tz6w63a/Q7xN
pCvvbSgiMZ6qcVIcJkBT2IooYie+ax45pQECHthgIUcQAzfmIfqlU0Qfl8rDgAmn
0c1o6HQjKGU2aVGgSRuaaiHaSZjbPIZVS51sOoI=
MIIDSjCCAjKgAwIBAgIVAJQLm8V2LcaCTHUcoIfO+KL63nG3MA0GCSqGSIb3DQEB
CwUAMDQxMjAwBgNVBAMTKUVsYXN0aWMgQ2VydGlmaWNhdGUgVG9vbCBBdXRvZ2Vu
ZXJhdGVkIENBMB4XDTIwMDIyNjA1NTA1N1oXDTIzMDIyNTA1NTA1N1owNDEyMDAG
A1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5lcmF0ZWQgQ0Ew
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDYyajkPvGtUOE5M1OowQfB
kWVrWjo1+LIxzgCeRHp0YztLtdVJ0sk2xoSrt2uZpxcPepdyOseLTjFJex1D2yCR
AEniIqcFif4G72nDih2LlbhpUe/+/MTryj8ZTkFTzI+eMmbQi5FFMaH+kwufmdt/
5/w8YazO18SxxJUlzMqzfNUrhM8vvvVdxgboU7PWhk28wZHCMHQovomHmzclhRpF
N0FMktA98vHHeRjH19P7rNhifSd7hZzoH3H148HVAKoPgqnZ6vW2O2YfAWOP6ulq
cyszr57p8fS9B2wSdlWW7nVHU1JuKcYD67CxbBS23BeGFgCj4tiNrmxO8S5Yf85v
AgMBAAGjUzBRMB0GA1UdDgQWBBSWAlip9eoPmnG4p4OFZeOUBlAbNDAfBgNVHSME
GDAWgBSWAlip9eoPmnG4p4OFZeOUBlAbNDAPBgNVHRMBAf8EBTADAQH/MA0GCSqG
SIb3DQEBCwUAA4IBAQA19qqrMTWl7YyId+LR/QIHDrP4jfxmrEELrAL58q5Epc1k
XxZLzOBSXoBfBrPdv+3XklWqXrZjKWfdkux0Xmjnl4qul+srrZDLJVZG3I7IrITh
AmQUmL9MuPiMnAcxoGZp1xpijtW8Qmd2qnambbljWfkuVaa4hcVRfrAX6TciIQ21
bS5aeLGrPqR14h30YzDp0RMmTujEa1o6ExN0+RSTkE9m89Q6WdM69az8JW7YkWqm
I+UCG3TcLd3TXmN1zNQkq4y2ObDK4Sxy/2p6yFPI1Fds5w/zLfBOvvPQY61vEqs8
SCCcQIe7f6NDpIRIBlty1C9IaEHj7edyHjF6rtYb
-----END CERTIFICATE-----

27
.ci/certs/ca.key Normal file
View File

@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpgIBAAKCAQEA2Mmo5D7xrVDhOTNTqMEHwZFla1o6NfiyMc4AnkR6dGM7S7XV
SdLJNsaEq7drmacXD3qXcjrHi04xSXsdQ9sgkQBJ4iKnBYn+Bu9pw4odi5W4aVHv
/vzE68o/GU5BU8yPnjJm0IuRRTGh/pMLn5nbf+f8PGGsztfEscSVJczKs3zVK4TP
L771XcYG6FOz1oZNvMGRwjB0KL6Jh5s3JYUaRTdBTJLQPfLxx3kYx9fT+6zYYn0n
e4Wc6B9x9ePB1QCqD4Kp2er1tjtmHwFjj+rpanMrM6+e6fH0vQdsEnZVlu51R1NS
binGA+uwsWwUttwXhhYAo+LYja5sTvEuWH/ObwIDAQABAoIBAQC8QDGnMnmPdWJ+
13FYY3cmwel+FXXjFDk5QpgK15A2rUz6a8XxO1d7d1wR+U84uH4v9Na6XQyWjaoD
EyPQnuJiyAtgkZLUHoY244PGR5NsePEQlBSCKmGeF5w/j1LvP/2e9EmP4wKdQYJY
nLxFNcgEBCFnFbKIU5n8fKa/klybCrwlBokenyBro02tqH4LL7h1YMRRrl97fv1V
e/y/0WcMN+KnMglfz6haimBRV2yamCCHHmBImC+wzOgT/quqlxPfI+a3ScHxuA65
3QyCavaqlPh+T3lXnN/Na4UWqFtzMmwgJX2x1zM5qiln46/JoDiXtagvV43L3rNs
LhPRFeIRAoGBAPhEB7nNpEDNjIRUL6WpebWS9brKAVY7gYn7YQrKGhhCyftyaiBZ
zYgxPaJdqYXf+DmkWlANGoYiwEs40QwkR/FZrvO4+Xh3n3dgtl59ZmieuoQvDsG+
RYIj+TfBaqhewhZNMMl7dxz7DeyQhyRCdsvl3VqJM0RuOsIrzrhCIEItAoGBAN+K
lgWI7swDpOEaLmu+IWMkGImh1LswXoZqIgi/ywZ7htZjPzidOIeUsMi+lrYsKojG
uU3sBxASsf9kYXDnuUuUbGT5M/N2ipXERt7klUAA/f5sg1IKlTrabaN/HGs/uNtf
Efa8v/h2VyTurdPCJ17TNpbOMDwX1qGM62tyt2CLAoGBAIHCnP8iWq18QeuQTO8b
a3/Z9hHRL22w4H4MI6aOB6GSlxuTq6CJD4IVqo9IwSg17fnCy2l3z9s4IqWuZqUf
+XJOW8ELd2jdrT2qEOfGR1Z7UCVyqxXcq1vgDYx0zZh/HpalddB5dcJx/c8do2Ty
UEE2PcHqYB9uNcvzNbLc7RtpAoGBALbuU0yePUTI6qGnajuTcQEPpeDjhRHWSFRZ
ABcG1N8uMS66Mx9iUcNp462zgeP8iqY5caUZtMHreqxT+gWKK7F0+as7386pwElF
QPXgO18QMMqHBIQb0vlBjJ1SRPBjSiSDTVEML1DljvTTOX7kEJHh6HdKrmBO5b54
cqMQUo53AoGBAPVWRPUXCqlBz914xKna0ZUh2aesRBg5BvOoq9ey9c52EIU5PXL5
0Isk8sWSsvhl3tjDPBH5WuL5piKgnCTqkVbEHmWu9s1T57Mw6NuxlPMLBWvyv4c6
tB9brOxv0ui3qGMuBsBoDKbkNnwXyOXLyFg7O+H4l016A3mLQzJM+NGV
-----END RSA PRIVATE KEY-----

View File

@ -1,19 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDIjCCAgqgAwIBAgIUI4QU6jA1dYSCbdIA6oAb2TBEluowDQYJKoZIhvcNAQEL
BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l
cmF0ZWQgQ0EwHhcNMTkwMjEzMDcyMzEzWhcNMjIwMjEyMDcyMzEzWjATMREwDwYD
VQQDEwhpbnN0YW5jZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJeT
yOy6EAScZxrULKjHePciiz38grivCrhFFV+dThaRCcl3DhDzb9Eny5q5iEw3WvLQ
Rqmf01jncNIhaocTt66VqveXaMubbE8O0LcG6e4kpFO+JtnVF8JTARTc+ux/1uD6
hO1VG/HItM7WQrQxh4hfB2u1AX2YQtoqEtXXEC+UHWfl4QzuzXjBnKCkO/L9/6Tf
yNFQWXxKnIiTs8Xm9sEhhSCBJPlLTQu+MX4vR2Uwj5XZmflDUr+ZTenl9qYxL6b3
SWhh/qEl4GAj1+tS7ZZOxE0237mUh3IIFYSWSaMm8K2m/BYHkLNWL5B1dMic0lsv
osSoYrQuCef4HQMCitsCAwEAAaNNMEswHQYDVR0OBBYEFFMg4l1GLW8lYbwASY+r
YeWYRzIiMB8GA1UdIwQYMBaAFDRKlCMowWR1rwxE0d1lTEQe5O71MAkGA1UdEwQC
MAAwDQYJKoZIhvcNAQELBQADggEBAEQrgh1xALpumQTzsjxFRGque/vlKTgRs5Kh
xtgapr6wjIbdq7dagee+4yNOKzS5lGVXCgwrJlHESv9qY0uumT/33vK2uduJ7NAd
fR2ZzyBnhMX+mkYhmGrGYCTUMUIwOIQYa4Evis4W+LHmCIDG03l7gLHfdIBe9VMO
pDZum8f6ng0MM49s8/rXODNYKw8kFyUhnfChqMi/2yggb1uUIfKlJJIchkgYjE13
zuC+fjo029Pq1jeMIdxugLf/7I/8NiW1Yj9aCXevUXG1qzHFEuKAinBXYOZO/vWS
LaEqOhwrzNynwgGpYAr7Rfgv4AflltYIIav4PZT03P7fbyAAf8s=
MIIDIzCCAgugAwIBAgIVAMTO6uVx9dLox2t0lY4IcBKZXb5WMA0GCSqGSIb3DQEB
CwUAMDQxMjAwBgNVBAMTKUVsYXN0aWMgQ2VydGlmaWNhdGUgVG9vbCBBdXRvZ2Vu
ZXJhdGVkIENBMB4XDTIwMDIyNjA1NTA1OVoXDTIzMDIyNTA1NTA1OVowEzERMA8G
A1UEAxMIaW5zdGFuY2UwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDK
YLTOikVENiN/qYupOsoXd7VYYnryyfCC/dK4FC2aozkbqjFzBdvPGAasoc4yEiH5
CGeXMgJuOjk1maqetmdIsw00j4oHJviYsnGXzxxS5swhD7spcW4Uk4V4tAUzrbfT
vW/2WW/yYCLe5phVb2chz0jL+WYb4bBmdfs/t6RtP9RqsplYAmVp3gZ6lt2YNtvE
k9gz0TVk3DuO1TquIClfRYUjuywS6xDSvxJ8Jl91EfDWM8QU+9F+YAtiv74xl2U3
P0wwMqNvMxf9/3ak3lTQGsgO4L6cwbKpVLMMzxSVunZz/sgl19xy3qHHz1Qr2MjJ
/2c2J7vahUL4NPRkjJClAgMBAAGjTTBLMB0GA1UdDgQWBBS2Wn8E2VZv4oenY+pR
O8G3zfQXhzAfBgNVHSMEGDAWgBSWAlip9eoPmnG4p4OFZeOUBlAbNDAJBgNVHRME
AjAAMA0GCSqGSIb3DQEBCwUAA4IBAQAvwPvCiJJ6v9jYcyvYY8I3gP0oCwrylpRL
n91UlgRSHUmuAObyOoVN5518gSV/bTU2SDrstcLkLFxHvnfpoGJoxsQEHuGxwDRI
nhYNd62EKLerehNM/F9ILKmvTh8f6QPCzjUuExTXv+63l2Sr6dBS7FHsGs6UKUYO
llM/y9wMZ1LCuZuBg9RhtgpFXRSgDM9Z7Begu0d/BPX9od/qAeZg9Arz4rwUiCN4
IJOMEBEPi5q1tgeS0Fb1Grpqd0Uz5tZKtEHNKzLG+zSMmkneL62Nk2HsmEFZKwzg
u2pU42UaUE596G6o78s1aLn9ICcElPHTjiuZNSiyuu9IzvFDjGQw
-----END CERTIFICATE-----

View File

@ -1,27 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAl5PI7LoQBJxnGtQsqMd49yKLPfyCuK8KuEUVX51OFpEJyXcO
EPNv0SfLmrmITDda8tBGqZ/TWOdw0iFqhxO3rpWq95doy5tsTw7Qtwbp7iSkU74m
2dUXwlMBFNz67H/W4PqE7VUb8ci0ztZCtDGHiF8Ha7UBfZhC2ioS1dcQL5QdZ+Xh
DO7NeMGcoKQ78v3/pN/I0VBZfEqciJOzxeb2wSGFIIEk+UtNC74xfi9HZTCPldmZ
+UNSv5lN6eX2pjEvpvdJaGH+oSXgYCPX61Ltlk7ETTbfuZSHcggVhJZJoybwrab8
FgeQs1YvkHV0yJzSWy+ixKhitC4J5/gdAwKK2wIDAQABAoIBAQCRFTJna/xy/WUu
59FLR4qAOj8++JgCwACpue4oU7/vl6nffSYokWoAr2+RzG4qTX2vFi3cpA8+dGCn
sLZvTi8tWzKGxBTZdg2oakzaMzLr74SeZ052iCGyrZJGbvF6Ny7srr1XEXSq6+os
ZCb6pMHOhO7saBdiKMAsY8MdjTl/33AduuE6ztqv+L92xTr2g4QlbT1KvWlEgppU
k4Gy7zdETkPBTSH/17ZwyGJoJICIAhbL4IpmOM4dPIg8nFkVPPpy6p0z4uGjtgnK
nreZ2EKMzCafBaHn7A77gpi0OrQdl6pe0fsGqv/323YjCJPbwwl5TsoNq44DzwiX
3M7XiVJxAoGBAOCne56vdN4uZmCgLVGT2JSUNVPOu4bfjrxWH6cslzrPT2Zhp3lO
M4axZ3gmcervV252YEZXntXDHHCSfrECllRN1WFD63XmyQ/CkhuvZkkeRHfzL1TE
EdqHOTqs4sRETZ7+RITFC81DZQkWWOKeyXMjyPBqd7RnThQHijB1c8Y5AoGBAKy6
CVKBx+zz5crVD0tz4UhOmz1wRNN0CL0l+FXRuFSgbzMIvwpfiqe25crgeLHe2M2/
TogdWbjZ2nUZQTzoRsSkQ6cKHpj+G/gWurp/UcHHXFVwgLSPF7c3KHDtiYq7Vqw0
bvmhM03LI6+ZIPRV7hLBr7WP7UmpAiREMF7tTnmzAoGBAIkx3w3WywFQxtblmyeB
qbd7F2IaE23XoxyjX+tBEQ4qQqwcoSE0v8TXHIBEwjceeX+NLVhn9ClJYVniLRq+
oL3VVqVyzB4RleJZCc98e3PV1yyFx/b1Uo3pHOsXX9lKeTjKwV9v0rhFGzPEgP3M
yOvXA8TG0FnM6OLUg/D6GX0JAoGAMuHS4TVOGeV3ahr9mHKYiN5vKNgrzka+VEod
L9rJ/FQOrfADpyCiDen5I5ygsXU+VM3oanyK88NpcVlxOGoMft0M+OYoQVWKE7lO
ZKYhBX6fGqQ7pfUJPXXIOgwfmni5fZ0sm+j63g3bg10OsiumKGxaQJgXhL1+3gQg
Y7ZwibUCgYEAlZoFFvkMLjpOSaHk1z5ZZnt19X0QUIultBwkumSqMPm+Ks7+uDrx
thGUCoz4ecr/ci4bIUY7mB+zfAbqnBOMxreJqCRbAIuRypo1IlWkTp8DywoDOfMW
NfzjVmzJ7EJu44nGmVAi1jw4Pbseivvi1ujMCoPgaE8I1uSh144bwN8=
MIIEogIBAAKCAQEAymC0zopFRDYjf6mLqTrKF3e1WGJ68snwgv3SuBQtmqM5G6ox
cwXbzxgGrKHOMhIh+QhnlzICbjo5NZmqnrZnSLMNNI+KByb4mLJxl88cUubMIQ+7
KXFuFJOFeLQFM623071v9llv8mAi3uaYVW9nIc9Iy/lmG+GwZnX7P7ekbT/UarKZ
WAJlad4GepbdmDbbxJPYM9E1ZNw7jtU6riApX0WFI7ssEusQ0r8SfCZfdRHw1jPE
FPvRfmALYr++MZdlNz9MMDKjbzMX/f92pN5U0BrIDuC+nMGyqVSzDM8Ulbp2c/7I
Jdfcct6hx89UK9jIyf9nNie72oVC+DT0ZIyQpQIDAQABAoIBADAh7f7NjgnaInlD
ds8KB3SraPsbeQhzlPtiqRJU4j/MIFH/GYG03AGWQkget67a9y+GmzSvlTpoKKEh
6h2TXl9BDpv4o6ht0WRn1HJ5tM/Wyqf2WNpTew3zxCPgFPikkXsPrChYPzLTQJfp
GkP/mfTFmxfAOlPZSp4j41zVLYs53eDkAegFPVfKSr1XNNJ3QODLPcIBfxBYsiC9
oU+jRW8xYuj31cEl5k5UqrChJ1rm3mt6cguqXKbISuoSvi13gXI6DccqhuLAU+Kr
ib2XYrRP+pWocZo/pM9WUVoNGtFxfY88sAQtvG6gDKo2AURtFyq84Ow0h9mdixV/
gRIDPcECgYEA5nEqE3OKuG9WuUFGXvjtn4C0F6JjflYWh7AbX51S4F6LKrW6/XHL
Rg4BtF+XReT7OQ6llsV8kZeUxsUckkgDLzSaA8lysNDV5KkhAWHfRqH//QKFbqZi
JL9t3x63Qt81US8s2hQk3khPYTRM8ZB3xHiXvZYSGC/0x/DxfEO3QJECgYEA4NK5
sxtrat8sFz6SK9nWEKimPjDVzxJ0hxdX4tRq/JdOO5RncawVqt6TNP9gTuxfBvhW
MhJYEsQj8iUoL1dxo9d1eP8HEANNV0iX5OBvJNmgBp+2OyRSyr+PA55+wAxYuAE7
QKaitOjW57fpArNRt2hQyiSzTuqUFRWTWJHCWNUCgYAEurPTXF6vdFGCUc2g61jt
GhYYGhQSpq+lrz6Qksj9o9MVWE9zHh++21C7o+6V16I0RJGva3QoBMVf4vG4KtQt
5tV2WG8LI+4P2Ey+G4UajP6U8bVNVQrUmD0oBBhcvfn5JY+1Fg6/pRpD82/U0VMz
7AmpMWhDqNBMPiymkTk0kQKBgCuWb05cSI0ly4SOKwS5bRk5uVFhYnKNH255hh6C
FGP4acB/WzbcqC7CjEPAJ0nl5d6SExQOHmk1AcsWjR3wlCWxxiK5PwNJwJrlhh1n
reS1FKN0H36D4lFQpkeLWQOe4Sx7gKNeKzlr0w6Fx3Uwku0+Gju2tdTdAey8jB6l
08opAoGAEe1AuR/OFp2xw6V8TH9UHkkpGxy+OrXI6PX6tgk29PgB+uiMu4RwbjVz
1di1KKq2XecAilVbnyqY+edADxYGbSnci9x5wQRIebfMi3VXKtV8NQBv2as6qwtW
JDcQUWotOHjpdvmfJWWkcBhbAKrgX8ukww00ZI/lC3/rmkGnBBg=
-----END RSA PRIVATE KEY-----

View File

@ -0,0 +1,20 @@
-----BEGIN CERTIFICATE-----
MIIDVjCCAj6gAwIBAgIULh42yRefYlRRl1hvt055LrUH0HwwDQYJKoZIhvcNAQEL
BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l
cmF0ZWQgQ0EwHhcNMjAwMjI4MDMzNzIwWhcNMjMwMjI3MDMzNzIwWjATMREwDwYD
VQQDEwhpbnN0YW5jZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIUP
t267NN21z+3ukajej8eojSXwP6zHxy7CUAp+sQ7bTq2XCKxkYX3CW9ThcS4cV9mL
ayYdWEYnbEDGYPQDo7Wk3Ih5OEXTMZb/yNEx5D4S2lGMOS5bCDdYx6GvwCMG4jNx
aMktosaxpprAJiHh2oLgQk0hQc/a9JfMo6kJKtuhjxsxjxLwcOHhuaUD7NS0Pjop
CJkSYcrL+nnQPQjKe4uLhAbSyiX914h4QX0CJ0e4z1ccdDX2PFWTrwaIf//vQhCR
wP2YKdfjR0JB4oDAlu85GsIs2cFLPysM5ufuNZO4fCr8uOwloKI8zZ2HhlIfBEcY
Gcy4g9N/9epmxMXZlGcCAwEAAaOBgDB+MB0GA1UdDgQWBBRefYm8DHHDdkTPHhS1
HEUwTb2uiDAfBgNVHSMEGDAWgBSWAlip9eoPmnG4p4OFZeOUBlAbNDAxBgNVHREE
KjAogglsb2NhbGhvc3SHBH8AAAGHEAAAAAAAAAAAAAAAAAAAAAGCA2VzMTAJBgNV
HRMEAjAAMA0GCSqGSIb3DQEBCwUAA4IBAQC+pauqM2wJjQaHyHu+kIm59P4b/5Oj
IH1cYCQfMB7Y2UMLxp0ew+f7o7zzE2DA52YYFDWy6J5DVWtSBPyeFGgX+RH+aA+9
Iv4cc9QpAs6aFjncorHrzNOrWLgCHIeRAxTR0CAkeP2dUZfDBuMpRyP6rAsYzyLH
Rb3/BfYJSI5vxgt5Ke49Y/ljDKFJTyDmAVrHQ4JWrseYE1UZ2eDkBXeiRlYE/QtB
YsrUSqdL6zvFZyUcilxDUUabNcA+GgeGZ2lAEA90F8vwi62QwRXo3Iv1Hz+6xc43
nFofDK9D8/qkrUD9iuhpx1974QwPhwWyjn9RZRpbZA4ngRL+szdRXR4N
-----END CERTIFICATE-----

View File

@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAhQ+3brs03bXP7e6RqN6Px6iNJfA/rMfHLsJQCn6xDttOrZcI
rGRhfcJb1OFxLhxX2YtrJh1YRidsQMZg9AOjtaTciHk4RdMxlv/I0THkPhLaUYw5
LlsIN1jHoa/AIwbiM3FoyS2ixrGmmsAmIeHaguBCTSFBz9r0l8yjqQkq26GPGzGP
EvBw4eG5pQPs1LQ+OikImRJhysv6edA9CMp7i4uEBtLKJf3XiHhBfQInR7jPVxx0
NfY8VZOvBoh//+9CEJHA/Zgp1+NHQkHigMCW7zkawizZwUs/Kwzm5+41k7h8Kvy4
7CWgojzNnYeGUh8ERxgZzLiD03/16mbExdmUZwIDAQABAoIBAEwhjulLMVc9JEfV
PP/qv0cUOBYh3LzF3T/yq4slq7Z9YgnOJYdFM8aZgqNNjc09KEJvE5JOLeiNu9Ff
768Nugg+2HM5MCo7SN9FYCfZLOcbMFCCM2FDcnMAV9A512vzD08xryuT8dNPZ6yZ
DfhK2hQRrb2lrpr3gwSrcGRRu3THqvq7X1RIjpLV3teDMeP8rQPAlpj8fmP+kdVV
5y1ihiDIo87McihG9FMavJtBDXQkUEuVw6eIeir8L/zHHD/ZwhYjNHZGWbrB88sz
CkJkfWh/FlA63tCVdJzkmnERALLTVy9mR0Sq6sUlnFhFNO2BRdWgYLrcp9McfTJC
e8+WsSECgYEAuwQ3nAaFL0jqYu1AREyKT/f3WUenf2UsX7dwwV2/yFtQvkzW7ji4
uZLnfUnZBojtHf35dRo+hDgtvhZhgZNAuPPsbOl/EIMTcbChEqV/3CSTFlhLFM1d
hfM9PoM+Bt/pyUNabjD1sWM0X7WeUhzcddshY3S4daBsNsLuOzweRRcCgYEAtiSS
4qiiGafYsY7gOHuAlOhs/00+1uWIFEHKgoHM9vzCxDN3LCmBdynHk8ZE2TAdhw+l
7xpu6LUxKQDfGmVZa9Epg0kQmVq9c54oQP57pJ3tR+68++insEkfnaZH8jblfq2s
sSkFrY3pdS19edq60nuft64kswKRUUkamCXTXTECgYBdoSfiMpV9bekC7DsPtq5M
iR3KEgi2zEViCmomNTRuL+GF1NyKWdWJ+xVwcYd5MRZdvKimyyPfeGzWTUg14i42
KtEEWgZmkukqMz8BIeCYq6sENeIpIQQgqv3PjU+Bi5r1S4Y7wsFPNRakkD4aaB6r
1rCppWcwZMeoxwEUoO2aswKBgBdDIIdWJi3EpAY5SyWrkEZ0UMdiZC4p7nE33ddB
IJ5CtdU9BXFcc652ZYjX/58FaCABvZ2F8LhDu92SwOusGfmNIxIjWL1dO2jywA1c
8wmZKd7P/M7nbdMz45fMzs9+d1zwbWfK53C8+R4AC1BuwQF0zHc3BHTgVRLelUjt
O8thAoGAdO2gHIqEsZzTgbvLbsh52eVbumjfNGnrnEv1fjb+o+/wAol8dymcmzbL
bZCRzoyA0qwU9kdPFgX46H6so6o1tUM2GQtVFoT6kDnPv7EkLQK0C4cDh6OOHxDU
NPvr/9fHhQd9EDWDvS1JnVMAdKDO6ELp3SoKGGmCXR2QplnqWAk=
-----END RSA PRIVATE KEY-----

View File

@ -1,94 +0,0 @@
version: '3.2'
services:
client-oss:
image: docker.elastic.co/clients/elasticsearch-js:${NODE_JS_VERSION:-10}
build:
context: ..
dockerfile: .ci/Dockerfile
args:
NODE_JS_VERSION: ${NODE_JS_VERSION:-10}
CODECOV_TOKEN: ${CODECOV_TOKEN}
environment:
- "TEST_ES_SERVER=http://elasticsearch-oss:9200"
volumes:
- ..:/usr/src/app
# This will mount the node_modules directory
# to the host machine using the buildtime directory.
- /usr/src/app/node_modules
- esvol:/tmp
networks:
- esnet-oss
depends_on:
- elasticsearch-oss
elasticsearch-oss:
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.0.0-beta1}
volumes:
- esvol:/tmp
networks:
- esnet-oss
environment:
- path.repo=/tmp
- "repositories.url.allowed_urls=http://snapshot.*"
- node.attr.testattr=test
- bootstrap.memory_lock=false
- "discovery.type=single-node"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
client-platinum:
image: docker.elastic.co/clients/elasticsearch-js:${NODE_JS_VERSION:-10}
build:
context: ..
dockerfile: .ci/Dockerfile
args:
NODE_JS_VERSION: ${NODE_JS_VERSION:-10}
environment:
- "TEST_ES_SERVER=https://elastic:changeme@elasticsearch-platinum:9200"
volumes:
- ..:/usr/src/app
# This will mount the node_modules directory
# to the host machine using the buildtime directory.
- /usr/src/app/node_modules
- esvol:/tmp
networks:
- esnet-platinum
depends_on:
- elasticsearch-platinum
# there is not need to run again also the unit test
command: ["npm", "run", "test:integration"]
elasticsearch-platinum:
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.0.0-beta1}
ports:
- "9200:9200"
networks:
- esnet-platinum
environment:
- "node.attr.testattr=test"
- "path.repo=/tmp"
- "repositories.url.allowed_urls=http://snapshot.*"
- "discovery.type=single-node"
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- "ELASTIC_PASSWORD=changeme"
- "xpack.security.enabled=true"
- "xpack.license.self_generated.type=trial"
- "xpack.security.http.ssl.enabled=true"
- "xpack.security.http.ssl.verification_mode=certificate"
- "xpack.security.http.ssl.key=certs/testnode.key"
- "xpack.security.http.ssl.certificate=certs/testnode.crt"
- "xpack.security.http.ssl.certificate_authorities=certs/ca.crt"
- "xpack.security.transport.ssl.enabled=true"
- "xpack.security.transport.ssl.key=certs/testnode.key"
- "xpack.security.transport.ssl.certificate=certs/testnode.crt"
- "xpack.security.transport.ssl.certificate_authorities=certs/ca.crt"
volumes:
- "./certs/testnode.crt:/usr/share/elasticsearch/config/certs/testnode.crt"
- "./certs/testnode.key:/usr/share/elasticsearch/config/certs/testnode.key"
- "./certs/ca.crt:/usr/share/elasticsearch/config/certs/ca.crt"
networks:
# we need two networks otherwise the two ES instances will join each other
esnet-oss:
esnet-platinum:
volumes:
esvol:

7
.ci/docker/Dockerfile Normal file
View File

@ -0,0 +1,7 @@
ARG NODE_JS_VERSION=10
FROM node:${NODE_JS_VERSION}-alpine
RUN apk --no-cache add git
# Create app directory
WORKDIR /usr/src/app

67
.ci/functions/cleanup.sh Normal file
View File

@ -0,0 +1,67 @@
#!/usr/bin/env bash
#
# Shared cleanup routines between different steps
#
# Please source .ci/functions/imports.sh as a whole not just this file
#
# Version 1.0.0
# - Initial version after refactor
function cleanup_volume {
if [[ "$(docker volume ls -q -f name=$1)" ]]; then
echo -e "\033[34;1mINFO:\033[0m Removing volume $1\033[0m"
(docker volume rm "$1") || true
fi
}
function container_running {
if [[ "$(docker ps -q -f name=$1)" ]]; then
return 0;
else return 1;
fi
}
function cleanup_node {
if container_running "$1"; then
echo -e "\033[34;1mINFO:\033[0m Removing container $1\033[0m"
(docker container rm --force --volumes "$1") || true
fi
if [[ -n "$1" ]]; then
echo -e "\033[34;1mINFO:\033[0m Removing volume $1-${suffix}-data\033[0m"
cleanup_volume "$1-${suffix}-data"
fi
}
function cleanup_network {
if [[ "$(docker network ls -q -f name=$1)" ]]; then
echo -e "\033[34;1mINFO:\033[0m Removing network $1\033[0m"
(docker network rm "$1") || true
fi
}
function cleanup_trap {
status=$?
set +x
if [[ "$DETACH" != "true" ]]; then
echo -e "\033[34;1mINFO:\033[0m clean the network if not detached (start and exit)\033[0m"
cleanup_all_in_network "$1"
fi
# status is 0 or SIGINT
if [[ "$status" == "0" || "$status" == "130" ]]; then
echo -e "\n\033[32;1mSUCCESS run-tests\033[0m"
exit 0
else
echo -e "\n\033[31;1mFAILURE during run-tests\033[0m"
exit ${status}
fi
};
function cleanup_all_in_network {
if [[ -z "$(docker network ls -q -f name="^$1\$")" ]]; then
echo -e "\033[34;1mINFO:\033[0m $1 is already deleted\033[0m"
return 0
fi
containers=$(docker network inspect -f '{{ range $key, $value := .Containers }}{{ printf "%s\n" .Name}}{{ end }}' $1)
while read -r container; do
cleanup_node "$container"
done <<< "$containers"
cleanup_network $1
echo -e "\033[32;1mSUCCESS:\033[0m Cleaned up and exiting\033[0m"
};

60
.ci/functions/imports.sh Normal file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env bash
#
# Sets up all the common variables and imports relevant functions
#
# Version 1.0.1
# - Initial version after refactor
# - Validate STACK_VERSION asap
function require_stack_version() {
if [[ -z $STACK_VERSION ]]; then
echo -e "\033[31;1mERROR:\033[0m Required environment variable [STACK_VERSION] not set\033[0m"
exit 1
fi
}
require_stack_version
if [[ -z $es_node_name ]]; then
# only set these once
set -euo pipefail
export TEST_SUITE=${TEST_SUITE-oss}
export RUNSCRIPTS=${RUNSCRIPTS-}
export DETACH=${DETACH-false}
export CLEANUP=${CLEANUP-false}
export es_node_name=instance
export elastic_password=changeme
export elasticsearch_image=elasticsearch
export elasticsearch_url=https://elastic:${elastic_password}@${es_node_name}:9200
if [[ $TEST_SUITE != "xpack" ]]; then
export elasticsearch_image=elasticsearch-${TEST_SUITE}
export elasticsearch_url=http://${es_node_name}:9200
fi
export external_elasticsearch_url=${elasticsearch_url/$es_node_name/localhost}
export elasticsearch_container="${elasticsearch_image}:${STACK_VERSION}"
export suffix=rest-test
export moniker=$(echo "$elasticsearch_container" | tr -C "[:alnum:]" '-')
export network_name=${moniker}${suffix}
export ssl_cert="${script_path}/certs/testnode.crt"
export ssl_key="${script_path}/certs/testnode.key"
export ssl_ca="${script_path}/certs/ca.crt"
fi
export script_path=$(dirname $(realpath -s $0))
source $script_path/functions/cleanup.sh
source $script_path/functions/wait-for-container.sh
trap "cleanup_trap ${network_name}" EXIT
if [[ "$CLEANUP" == "true" ]]; then
cleanup_all_in_network $network_name
exit 0
fi
echo -e "\033[34;1mINFO:\033[0m Creating network $network_name if it does not exist already \033[0m"
docker network inspect "$network_name" > /dev/null 2>&1 || docker network create "$network_name"

View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# Exposes a routine scripts can call to wait for a container if that container set up a health command
#
# Please source .ci/functions/imports.sh as a whole not just this file
#
# Version 1.0.1
# - Initial version after refactor
# - Make sure wait_for_contiainer is silent
function wait_for_container {
set +x
until ! container_running "$1" || (container_running "$1" && [[ "$(docker inspect -f "{{.State.Health.Status}}" ${1})" != "starting" ]]); do
echo ""
docker inspect -f "{{range .State.Health.Log}}{{.Output}}{{end}}" ${1}
echo -e "\033[34;1mINFO:\033[0m waiting for node $1 to be up\033[0m"
sleep 2;
done;
# Always show logs if the container is running, this is very useful both on CI as well as while developing
if container_running $1; then
docker logs $1
fi
if ! container_running $1 || [[ "$(docker inspect -f "{{.State.Health.Status}}" ${1})" != "healthy" ]]; then
cleanup_all_in_network $2
echo
echo -e "\033[31;1mERROR:\033[0m Failed to start $1 in detached mode beyond health checks\033[0m"
echo -e "\033[31;1mERROR:\033[0m dumped the docker log before shutting the node down\033[0m"
return 1
else
echo
echo -e "\033[32;1mSUCCESS:\033[0m Detached and healthy: ${1} on docker network: ${network_name}\033[0m"
return 0
fi
}

View File

@ -1,4 +1,4 @@
---
##### GLOBAL METADATA
@ -42,11 +42,15 @@
- axis:
type: yaml
filename: .ci/test-matrix.yml
name: ELASTICSEARCH_VERSION
name: STACK_VERSION
- axis:
type: yaml
filename: .ci/test-matrix.yml
name: NODE_JS_VERSION
- axis:
type: yaml
filename: .ci/test-matrix.yml
name: TEST_SUITE
yaml-strategy:
exclude-key: exclude
filename: .ci/test-matrix.yml
@ -65,3 +69,6 @@
publishers:
- email:
recipients: infra-root+build@elastic.co
# - junit:
# results: "*-junit.xml"
# allow-empty-results: true

View File

@ -0,0 +1,14 @@
---
- job:
name: elastic+elasticsearch-js+7.3
display-name: 'elastic / elasticsearch-js # 7.3'
description: Testing the elasticsearch-js 7.3 branch.
parameters:
- string:
name: branch_specifier
default: refs/heads/7.3
description: the Git branch specifier to build (&lt;branchName&gt;, &lt;tagName&gt;,
&lt;commitId&gt;, etc.)
triggers:
- github
- timed: '@weekly'

15
.ci/packer_cache.sh Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
source /usr/local/bin/bash_standard_lib.sh
DOCKER_IMAGES="node:14-alpine
node:12-alpine
node:10-alpine
node:8-alpine
"
for di in ${DOCKER_IMAGES}
do
(retry 2 docker pull "${di}") || echo "Error pulling ${di} Docker image, we continue"
done

115
.ci/run-elasticsearch.sh Executable file
View File

@ -0,0 +1,115 @@
#!/usr/bin/env bash
#
# Launch one or more Elasticsearch nodes via the Docker image,
# to form a cluster suitable for running the REST API tests.
#
# Export the STACK_VERSION variable, eg. '8.0.0-SNAPSHOT'.
# Export the TEST_SUITE variable, eg. 'oss' or 'xpack' defaults to 'oss'.
# Export the NUMBER_OF_NODES variable to start more than 1 node
# Version 1.1.0
# - Initial version of the run-elasticsearch.sh script
# - Deleting the volume should not dependent on the container still running
# - Fixed `ES_JAVA_OPTS` config
# - Moved to STACK_VERSION and TEST_VERSION
# - Refactored into functions and imports
# - Support NUMBER_OF_NODES
script_path=$(dirname $(realpath -s $0))
source $script_path/functions/imports.sh
set -euo pipefail
echo -e "\033[34;1mINFO:\033[0m Take down node if called twice with the same arguments (DETACH=true) or on seperate terminals \033[0m"
cleanup_node $es_node_name
master_node_name=${es_node_name}
cluster_name=${moniker}${suffix}
declare -a volumes
environment=($(cat <<-END
--env node.name=$es_node_name
--env cluster.name=$cluster_name
--env cluster.initial_master_nodes=$master_node_name
--env discovery.seed_hosts=$master_node_name
--env cluster.routing.allocation.disk.threshold_enabled=false
--env bootstrap.memory_lock=true
--env node.attr.testattr=test
--env path.repo=/tmp
--env repositories.url.allowed_urls=http://snapshot.test*
END
))
if [[ "$TEST_SUITE" == "xpack" ]]; then
environment+=($(cat <<-END
--env ELASTIC_PASSWORD=$elastic_password
--env xpack.license.self_generated.type=trial
--env xpack.security.enabled=true
--env xpack.security.http.ssl.enabled=true
--env xpack.security.http.ssl.verification_mode=certificate
--env xpack.security.http.ssl.key=certs/testnode.key
--env xpack.security.http.ssl.certificate=certs/testnode.crt
--env xpack.security.http.ssl.certificate_authorities=certs/ca.crt
--env xpack.security.transport.ssl.enabled=true
--env xpack.security.transport.ssl.key=certs/testnode.key
--env xpack.security.transport.ssl.certificate=certs/testnode.crt
--env xpack.security.transport.ssl.certificate_authorities=certs/ca.crt
END
))
volumes+=($(cat <<-END
--volume $ssl_cert:/usr/share/elasticsearch/config/certs/testnode.crt
--volume $ssl_key:/usr/share/elasticsearch/config/certs/testnode.key
--volume $ssl_ca:/usr/share/elasticsearch/config/certs/ca.crt
END
))
fi
cert_validation_flags=""
if [[ "$TEST_SUITE" == "xpack" ]]; then
cert_validation_flags="--insecure --cacert /usr/share/elasticsearch/config/certs/ca.crt --resolve ${es_node_name}:443:127.0.0.1"
fi
NUMBER_OF_NODES=${NUMBER_OF_NODES-1}
http_port=9200
for (( i=0; i<$NUMBER_OF_NODES; i++, http_port++ )); do
node_name=${es_node_name}$i
node_url=${external_elasticsearch_url/9200/${http_port}}$i
if [[ "$i" == "0" ]]; then node_name=$es_node_name; fi
environment+=($(cat <<-END
--env node.name=$node_name
END
))
echo "$i: $http_port $node_url "
volume_name=${node_name}-${suffix}-data
volumes+=($(cat <<-END
--volume $volume_name:/usr/share/elasticsearch/data${i}
END
))
# make sure we detach for all but the last node if DETACH=false (default) so all nodes are started
local_detach="true"
if [[ "$i" == "$((NUMBER_OF_NODES-1))" ]]; then local_detach=$DETACH; fi
echo -e "\033[34;1mINFO:\033[0m Starting container $node_name \033[0m"
set -x
docker run \
--name "$node_name" \
--network "$network_name" \
--env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \
"${environment[@]}" \
"${volumes[@]}" \
--publish "$http_port":9200 \
--ulimit nofile=65536:65536 \
--ulimit memlock=-1:-1 \
--detach="$local_detach" \
--health-cmd="curl $cert_validation_flags --fail $elasticsearch_url/_cluster/health || exit 1" \
--health-interval=2s \
--health-retries=20 \
--health-timeout=2s \
--rm \
docker.elastic.co/elasticsearch/"$elasticsearch_container";
set +x
if wait_for_container "$es_node_name" "$network_name"; then
echo -e "\033[32;1mSUCCESS:\033[0m Running on: $node_url\033[0m"
fi
done

46
.ci/run-repository.sh Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
# parameters are available to this script
# STACK_VERSION -- version e.g Major.Minor.Patch(-Prelease)
# TEST_SUITE -- which test suite to run: oss or xpack
# ELASTICSEARCH_URL -- The url at which elasticsearch is reachable, a default is composed based on STACK_VERSION and TEST_SUITE
# NODE_JS_VERSION -- node js version (defined in test-matrix.yml, a default is hardcoded here)
script_path=$(dirname $(realpath -s $0))
source $script_path/functions/imports.sh
set -euo pipefail
NODE_JS_VERSION=${NODE_JS_VERSION-12}
ELASTICSEARCH_URL=${ELASTICSEARCH_URL-"$elasticsearch_url"}
elasticsearch_container=${elasticsearch_container-}
echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
echo -e "\033[34;1mINFO:\033[0m TEST_SUITE ${TEST_SUITE}\033[0m"
echo -e "\033[34;1mINFO:\033[0m URL ${ELASTICSEARCH_URL}\033[0m"
echo -e "\033[34;1mINFO:\033[0m CONTAINER ${elasticsearch_container}\033[0m"
echo -e "\033[34;1mINFO:\033[0m NODE_JS_VERSION ${NODE_JS_VERSION}\033[0m"
echo -e "\033[1m>>>>> Build docker container >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
docker build \
--file .ci/Dockerfile \
--tag elastic/elasticsearch-js \
--build-arg NODE_JS_VERSION=${NODE_JS_VERSION} \
.
echo -e "\033[1m>>>>> NPM run test:integration >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
repo=$(realpath $(dirname $(realpath -s $0))/../)
run_script_args=""
if [[ "$NODE_JS_VERSION" == "8" ]]; then
run_script_args="--harmony-async-iteration"
fi
docker run \
--network=${network_name} \
--env "TEST_ES_SERVER=${ELASTICSEARCH_URL}" \
--volume $repo:/usr/src/app \
--volume /usr/src/app/node_modules \
--name elasticsearch-js \
--rm \
elastic/elasticsearch-js \
node ${run_script_args} test/integration/index.js

View File

@ -1,110 +1,23 @@
#!/usr/bin/env bash
#
# Runs the client tests via Docker with the expectation that the required
# environment variables have already been exported before running this script.
#
# The required environment variables include:
#
# - $ELASTICSEARCH_VERSION
# - $NODE_JS_VERSION
#
# Version 1.1
# - Moved to .ci folder and seperated out `run-repository.sh`
# - Add `$RUNSCRIPTS` env var for running Elasticsearch dependent products
script_path=$(dirname $(realpath -s $0))
source $script_path/functions/imports.sh
set -euo pipefail
set -eo pipefail
echo -e "\033[1m>>>>> Start [$STACK_VERSION container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
DETACH=true bash .ci/run-elasticsearch.sh
set +x
export VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID")
export CODECOV_TOKEN=$(vault read -field=token secret/clients-ci/elasticsearch-js/codecov)
unset VAULT_ROLE_ID VAULT_SECRET_ID VAULT_TOKEN
set -x
function cleanup {
docker container rm --force --volumes elasticsearch-oss > /dev/null 2>&1 || true
docker container rm --force --volumes elasticsearch-platinum > /dev/null 2>&1 || true
docker container rm --force --volumes elasticsearch-js-oss > /dev/null 2>&1 || true
docker container rm --force --volumes elasticsearch-js-platinum > /dev/null 2>&1 || true
docker network rm esnet-oss > /dev/null
docker network rm esnet-platinum > /dev/null
}
trap cleanup EXIT
# create network and volume
docker network create esnet-oss
docker network create esnet-platinum
# create client image
docker build \
--file .ci/Dockerfile \
--tag elastic/elasticsearch-js \
--build-arg NODE_JS_VERSION=${NODE_JS_VERSION} \
.
# run elasticsearch oss
docker run \
--rm \
--env "node.attr.testattr=test" \
--env "path.repo=/tmp" \
--env "repositories.url.allowed_urls=http://snapshot.*" \
--env "discovery.type=single-node" \
--network=esnet-oss \
--name=elasticsearch-oss \
--detach \
docker.elastic.co/elasticsearch/elasticsearch-oss:${ELASTICSEARCH_VERSION}
# run elasticsearch platinum
repo=$(pwd)
testnodecrt="/.ci/certs/testnode.crt"
testnodekey="/.ci/certs/testnode.key"
cacrt="/.ci/certs/ca.crt"
docker run \
--rm \
--env "node.attr.testattr=test" \
--env "path.repo=/tmp" \
--env "repositories.url.allowed_urls=http://snapshot.*" \
--env "discovery.type=single-node" \
--env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \
--env "ELASTIC_PASSWORD=changeme" \
--env "xpack.security.enabled=true" \
--env "xpack.license.self_generated.type=trial" \
--env "xpack.security.http.ssl.enabled=true" \
--env "xpack.security.http.ssl.verification_mode=certificate" \
--env "xpack.security.http.ssl.key=certs/testnode.key" \
--env "xpack.security.http.ssl.certificate=certs/testnode.crt" \
--env "xpack.security.http.ssl.certificate_authorities=certs/ca.crt" \
--env "xpack.security.transport.ssl.enabled=true" \
--env "xpack.security.transport.ssl.key=certs/testnode.key" \
--env "xpack.security.transport.ssl.certificate=certs/testnode.crt" \
--env "xpack.security.transport.ssl.certificate_authorities=certs/ca.crt" \
--volume "$repo$testnodecrt:/usr/share/elasticsearch/config/certs/testnode.crt" \
--volume "$repo$testnodekey:/usr/share/elasticsearch/config/certs/testnode.key" \
--volume "$repo$cacrt:/usr/share/elasticsearch/config/certs/ca.crt" \
--network=esnet-platinum \
--name=elasticsearch-platinum \
--detach \
docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION}
# run the client unit and oss integration test
docker run \
--network=esnet-oss \
--env "TEST_ES_SERVER=http://elasticsearch-oss:9200" \
--env "CODECOV_TOKEN" \
--volume $repo:/usr/src/app \
--volume /usr/src/app/node_modules \
--name elasticsearch-js-oss \
--rm \
elastic/elasticsearch-js \
npm run ci
# run the client platinium integration test
docker run \
--network=esnet-platinum \
--env "TEST_ES_SERVER=https://elastic:changeme@elasticsearch-platinum:9200" \
--volume $repo:/usr/src/app \
--volume /usr/src/app/node_modules \
--name elasticsearch-js-platinum \
--rm \
elastic/elasticsearch-js \
npm run test:integration
if [[ -n "$RUNSCRIPTS" ]]; then
for RUNSCRIPT in ${RUNSCRIPTS//,/ } ; do
echo -e "\033[1m>>>>> Running run-$RUNSCRIPT.sh >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
CONTAINER_NAME=${RUNSCRIPT} \
DETACH=true \
bash .ci/run-${RUNSCRIPT}.sh
done
fi
echo -e "\033[1m>>>>> Repository specific tests >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
bash .ci/run-repository.sh

View File

@ -1,11 +1,15 @@
---
ELASTICSEARCH_VERSION:
- 7.0.0-beta1
STACK_VERSION:
- 7.7.0-SNAPSHOT
NODE_JS_VERSION:
- 11
- 10
- 8
- 6
- 14
- 12
- 10
- 8
TEST_SUITE:
- oss
- xpack
exclude: ~

View File

@ -3,7 +3,7 @@
#### You have already researched for similar issues?
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
#### Are you sure this is an issue with @elastic/elasticsearch or are you just looking for some help?
#### Are you sure this is an issue with `@elastic/elasticsearch` or are you just looking for some help?
Issues should only be posted in this repository after you have been able to reproduce them and confirm that they are a bug or incorrect/missing information in the [docs](https://github.com/elastic/elasticsearch-js/docs).

View File

@ -23,6 +23,14 @@ Paste your code here:
```
<!--
In some cases, it might be challenging to reproduce the bug in a few lines of code.
You can fork the following repository, which contains all the configuration needed
to spin up a three nodes Elasticsearch cluster with security enabled.
The repository also contains a preconfigured client instance that you can use to reproduce the issue.
https://github.com/delvedor/es-reproduce-issue
--->
## Expected behavior
A clear and concise description of what you expected to happen.
@ -36,6 +44,6 @@ Paste the results here:
## Your Environment
- *node version*: 6,8,10
- *@elastic/elasticsearch version*: >=7.0.0
- `@elastic/elasticsearch` *version*: >=7.0.0
- *os*: Mac, Windows, Linux
- *any other relevant information*

View File

@ -29,6 +29,14 @@ Paste your code here:
```
<!--
In some cases, it might be challenging to reproduce the bug in a few lines of code.
You can fork the following repository, which contains all the configuration needed
to spin up a three nodes Elasticsearch cluster with security enabled.
The repository also contains a preconfigured client instance that you can use to reproduce the issue.
https://github.com/delvedor/es-reproduce-issue
--->
## Expected behavior
A clear and concise description of what you expected to happen.
@ -42,6 +50,6 @@ Paste the results here:
## Your Environment
- *node version*: 6,8,10
- *@elastic/elasticsearch version*: >=7.0.0
- `@elastic/elasticsearch` *version*: >=7.0.0
- *os*: Mac, Windows, Linux
- *any other relevant information*

1
.github/stale.yml vendored
View File

@ -9,6 +9,7 @@ exemptLabels:
- "discussion"
- "feature request"
- "bug"
- "todo"
# Label to use when marking an issue as stale
staleLabel: stale

16
.github/workflows/backport.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: Backport
on:
pull_request:
types:
- closed
- labeled
jobs:
backport:
runs-on: ubuntu-latest
name: Backport
steps:
- name: Backport
uses: tibdex/backport@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

156
.github/workflows/nodejs.yml vendored Normal file
View File

@ -0,0 +1,156 @@
name: Node CI
on: [push, pull_request]
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm install
- name: Lint
run: |
npm run lint
- name: Unit test
run: |
npm run test:unit
- name: Behavior test
run: |
npm run test:behavior
- name: Type Definitions
run: |
npm run test:types
test-node-v8:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [8.x]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm install
- name: Test
run: |
npm run test:unit -- --node-arg=--harmony-async-iteration
helpers-integration-test:
name: Helpers integration test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.7.0-SNAPSHOT
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm install
- name: Integration test
run: |
npm run test:integration:helpers
code-coverage:
name: Code coverage
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm install
- name: Code coverage
run: |
npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.lcov
fail_ci_if_error: true
license:
name: License check
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm install
- name: License checker
run: |
npm run license-checker

9
.gitignore vendored
View File

@ -45,13 +45,14 @@ jspm_packages
# vim swap files
*.swp
#Jetbrains editor folder
.idea
package-lock.json
# elasticsearch repo or binary files
elasticsearch*
# Generated typings, we don't commit them
# because we should copy them in the main .d.ts file
api/generated.d.ts
test/benchmarks/macro/fixtures/*
*-junit.xml

View File

@ -67,3 +67,6 @@ scripts
.ci
.travis.yml
certs
.github
CODE_OF_CONDUCT.md
CONTRIBUTING.md

View File

@ -1,31 +0,0 @@
dist: trusty
sudo: required
language: node_js
node_js:
- "10"
- "8"
- "6"
env:
global:
- ELASTICSEARCH_VERSION=7.0.0-beta1
- QUIET=true
before_install:
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}-linux-x86_64.tar.gz
- tar -xzf elasticsearch-${ELASTICSEARCH_VERSION}-linux-x86_64.tar.gz
- ./elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch -Enode.attr.testattr=test -Epath.repo=/tmp -Erepositories.url.allowed_urls='http://snapshot.*' &> /dev/null &
install:
- npm install
script:
- npm run ci
notifications:
email:
on_success: never
on_failure: always

3
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,3 @@
303 See Other
Location: https://www.elastic.co/community/codeofconduct

100
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,100 @@
# Contributing to the Elasticsearch Node.js client
The Elasticsearch Node.js client is open source and we love to receive contributions from our community — you!
There are many ways to contribute,
from writing tutorials or blog posts,
improving the documentation,
submitting bug reports and feature requests or writing code.
## Repository structure
The `master` branch is considered unstable, and it's compatible with Elasticsearch master. Unless you are patching an issue, new features should always be sent to the `master` branch, in case of a bugfix, it depends if the bug affects all the release lines.<br/>
There is a branch for every supported release line, such as `7.x` or `6.x`. We release bugfixes as soon as possible, while minor and major releases are published at the same time of the Elastic Stack.
Usually for every release line there will be a *published* version and a *next* version. Eg: the `7.x` branch contains the version published on npm, and bugfixes should be sent there, while `7.2` *(assuming that 7.1.x is released)* contains the next version, and new features should be sent there.
## Code contributions
If you have a bugfix or new feature that you would like to contribute,
please find or open an issue about it first.
Talk about what you would like to do.
It may be that somebody is already working on it,
or that there are particular issues that you should know about before implementing the change.
Note that we strictly follow the [Elastic EOL schedule](https://www.elastic.co/support/eol).
### Submitting your changes
Generally, we require that you test any code you are adding or modifying.
Once your changes are ready to submit for review:
1. Test your changes
Run the test suite to make sure that nothing is broken.
Usually run `npm test` is enough, our CI will take care of running the integration test. If you want to run the integration test yourself, see the *Testing* section below.
2. Submit a pull request
Push your local changes to your forked copy of the repository and [submit a pull request](https://help.github.com/articles/using-pull-requests).
In the pull request,
choose a title which sums up the changes that you have made,
and in the body provide more details about what your changes do.
Also mention the number of the issue where discussion has taken place,
eg "Closes #123".
3. Sign the Contributor License Agreement
Please make sure you have signed our [Contributor License Agreement](https://www.elastic.co/contributor-agreement/).
We are not asking you to assign copyright to us,
but to give us the right to distribute your code without restriction.
We ask this of all contributors in order to assure our users of the origin and continuing existence of the code.
You only need to sign the CLA once.
4. Be patient
We might not be able to review your code as fast as we would like to,
but we'll do our best to dedicate it the attention it deserves.
Your effort is much appreciated!
### Code generation
The entire content of the API folder is generated as well as the `docs/reference.asciidoc` file.<br/>
If you want to run the code generation you should run the following command:
```sh
node scripts/generate --tag <tag name>
# or
node scripts/generate --branch <branch name>
```
Then you should copy the content of `api/generated.d.ts` into the `index.d.ts` file *(automate this step would be a nice pr!)*.
### Testing
There are different test scripts, usually during development you only need to run `npm test`, but if you want you can run just a part of the suite, following you will find all the testing scripts and what they do.
| Script | Description |
|---|---|
| `npm run test:unit` | Runs the content of the `test/unit` folder. |
| `npm run test:behavior` | Runs the content of the `test/behavior` folder. |
| `npm run test:types` | Runs the content of the `test/types` folder. |
| `npm run test:unit -- --cov --coverage-report=html` | Runs the content of the `test/unit` folder and calculates the code coverage. |
| `npm run test:integration` | Runs the integration test runner.<br/>*Note: it requires a living instance of Elasticsearch.* |
| `npm run lint` | Run the [linter](https://standardjs.com/). |
| `npm run lint:fix` | Fixes the lint errors. |
| `npm test` | Runs lint, unit, behavior, and types test. |
#### Integration test
The integration test are generated on the fly by the runner you will find inside `test/integration`, once you execute it, it will clone the Elasticsearch repository and checkout the correct version to grab the [OSS yaml files](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/test) and the [Elastic licensed yaml files](https://github.com/elastic/elasticsearch/tree/master/x-pack/plugin/src/test/resources/rest-api-spec/test) that will be used for generating the test.
Usually this step is executed by CI since it takes some time, but you can easily run this yourself! Just follow this steps:
1. Boot an Elasticsearch instance, you can do that by running `./scripts/es-docker.sh` or `./scripts/es-docker-platinum.sh`, the first one will work only with the OSS APIs, while the second will work also with the Elastic licensed APIs;
1. If you are running the OSS test, you should use `npm run test:integration`, otherwise use `TEST_ES_SERVER=https://elastic:changeme@localhost:9200 npm run test:integration`. You can also pass a `-b` parameter if you want the test to bail out at the first failure: `npm run test:integration -- -b`;
1. Grab a coffee, it will take some time ;)
### Releasing
If you have access to make releases, the process is as follows:
1. Update the version in `package.json` according to the scale of the change. (major, minor or patch)
1. Commit changes with message `Bumped vx.y.z` where `x.y.z` is the version in `package.json`
1. Create a release via the GitHub UI.
1. Wait for CI to finish running the test.
1. Publish to npm with `npm publish` *(see [publish](https://docs.npmjs.com/cli/publish) and [dist-tag](https://docs.npmjs.com/cli/dist-tag) docs)*

View File

@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Copyright 2020 Elastic and contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

224
README.md
View File

@ -1,24 +1,24 @@
<img align="right" width="auto" height="auto" src="https://www.elastic.co/static-res/images/elastic-logo-200.png">
# @elastic/elasticsearch
# Elasticsearch Node.js client
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://clients-ci.elastic.co/job/elastic+elasticsearch-js+master/badge/icon)](https://clients-ci.elastic.co/job/elastic+elasticsearch-js+master/) [![codecov](https://codecov.io/gh/elastic/elasticsearch-js/branch/master/graph/badge.svg)](https://codecov.io/gh/elastic/elasticsearch-js) [![NPM downloads](https://img.shields.io/npm/dm/@elastic/elasticsearch.svg?style=flat)](https://www.npmjs.com/package/@elastic/elasticsearch)
---
**Note:** In the past months we have worked on the new Elasticsearch Node.js client, we will announce it soon!
If you want you can already try it by following the instructions below, while if you're going to use the legacy one or report an issue, please check out [elastic/elasticsearch-js-legacy](https://github.com/elastic/elasticsearch-js-legacy).
---
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://clients-ci.elastic.co/buildStatus/icon?job=elastic%2Belasticsearch-js%2Bmaster)](https://clients-ci.elastic.co/view/Javascript/job/elastic+elasticsearch-js+master/) [![codecov](https://codecov.io/gh/elastic/elasticsearch-js/branch/master/graph/badge.svg)](https://codecov.io/gh/elastic/elasticsearch-js) [![NPM downloads](https://img.shields.io/npm/dm/@elastic/elasticsearch.svg?style=flat)](https://www.npmjs.com/package/@elastic/elasticsearch)
The official Node.js client for Elasticsearch.
---
**Note:** In the past months we have worked on the new Elasticsearch Node.js client and you can use it by following the instructions below. If you're going to use the legacy one or report an issue, however, please check out [elastic/elasticsearch-js-legacy](https://github.com/elastic/elasticsearch-js-legacy).
---
## Features
- One-to-one mapping with REST API.
- Generalized, pluggable architecture.
- Configurable, automatic discovery of cluster nodes.
- Persistent, Keep-Alive connections.
- Load balancing (with pluggable selection strategy) across all available nodes.
- Load balancing across all available nodes.
- Child client support.
- TypeScript support out of the box.
## Install
@ -28,30 +28,54 @@ npm install @elastic/elasticsearch
### Compatibility
---
The minimum supported version of Node.js is `v8`.
**Warning:** currently on npm you will only find a beta release that works with Elasticsearch 7, we will add the support for Elasticsearch 5, 6, and 7 once we release the final version of this library.
The library is compatible with all Elasticsearch versions since 5.x, and you should use the same major version of the Elasticsearch instance that you are using.
---
| Elasticsearch Version | Client Version |
| --------------------- |----------------|
| `master` | `master` |
| `7.x` | `7.x` |
| `6.x` | `6.x` |
| `5.x` | `5.x` |
The library is compatible with all Elasticsearch versions since 5.x, but you should use the same major version of the Elasticsearch instance that you are using.
To install a specific major of the client, run the following command:
```
# Elasticsearch 7.x
@elastic/elasticsearch@7
# Elasticsearch 6.x
@elastic/elasticsearch@6
# Elasticsearch 5.x
@elastic/elasticsearch@5
npm install @elastic/elasticsearch@<major>
```
## Usage
You can find the full documentation in the [docs](https://github.com/elastic/elasticsearch-js/tree/master/docs) folder.
#### Browser
WARNING: There is no official support for the browser environment. It exposes your Elasticsearch instance to everyone, which could lead to security issues.
We recommend that you write a lightweight proxy that uses this client instead.
## Documentation
- [Introduction](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/introduction.html)
- [Changelog](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/changelog-client.html)
- [Usage](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-usage.html)
- [Client configuration](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-configuration.html)
- [API reference](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html)
- [Breaking changes coming from the old client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/breaking-changes.html)
- [Authentication](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html)
- [Observability](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/observability.html)
- [Creating a child client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/child-client.html)
- [Extend the client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/extend-client.html)
- [Client helpers](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-helpers.html)
- [Typescript support](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/typescript.html)
- [Testing](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-testing.html)
- [Examples](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/examples.html)
## Quick start
First of all, require the client and initialize it:
```js
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
```
You can use both the callback-style API and the promise-style API, both behave the same way.
```js
// promise API
const result = await client.search({
index: 'my-index',
@ -76,77 +100,99 @@ The returned value of **every** API call is formed as follows:
meta: object
}
```
### Client options
The client is designed to be easily configured as you see fit for your needs, following you can see all the possible options that you can use to configure it.
```ts
{
// the Elasticsearch endpoint to use
node: string | string[];
// alias of above
nodes: string | string[];
// custom connection class
Connection: typeof Connection;
// custom connection pool class
ConnectionPool: typeof ConnectionPool;
// custom transport class
Transport: typeof Transport;
// custom serializer class
Serializer: typeof Serializer;
// max number of retries for each request
maxRetries: number;
// max request timeout for each request
requestTimeout: number;
// max ping timeout for each request
pingTimeout: number;
// perform a sniff operation every `n` milliseconds
sniffInterval: number;
// perform a sniff once the client is started
sniffOnStart: boolean;
// custom sniff endpoint, defaults `_nodes/_all/http`
sniffEndpoint: string;
// perform a sniff on connection fault
sniffOnConnectionFault: boolean;
// configurethe node resurrection strategy, default `ping`
resurrectStrategy: 'ping' | 'optimistic' | 'none';
// adds `accept-encoding` header to every request
suggestCompression: boolean;
// enable gzip request body compression
compression: 'gzip';
// ssl configuraton
ssl: http.SecureContextOptions;
// http agent options
agent: http.AgentOptions;
// filters which node not to use for a request
nodeFilter: nodeFilterFn;
// custom selection strategy, defaults `round-robin`
nodeSelector: nodeSelectorFn | string;
Let's see a complete example!
```js
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
async function run () {
// Let's start by indexing some data
await client.index({
index: 'game-of-thrones',
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6
body: {
character: 'Ned Stark',
quote: 'Winter is coming.'
}
})
await client.index({
index: 'game-of-thrones',
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6
body: {
character: 'Daenerys Targaryen',
quote: 'I am the blood of the dragon.'
}
})
await client.index({
index: 'game-of-thrones',
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6
body: {
character: 'Tyrion Lannister',
quote: 'A mind needs books like a sword needs a whetstone.'
}
})
// here we are forcing an index refresh, otherwise we will not
// get any result in the consequent search
await client.indices.refresh({ index: 'game-of-thrones' })
// Let's search!
const { body } = await client.search({
index: 'game-of-thrones',
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6
body: {
query: {
match: { quote: 'winter' }
}
}
})
console.log(body.hits.hits)
}
run().catch(console.log)
```
### Request specific options
If needed you can pass request specific options in a second object:
```js
// promise API
const result = await client.search({
index: 'my-index',
body: { foo: 'bar' }
}, {
ignore: [404],
maxRetries: 3
})
## Install multiple versions
If you are using multiple versions of Elasticsearch, you need to use multiple versions of the client. In the past, install multiple versions of the same package was not possible, but with `npm v6.9`, you can do that via aliasing.
The command you must run to install different version of the client is:
```sh
npm install <alias>@npm:@elastic/elasticsearch@<version>
```
The supported *request specific options* are:
```ts
{
ignore: [number], // default `null`
requestTimeout: number, // client default
maxRetries: number, // default `5`
asStream: boolean, // default `false`
compression: string, // default `false`
headers: object, // default `null`
querystring: object // default `null`
So for example if you need to install `7.x` and `6.x`, you will run
```sh
npm install es6@npm:@elastic/elasticsearch@6
npm install es7@npm:@elastic/elasticsearch@7
```
And your `package.json` will look like the following:
```json
"dependencies": {
"es6": "npm:@elastic/elasticsearch@^6.7.0",
"es7": "npm:@elastic/elasticsearch@^7.0.0"
}
```
You will require the packages from your code by using the alias you have defined.
```js
const { Client: Client6 } = require('es6')
const { Client: Client7 } = require('es7')
const client6 = new Client6({ node: 'http://localhost:9200' })
const client7 = new Client7({ node: 'http://localhost:9201' })
client6.info(console.log)
client7.info(console.log)
```
Finally, if you want to install the client for the next version of Elasticsearch *(the one that lives in Elasticsearchs master branch)*, you can use the following command:
```sh
npm install esmaster@github:elastic/elasticsearch-js
```
## License

View File

@ -0,0 +1,78 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildAsyncSearchDelete (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a async_search.delete request
* Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
*/
return function asyncSearchDelete (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['id'] == null) {
const err = new ConfigurationError('Missing required parameter: id')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'DELETE'
path = '/' + '_async_search' + '/' + encodeURIComponent(id)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildAsyncSearchDelete

View File

@ -0,0 +1,82 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildAsyncSearchGet (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'wait_for_completion_timeout',
'keep_alive',
'typed_keys'
]
const snakeCase = {
waitForCompletionTimeout: 'wait_for_completion_timeout',
keepAlive: 'keep_alive',
typedKeys: 'typed_keys'
}
/**
* Perform a async_search.get request
* Retrieves the results of a previously submitted async search request given its ID.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
*/
return function asyncSearchGet (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['id'] == null) {
const err = new ConfigurationError('Missing required parameter: id')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_async_search' + '/' + encodeURIComponent(id)
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildAsyncSearchGet

View File

@ -0,0 +1,147 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildAsyncSearchSubmit (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'wait_for_completion_timeout',
'keep_on_completion',
'keep_alive',
'batched_reduce_size',
'request_cache',
'analyzer',
'analyze_wildcard',
'default_operator',
'df',
'explain',
'stored_fields',
'docvalue_fields',
'from',
'ignore_unavailable',
'ignore_throttled',
'allow_no_indices',
'expand_wildcards',
'lenient',
'preference',
'q',
'routing',
'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',
'max_concurrent_shard_requests'
]
const snakeCase = {
waitForCompletionTimeout: 'wait_for_completion_timeout',
keepOnCompletion: 'keep_on_completion',
keepAlive: 'keep_alive',
batchedReduceSize: 'batched_reduce_size',
requestCache: 'request_cache',
analyzeWildcard: 'analyze_wildcard',
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',
maxConcurrentShardRequests: 'max_concurrent_shard_requests'
}
/**
* Perform a async_search.submit request
* Executes a search request asynchronously.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
*/
return function asyncSearchSubmit (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null) {
if (method == null) method = 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_async_search'
} else {
if (method == null) method = 'POST'
path = '/' + '_async_search'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildAsyncSearchSubmit

View File

@ -0,0 +1,72 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildAutoscalingGetAutoscalingDecision (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a autoscaling.get_autoscaling_decision request
* Gets the current autoscaling decision based on the configured autoscaling policy, indicating whether or not autoscaling is needed.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-decision.html
*/
return function autoscalingGetAutoscalingDecision (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_autoscaling' + '/' + 'decision'
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildAutoscalingGetAutoscalingDecision

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,23 +9,7 @@
function buildBulk (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [bulk](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html) request
*
* @param {string} index - Default index for items which don't provide one
* @param {string} type - Default document type for items which don't provide one
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
* @param {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout
* @param {string} type - Default document type for items which don't provide one
* @param {list} _source - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request
* @param {list} _source_excludes - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
* @param {list} _source_includes - Default list of fields to extract and return from the _source field, can be overridden on each sub-request
* @param {string} pipeline - The pipeline id to preprocess incoming documents with
* @param {object} body - The operation definition and data (action-data pairs), separated by newlines
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'wait_for_active_shards',
@ -50,7 +19,9 @@ function buildBulk (opts) {
'type',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'pipeline',
'pretty',
'human',
@ -62,11 +33,18 @@ function buildBulk (opts) {
const snakeCase = {
waitForActiveShards: 'wait_for_active_shards',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a bulk request
* Allows to perform multiple index/update/delete operations in a single request.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html
*/
return function bulk (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -97,26 +75,25 @@ function buildBulk (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, index, type } = params
var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
var warnings = []
var { method, body, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null) {
if (method == null) method = 'POST'
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_bulk'
} else if ((index) != null) {
if (method == null) method = 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_bulk'
} else {
if (method == null) method = 'POST'
path = '/' + '_bulk'
}
@ -128,34 +105,8 @@ function buildBulk (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,28 +9,16 @@
function buildCatAliases (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.aliases](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html) request
*
* @param {list} name - A comma-separated list of alias names to return
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
'local',
'master_timeout',
'h',
'help',
's',
'v',
'expand_wildcards',
'pretty',
'human',
'error_trace',
@ -54,11 +27,16 @@ function buildCatAliases (opts) {
]
const snakeCase = {
masterTimeout: 'master_timeout',
expandWildcards: 'expand_wildcards',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cat.aliases request
* Shows information about currently configured aliases to indices including filter and routing infos.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html
*/
return function catAliases (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -71,36 +49,28 @@ function buildCatAliases (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, name } = params
var querystring = semicopy(params, ['method', 'body', 'name'])
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((name) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(name)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'aliases'
}
@ -112,34 +82,8 @@ function buildCatAliases (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,20 +9,7 @@
function buildCatAllocation (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.allocation](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html) request
*
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {enum} bytes - The unit in which to display byte values
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -61,6 +33,11 @@ function buildCatAllocation (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.allocation request
* Provides a snapshot of how many shards are allocated to each data node and how much disk space they are using.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html
*/
return function catAllocation (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -73,36 +50,28 @@ function buildCatAllocation (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, nodeId, node_id } = params
var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id'])
var warnings = []
var { method, body, nodeId, node_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((node_id || nodeId) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(node_id || nodeId)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'allocation'
}
@ -114,34 +83,8 @@ function buildCatAllocation (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,24 +9,10 @@
function buildCatCount (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.count](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html) request
*
* @param {list} index - A comma-separated list of index names to limit the returned information
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
'local',
'master_timeout',
'h',
'help',
's',
@ -54,11 +25,15 @@ function buildCatCount (opts) {
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cat.count request
* Provides quick access to the document count of the entire cluster, or individual indices.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html
*/
return function catCount (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -71,36 +46,28 @@ function buildCatCount (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(index)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'count'
}
@ -112,34 +79,8 @@ function buildCatCount (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,27 +9,11 @@
function buildCatFielddata (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.fielddata](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html) request
*
* @param {list} fields - A comma-separated list of fields to return the fielddata size
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {enum} bytes - The unit in which to display byte values
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
* @param {list} fields - A comma-separated list of fields to return in the output
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
'bytes',
'local',
'master_timeout',
'h',
'help',
's',
@ -58,11 +27,15 @@ function buildCatFielddata (opts) {
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cat.fielddata request
* Shows how much heap memory is currently being used by fielddata on every data node in the cluster.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html
*/
return function catFielddata (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -75,36 +48,28 @@ function buildCatFielddata (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, fields } = params
var querystring = semicopy(params, ['method', 'body', 'fields'])
var warnings = []
var { method, body, fields, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((fields) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(fields)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'fielddata'
}
@ -116,34 +81,8 @@ function buildCatFielddata (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,27 +9,14 @@
function buildCatHealth (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html) request
*
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} ts - Set to false to disable timestamping
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
'local',
'master_timeout',
'h',
'help',
's',
'time',
'ts',
'v',
'pretty',
@ -55,11 +27,15 @@ function buildCatHealth (opts) {
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cat.health request
* Returns a concise representation of the cluster health.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html
*/
return function catHealth (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -72,33 +48,24 @@ function buildCatHealth (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'health'
// build request object
@ -109,34 +76,8 @@ function buildCatHealth (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,13 +9,7 @@
function buildCatHelp (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.help](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html) request
*
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'help',
@ -47,6 +26,11 @@ function buildCatHelp (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.help request
* Returns help for the Cat APIs.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html
*/
return function catHelp (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -59,33 +43,24 @@ function buildCatHelp (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cat'
// build request object
@ -96,34 +71,8 @@ function buildCatHelp (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,22 +9,7 @@
function buildCatIndices (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.indices](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html) request
*
* @param {list} index - A comma-separated list of index names to limit the returned information
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {enum} bytes - The unit in which to display byte values
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {enum} health - A health status ("green", "yellow", or "red" to filter only indices matching the specified health status
* @param {boolean} help - Return help information
* @param {boolean} pri - Set to true to return stats only for primary shards
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -51,7 +21,10 @@ function buildCatIndices (opts) {
'help',
'pri',
's',
'time',
'v',
'include_unloaded_segments',
'expand_wildcards',
'pretty',
'human',
'error_trace',
@ -61,10 +34,17 @@ function buildCatIndices (opts) {
const snakeCase = {
masterTimeout: 'master_timeout',
includeUnloadedSegments: 'include_unloaded_segments',
expandWildcards: 'expand_wildcards',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cat.indices request
* Returns information about indices: number of primaries and replicas, document counts, disk size, ...
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html
*/
return function catIndices (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -77,36 +57,28 @@ function buildCatIndices (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(index)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'indices'
}
@ -118,34 +90,8 @@ function buildCatIndices (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,18 +9,7 @@
function buildCatMaster (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.master](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html) request
*
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -58,6 +32,11 @@ function buildCatMaster (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.master request
* Returns information about the master node.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html
*/
return function catMaster (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -70,33 +49,24 @@ function buildCatMaster (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'master'
// build request object
@ -107,34 +77,8 @@ function buildCatMaster (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -0,0 +1,85 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildCatMlDataFrameAnalytics (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'bytes',
'format',
'h',
'help',
's',
'time',
'v'
]
const snakeCase = {
allowNoMatch: 'allow_no_match'
}
/**
* Perform a cat.ml_data_frame_analytics request
* Gets configuration and usage information about data frame analytics jobs.
* http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-dfanalytics.html
*/
return function catMlDataFrameAnalytics (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((id) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'ml' + '/' + 'data_frame' + '/' + 'analytics'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCatMlDataFrameAnalytics

View File

@ -0,0 +1,84 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildCatMlDatafeeds (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_datafeeds',
'format',
'h',
'help',
's',
'time',
'v'
]
const snakeCase = {
allowNoDatafeeds: 'allow_no_datafeeds'
}
/**
* Perform a cat.ml_datafeeds request
* Gets configuration and usage information about datafeeds.
* http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html
*/
return function catMlDatafeeds (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, datafeedId, datafeed_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((datafeed_id || datafeedId) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'ml' + '/' + 'datafeeds'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCatMlDatafeeds

85
api/api/cat.ml_jobs.js Normal file
View File

@ -0,0 +1,85 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildCatMlJobs (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_jobs',
'bytes',
'format',
'h',
'help',
's',
'time',
'v'
]
const snakeCase = {
allowNoJobs: 'allow_no_jobs'
}
/**
* Perform a cat.ml_jobs request
* Gets configuration and usage information about anomaly detection jobs.
* http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html
*/
return function catMlJobs (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, jobId, job_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((job_id || jobId) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCatMlJobs

View File

@ -0,0 +1,87 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildCatMlTrainedModels (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'from',
'size',
'bytes',
'format',
'h',
'help',
's',
'time',
'v'
]
const snakeCase = {
allowNoMatch: 'allow_no_match'
}
/**
* Perform a cat.ml_trained_models request
* Gets configuration and usage information about inference trained models.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html
*/
return function catMlTrainedModels (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, modelId, model_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((model_id || modelId) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'ml' + '/' + 'trained_models' + '/' + encodeURIComponent(model_id || modelId)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'ml' + '/' + 'trained_models'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCatMlTrainedModels

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,18 +9,7 @@
function buildCatNodeattrs (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.nodeattrs](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html) request
*
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -58,6 +32,11 @@ function buildCatNodeattrs (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.nodeattrs request
* Returns information about custom node attributes.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html
*/
return function catNodeattrs (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -70,33 +49,24 @@ function buildCatNodeattrs (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'nodeattrs'
// build request object
@ -107,34 +77,8 @@ function buildCatNodeattrs (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,21 +9,10 @@
function buildCatNodes (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.nodes](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html) request
*
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} full_id - Return the full node ID instead of the shortened version (default: false)
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'bytes',
'format',
'full_id',
'local',
@ -46,6 +20,7 @@ function buildCatNodes (opts) {
'h',
'help',
's',
'time',
'v',
'pretty',
'human',
@ -61,6 +36,11 @@ function buildCatNodes (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.nodes request
* Returns basic statistics about performance of cluster nodes.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html
*/
return function catNodes (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -73,33 +53,24 @@ function buildCatNodes (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'nodes'
// build request object
@ -110,34 +81,8 @@ function buildCatNodes (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,18 +9,7 @@
function buildCatPendingTasks (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html) request
*
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -44,6 +18,7 @@ function buildCatPendingTasks (opts) {
'h',
'help',
's',
'time',
'v',
'pretty',
'human',
@ -58,6 +33,11 @@ function buildCatPendingTasks (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.pending_tasks request
* Returns a concise representation of the cluster pending tasks.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html
*/
return function catPendingTasks (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -70,33 +50,24 @@ function buildCatPendingTasks (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'pending_tasks'
// build request object
@ -107,34 +78,8 @@ function buildCatPendingTasks (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,18 +9,7 @@
function buildCatPlugins (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.plugins](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html) request
*
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -58,6 +32,11 @@ function buildCatPlugins (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.plugins request
* Returns information about installed plugins across nodes node.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html
*/
return function catPlugins (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -70,33 +49,24 @@ function buildCatPlugins (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'plugins'
// build request object
@ -107,34 +77,8 @@ function buildCatPlugins (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,27 +9,18 @@
function buildCatRecovery (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html) request
*
* @param {list} index - A comma-separated list of index names to limit the returned information
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {enum} bytes - The unit in which to display byte values
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
'active_only',
'bytes',
'master_timeout',
'detailed',
'h',
'help',
'index',
's',
'time',
'v',
'pretty',
'human',
@ -54,11 +30,16 @@ function buildCatRecovery (opts) {
]
const snakeCase = {
masterTimeout: 'master_timeout',
activeOnly: 'active_only',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cat.recovery request
* Returns information about index shard recoveries, both on-going completed.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html
*/
return function catRecovery (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -71,36 +52,28 @@ function buildCatRecovery (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(index)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'recovery'
}
@ -112,34 +85,8 @@ function buildCatRecovery (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,18 +9,7 @@
function buildCatRepositories (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.repositories](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html) request
*
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} local - Return local information, do not retrieve the state from master node
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -58,6 +32,11 @@ function buildCatRepositories (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.repositories request
* Returns information about snapshot repositories registered in the cluster.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html
*/
return function catRepositories (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -70,33 +49,24 @@ function buildCatRepositories (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'repositories'
// build request object
@ -107,34 +77,8 @@ function buildCatRepositories (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,18 +9,7 @@
function buildCatSegments (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.segments](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html) request
*
* @param {list} index - A comma-separated list of index names to limit the returned information
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {enum} bytes - The unit in which to display byte values
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -56,6 +30,11 @@ function buildCatSegments (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.segments request
* Provides low-level information about the segments in the shards of an index.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html
*/
return function catSegments (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -68,36 +47,28 @@ function buildCatSegments (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(index)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'segments'
}
@ -109,34 +80,8 @@ function buildCatSegments (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,20 +9,7 @@
function buildCatShards (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.shards](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html) request
*
* @param {list} index - A comma-separated list of index names to limit the returned information
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {enum} bytes - The unit in which to display byte values
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -47,6 +19,7 @@ function buildCatShards (opts) {
'h',
'help',
's',
'time',
'v',
'pretty',
'human',
@ -61,6 +34,11 @@ function buildCatShards (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.shards request
* Provides a detailed view of shard allocation on nodes.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html
*/
return function catShards (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -73,36 +51,28 @@ function buildCatShards (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(index)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'shards'
}
@ -114,34 +84,8 @@ function buildCatShards (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,19 +9,7 @@
function buildCatSnapshots (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html) request
*
* @param {list} repository - Name of repository from which to fetch the snapshot information
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} ignore_unavailable - Set to true to ignore unavailable snapshots
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -45,6 +18,7 @@ function buildCatSnapshots (opts) {
'h',
'help',
's',
'time',
'v',
'pretty',
'human',
@ -60,6 +34,11 @@ function buildCatSnapshots (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.snapshots request
* Returns all snapshots in a specific repository.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html
*/
return function catSnapshots (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -72,36 +51,28 @@ function buildCatSnapshots (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, repository } = params
var querystring = semicopy(params, ['method', 'body', 'repository'])
var warnings = []
var { method, body, repository, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((repository) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(repository)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'snapshots'
}
@ -113,34 +84,8 @@ function buildCatSnapshots (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,20 +9,7 @@
function buildCatTasks (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request
*
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* @param {list} actions - A comma-separated list of actions that should be returned. Leave empty to return all.
* @param {boolean} detailed - Return detailed task information (default: false)
* @param {number} parent_task - Return tasks with specified parent task id. Set to -1 to return all.
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -48,6 +20,7 @@ function buildCatTasks (opts) {
'h',
'help',
's',
'time',
'v',
'pretty',
'human',
@ -63,6 +36,11 @@ function buildCatTasks (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.tasks request
* Returns information about the tasks currently executing on one or more nodes in the cluster.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html
*/
return function catTasks (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -75,33 +53,24 @@ function buildCatTasks (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'tasks'
// build request object
@ -112,34 +81,8 @@ function buildCatTasks (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,19 +9,7 @@
function buildCatTemplates (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.templates](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html) request
*
* @param {string} name - A pattern that returned template names must match
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -59,6 +32,11 @@ function buildCatTemplates (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.templates request
* Returns information about existing templates.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html
*/
return function catTemplates (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -71,36 +49,28 @@ function buildCatTemplates (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, name } = params
var querystring = semicopy(params, ['method', 'body', 'name'])
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((name) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(name)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'templates'
}
@ -112,34 +82,8 @@ function buildCatTemplates (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,20 +9,7 @@
function buildCatThreadPool (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cat.thread_pool](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html) request
*
* @param {list} thread_pool_patterns - A comma-separated list of regular-expressions to filter the thread pools in the output
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {enum} size - The multiplier in which to display values
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'format',
@ -61,6 +33,12 @@ function buildCatThreadPool (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cat.thread_pool request
* Returns cluster-wide thread pool statistics per node.
By default the active, queue and rejected statistics are returned for all thread pools.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html
*/
return function catThreadPool (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -73,36 +51,28 @@ function buildCatThreadPool (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, threadPoolPatterns, thread_pool_patterns } = params
var querystring = semicopy(params, ['method', 'body', 'threadPoolPatterns', 'thread_pool_patterns'])
var warnings = []
var { method, body, threadPoolPatterns, thread_pool_patterns, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((thread_pool_patterns || threadPoolPatterns) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'thread_pool' + '/' + encodeURIComponent(thread_pool_patterns || threadPoolPatterns)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'thread_pool'
}
@ -114,34 +84,8 @@ function buildCatThreadPool (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

86
api/api/cat.transforms.js Normal file
View File

@ -0,0 +1,86 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildCatTransforms (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'from',
'size',
'allow_no_match',
'format',
'h',
'help',
's',
'time',
'v'
]
const snakeCase = {
allowNoMatch: 'allow_no_match'
}
/**
* Perform a cat.transforms request
* Gets configuration and usage information about transforms.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html
*/
return function catTransforms (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, transformId, transform_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((transform_id || transformId) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'transforms'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCatTransforms

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,12 +9,7 @@
function buildCcrDeleteAutoFollowPattern (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [ccr.delete_auto_follow_pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html) request
*
* @param {string} name - The name of the auto follow pattern.
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
@ -39,6 +19,11 @@ function buildCcrDeleteAutoFollowPattern (opts) {
}
/**
* Perform a ccr.delete_auto_follow_pattern request
* Deletes auto-follow patterns.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html
*/
return function ccrDeleteAutoFollowPattern (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -63,21 +48,18 @@ function buildCcrDeleteAutoFollowPattern (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, name } = params
var querystring = semicopy(params, ['method', 'body', 'name'])
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'DELETE'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'DELETE'
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name)
// build request object
@ -88,34 +70,8 @@ function buildCcrDeleteAutoFollowPattern (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,14 +9,7 @@
function buildCcrFollow (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [ccr.follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html) request
*
* @param {string} index - The name of the follower index
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {object} body - The name of the leader index and other optional ccr related parameters
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'wait_for_active_shards'
@ -41,6 +19,11 @@ function buildCcrFollow (opts) {
waitForActiveShards: 'wait_for_active_shards'
}
/**
* Perform a ccr.follow request
* Creates a new follower index configured to follow the referenced leader index.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html
*/
return function ccrFollow (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -69,21 +52,18 @@ function buildCcrFollow (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'PUT'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'PUT'
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'follow'
// build request object
@ -94,34 +74,8 @@ function buildCcrFollow (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,12 +9,7 @@
function buildCcrFollowInfo (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [ccr.follow_info](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html) request
*
* @param {list} index - A comma-separated list of index patterns; use `_all` to perform the operation on all indices
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
@ -39,6 +19,11 @@ function buildCcrFollowInfo (opts) {
}
/**
* Perform a ccr.follow_info request
* Retrieves information about all follower indices, including parameters and status for each follower index
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html
*/
return function ccrFollowInfo (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -51,27 +36,30 @@ function buildCcrFollowInfo (opts) {
options = {}
}
// check required parameters
if (params['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'info'
// build request object
@ -82,34 +70,8 @@ function buildCcrFollowInfo (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,12 +9,7 @@
function buildCcrFollowStats (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [ccr.follow_stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html) request
*
* @param {list} index - A comma-separated list of index patterns; use `_all` to perform the operation on all indices
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
@ -39,6 +19,11 @@ function buildCcrFollowStats (opts) {
}
/**
* Perform a ccr.follow_stats request
* Retrieves follower stats. return shard-level stats about the following tasks associated with each shard for the specified indices.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html
*/
return function ccrFollowStats (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -51,27 +36,30 @@ function buildCcrFollowStats (opts) {
options = {}
}
// check required parameters
if (params['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'stats'
// build request object
@ -82,34 +70,8 @@ function buildCcrFollowStats (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -0,0 +1,82 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildCcrForgetFollower (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a ccr.forget_follower request
* Removes the follower retention leases from the leader.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-forget-follower.html
*/
return function ccrForgetFollower (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'forget_follower'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCcrForgetFollower

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,12 +9,7 @@
function buildCcrGetAutoFollowPattern (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [ccr.get_auto_follow_pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html) request
*
* @param {string} name - The name of the auto follow pattern.
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
@ -39,6 +19,11 @@ function buildCcrGetAutoFollowPattern (opts) {
}
/**
* Perform a ccr.get_auto_follow_pattern request
* Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html
*/
return function ccrGetAutoFollowPattern (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -57,24 +42,22 @@ function buildCcrGetAutoFollowPattern (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, name } = params
var querystring = semicopy(params, ['method', 'body', 'name'])
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((name) != null) {
if (method == null) method = 'GET'
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name)
} else {
if (method == null) method = 'GET'
path = '/' + '_ccr' + '/' + 'auto_follow'
}
@ -86,34 +69,8 @@ function buildCcrGetAutoFollowPattern (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -0,0 +1,78 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildCcrPauseAutoFollowPattern (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a ccr.pause_auto_follow_pattern request
* Pauses an auto-follow pattern
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-auto-follow-pattern.html
*/
return function ccrPauseAutoFollowPattern (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['name'] == null) {
const err = new ConfigurationError('Missing required parameter: name')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'POST'
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + '/' + 'pause'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCcrPauseAutoFollowPattern

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,12 +9,7 @@
function buildCcrPauseFollow (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [ccr.pause_follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html) request
*
* @param {string} index - The name of the follower index that should pause following its leader index.
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
@ -39,6 +19,11 @@ function buildCcrPauseFollow (opts) {
}
/**
* Perform a ccr.pause_follow request
* Pauses a follower index. The follower index will not fetch any additional operations from the leader index.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html
*/
return function ccrPauseFollow (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -63,21 +48,18 @@ function buildCcrPauseFollow (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'pause_follow'
// build request object
@ -88,34 +70,8 @@ function buildCcrPauseFollow (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,13 +9,7 @@
function buildCcrPutAutoFollowPattern (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [ccr.put_auto_follow_pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html) request
*
* @param {string} name - The name of the auto follow pattern.
* @param {object} body - The specification of the auto follow pattern
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
@ -40,6 +19,11 @@ function buildCcrPutAutoFollowPattern (opts) {
}
/**
* Perform a ccr.put_auto_follow_pattern request
* Creates a new named collection of auto-follow patterns against a specified remote cluster. Newly created indices on the remote cluster matching any of the specified patterns will be automatically configured as follower indices.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html
*/
return function ccrPutAutoFollowPattern (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -68,21 +52,18 @@ function buildCcrPutAutoFollowPattern (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, name } = params
var querystring = semicopy(params, ['method', 'body', 'name'])
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'PUT'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'PUT'
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name)
// build request object
@ -93,34 +74,8 @@ function buildCcrPutAutoFollowPattern (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -0,0 +1,78 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildCcrResumeAutoFollowPattern (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a ccr.resume_auto_follow_pattern request
* Resumes an auto-follow pattern that has been paused
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-auto-follow-pattern.html
*/
return function ccrResumeAutoFollowPattern (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['name'] == null) {
const err = new ConfigurationError('Missing required parameter: name')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'POST'
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + '/' + 'resume'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCcrResumeAutoFollowPattern

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,13 +9,7 @@
function buildCcrResumeFollow (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [ccr.resume_follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html) request
*
* @param {string} index - The name of the follow index to resume following.
* @param {object} body - The name of the leader index and other optional ccr related parameters
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
@ -40,6 +19,11 @@ function buildCcrResumeFollow (opts) {
}
/**
* Perform a ccr.resume_follow request
* Resumes a follower index that has been paused
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html
*/
return function ccrResumeFollow (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -64,21 +48,18 @@ function buildCcrResumeFollow (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'resume_follow'
// build request object
@ -89,34 +70,8 @@ function buildCcrResumeFollow (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,11 +9,7 @@
function buildCcrStats (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [ccr.stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html) request
*
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
@ -38,6 +19,11 @@ function buildCcrStats (opts) {
}
/**
* Perform a ccr.stats request
* Gets all stats related to cross-cluster replication.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html
*/
return function ccrStats (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -56,21 +42,18 @@ function buildCcrStats (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_ccr' + '/' + 'stats'
// build request object
@ -81,34 +64,8 @@ function buildCcrStats (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,12 +9,7 @@
function buildCcrUnfollow (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [ccr.unfollow](http://www.elastic.co/guide/en/elasticsearch/reference/current) request
*
* @param {string} index - The name of the follower index that should be turned into a regular index.
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
@ -39,6 +19,11 @@ function buildCcrUnfollow (opts) {
}
/**
* Perform a ccr.unfollow request
* Stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-unfollow.html
*/
return function ccrUnfollow (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -63,21 +48,18 @@ function buildCcrUnfollow (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'unfollow'
// build request object
@ -88,34 +70,8 @@ function buildCcrUnfollow (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,13 +9,7 @@
function buildClearScroll (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [clear_scroll](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html) request
*
* @param {list} scroll_id - A comma-separated list of scroll IDs to clear
* @param {object} body - A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'pretty',
@ -45,6 +24,11 @@ function buildClearScroll (opts) {
filterPath: 'filter_path'
}
/**
* Perform a clear_scroll request
* Explicitly clears the search context for a scroll.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#_clear_scroll_api
*/
return function clearScroll (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -63,24 +47,22 @@ function buildClearScroll (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, scrollId, scroll_id } = params
var querystring = semicopy(params, ['method', 'body', 'scrollId', 'scroll_id'])
var warnings = []
var { method, body, scrollId, scroll_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'DELETE'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((scroll_id || scrollId) != null) {
if (method == null) method = 'DELETE'
path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId)
} else {
if (method == null) method = 'DELETE'
path = '/' + '_search' + '/' + 'scroll'
}
@ -92,34 +74,8 @@ function buildClearScroll (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,14 +9,7 @@
function buildClusterAllocationExplain (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cluster.allocation_explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html) request
*
* @param {boolean} include_yes_decisions - Return 'YES' decisions in explanation (default: false)
* @param {boolean} include_disk_info - Return information about disk usage and shard sizes (default: false)
* @param {object} body - The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard'
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'include_yes_decisions',
@ -50,6 +28,11 @@ function buildClusterAllocationExplain (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cluster.allocation_explain request
* Provides explanations for shard allocations in the cluster.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html
*/
return function clusterAllocationExplain (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -68,21 +51,18 @@ function buildClusterAllocationExplain (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = body == null ? 'GET' : 'POST'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = body == null ? 'GET' : 'POST'
path = '/' + '_cluster' + '/' + 'allocation' + '/' + 'explain'
// build request object
@ -93,34 +73,8 @@ function buildClusterAllocationExplain (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -0,0 +1,86 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildClusterDeleteComponentTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'timeout',
'master_timeout',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cluster.delete_component_template request
* Deletes a component template
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
*/
return function clusterDeleteComponentTemplate (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['name'] == null) {
const err = new ConfigurationError('Missing required parameter: name')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'DELETE'
path = '/' + '_component_template' + '/' + encodeURIComponent(name)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildClusterDeleteComponentTemplate

View File

@ -0,0 +1,85 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildClusterGetComponentTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'master_timeout',
'local',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cluster.get_component_template request
* Returns one or more component templates
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
*/
return function clusterGetComponentTemplate (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((name) != null) {
if (method == null) method = 'GET'
path = '/' + '_component_template' + '/' + encodeURIComponent(name)
} else {
if (method == null) method = 'GET'
path = '/' + '_component_template'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildClusterGetComponentTemplate

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,15 +9,7 @@
function buildClusterGetSettings (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cluster.get_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request
*
* @param {boolean} flat_settings - Return settings in flat format (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {time} timeout - Explicit operation timeout
* @param {boolean} include_defaults - Whether to return all default clusters setting.
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'flat_settings',
@ -54,6 +31,11 @@ function buildClusterGetSettings (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cluster.get_settings request
* Returns cluster settings.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html
*/
return function clusterGetSettings (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -66,33 +48,24 @@ function buildClusterGetSettings (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cluster' + '/' + 'settings'
// build request object
@ -103,34 +76,8 @@ function buildClusterGetSettings (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,24 +9,10 @@
function buildClusterHealth (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cluster.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html) request
*
* @param {list} index - Limit the information returned to a specific index
* @param {enum} level - Specify the level of detail for returned information
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {time} timeout - Explicit operation timeout
* @param {string} wait_for_active_shards - Wait until the specified number of shards is active
* @param {string} wait_for_nodes - Wait until the specified number of nodes is available
* @param {enum} wait_for_events - Wait until all currently queued events with the given priority are processed
* @param {boolean} wait_for_no_relocating_shards - Whether to wait until there are no relocating shards in the cluster
* @param {boolean} wait_for_no_initializing_shards - Whether to wait until there are no initializing shards in the cluster
* @param {enum} wait_for_status - Wait until cluster is in a specific state
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'expand_wildcards',
'level',
'local',
'master_timeout',
@ -60,6 +31,7 @@ function buildClusterHealth (opts) {
]
const snakeCase = {
expandWildcards: 'expand_wildcards',
masterTimeout: 'master_timeout',
waitForActiveShards: 'wait_for_active_shards',
waitForNodes: 'wait_for_nodes',
@ -71,6 +43,11 @@ function buildClusterHealth (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cluster.health request
* Returns basic information about the health of the cluster.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html
*/
return function clusterHealth (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -83,36 +60,28 @@ function buildClusterHealth (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null) {
if (method == null) method = 'GET'
path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(index)
} else {
if (method == null) method = 'GET'
path = '/' + '_cluster' + '/' + 'health'
}
@ -124,34 +93,8 @@ function buildClusterHealth (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,13 +9,7 @@
function buildClusterPendingTasks (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cluster.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html) request
*
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Specify timeout for connection to master
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'local',
@ -48,6 +27,12 @@ function buildClusterPendingTasks (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cluster.pending_tasks request
* Returns a list of any cluster-level changes (e.g. create index, update mapping,
allocate or fail shard) which have not yet been executed.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html
*/
return function clusterPendingTasks (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -60,33 +45,24 @@ function buildClusterPendingTasks (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_cluster' + '/' + 'pending_tasks'
// build request object
@ -97,34 +73,8 @@ function buildClusterPendingTasks (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -0,0 +1,91 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildClusterPutComponentTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'create',
'timeout',
'master_timeout',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cluster.put_component_template request
* Creates or updates a component template
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
*/
return function clusterPutComponentTemplate (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['name'] == null) {
const err = new ConfigurationError('Missing required parameter: name')
return handleError(err, callback)
}
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'PUT'
path = '/' + '_component_template' + '/' + encodeURIComponent(name)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildClusterPutComponentTemplate

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,15 +9,7 @@
function buildClusterPutSettings (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cluster.put_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request
*
* @param {boolean} flat_settings - Return settings in flat format (default: false)
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {time} timeout - Explicit operation timeout
* @param {object} body - The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart).
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'flat_settings',
@ -52,6 +29,11 @@ function buildClusterPutSettings (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cluster.put_settings request
* Updates the cluster settings.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html
*/
return function clusterPutSettings (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -76,21 +58,18 @@ function buildClusterPutSettings (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'PUT'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'PUT'
path = '/' + '_cluster' + '/' + 'settings'
// build request object
@ -101,34 +80,8 @@ function buildClusterPutSettings (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,11 +9,7 @@
function buildClusterRemoteInfo (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cluster.remote_info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html) request
*
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'pretty',
@ -43,6 +24,11 @@ function buildClusterRemoteInfo (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cluster.remote_info request
* Returns the information about configured remote clusters.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html
*/
return function clusterRemoteInfo (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -55,33 +41,24 @@ function buildClusterRemoteInfo (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_remote' + '/' + 'info'
// build request object
@ -92,34 +69,8 @@ function buildClusterRemoteInfo (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,18 +9,7 @@
function buildClusterReroute (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cluster.reroute](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html) request
*
* @param {boolean} dry_run - Simulate the operation only and return the resulting state
* @param {boolean} explain - Return an explanation of why the commands can or cannot be executed
* @param {boolean} retry_failed - Retries allocation of shards that are blocked due to too many subsequent allocation failures
* @param {list} metric - Limit the information returned to the specified metrics. Defaults to all but metadata
* @param {time} master_timeout - Explicit operation timeout for connection to master node
* @param {time} timeout - Explicit operation timeout
* @param {object} body - The definition of `commands` to perform (`move`, `cancel`, `allocate`)
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'dry_run',
@ -59,6 +33,11 @@ function buildClusterReroute (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cluster.reroute request
* Allows to manually change the allocation of individual shards in the cluster.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html
*/
return function clusterReroute (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -77,21 +56,18 @@ function buildClusterReroute (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body } = params
var querystring = semicopy(params, ['method', 'body'])
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'POST'
path = '/' + '_cluster' + '/' + 'reroute'
// build request object
@ -102,34 +78,8 @@ function buildClusterReroute (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,21 +9,7 @@
function buildClusterState (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cluster.state](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html) request
*
* @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
* @param {list} metric - Limit the information returned to the specified metrics
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
* @param {time} master_timeout - Specify timeout for connection to master
* @param {boolean} flat_settings - Return settings in flat format (default: false)
* @param {number} wait_for_metadata_version - Wait for the metadata version to be equal or greater than the specified metadata version
* @param {time} wait_for_timeout - The maximum time to wait for wait_for_metadata_version before timing out
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'local',
@ -68,6 +39,11 @@ function buildClusterState (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cluster.state request
* Returns a comprehensive information about the state of the cluster.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html
*/
return function clusterState (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -80,12 +56,6 @@ function buildClusterState (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// check required url components
if (params['index'] != null && (params['metric'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: metric')
@ -98,26 +68,25 @@ function buildClusterState (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, index, metric } = params
var querystring = semicopy(params, ['method', 'body', 'index', 'metric'])
var warnings = []
var { method, body, metric, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((metric) != null && (index) != null) {
if (method == null) method = 'GET'
path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index)
} else if ((metric) != null) {
if (method == null) method = 'GET'
path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric)
} else {
if (method == null) method = 'GET'
path = '/' + '_cluster' + '/' + 'state'
}
@ -129,34 +98,8 @@ function buildClusterState (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,14 +9,7 @@
function buildClusterStats (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [cluster.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html) request
*
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* @param {boolean} flat_settings - Return settings in flat format (default: false)
* @param {time} timeout - Explicit operation timeout
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'flat_settings',
@ -49,6 +27,11 @@ function buildClusterStats (opts) {
filterPath: 'filter_path'
}
/**
* Perform a cluster.stats request
* Returns high-level overview of cluster statistics.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html
*/
return function clusterStats (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -61,36 +44,28 @@ function buildClusterStats (opts) {
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = null
var { method, body, nodeId, node_id } = params
var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id'])
var warnings = []
var { method, body, nodeId, node_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((node_id || nodeId) != null) {
if (method == null) method = 'GET'
path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId)
} else {
if (method == null) method = 'GET'
path = '/' + '_cluster' + '/' + 'stats'
}
@ -102,34 +77,8 @@ function buildClusterStats (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,28 +9,7 @@
function buildCount (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [count](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html) request
*
* @param {list} index - A comma-separated list of indices to restrict the results
* @param {list} type - A comma-separated list of types to restrict the results
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled
* @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {number} min_score - Include only documents with a specific `_score` value in the result
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
* @param {list} routing - A comma-separated list of specific routing values
* @param {string} q - Query in the Lucene query string syntax
* @param {string} analyzer - The analyzer to use for the query string
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {enum} default_operator - The default operator for query string query (AND or OR)
* @param {string} df - The field to use as default where no field prefix is given in the query string
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {number} terminate_after - The maximum count for each shard, upon reaching which the query execution will terminate early
* @param {object} body - A query to restrict the results specified with the Query DSL (optional)
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'ignore_unavailable',
@ -82,6 +46,11 @@ function buildCount (opts) {
filterPath: 'filter_path'
}
/**
* Perform a count request
* Returns number of documents matching a query.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html
*/
return function count (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -106,26 +75,25 @@ function buildCount (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, index, type } = params
var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
var warnings = []
var { method, body, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = body == null ? 'GET' : 'POST'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null) {
if (method == null) method = body == null ? 'GET' : 'POST'
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_count'
} else if ((index) != null) {
if (method == null) method = body == null ? 'GET' : 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_count'
} else {
if (method == null) method = body == null ? 'GET' : 'POST'
path = '/' + '_count'
}
@ -137,34 +105,8 @@ function buildCount (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,27 +9,10 @@
function buildCreate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [create](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request
*
* @param {string} id - Document ID
* @param {string} index - The name of the index
* @param {string} type - The type of the document
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {string} parent - ID of the parent document
* @param {enum} refresh - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
* @param {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout
* @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type
* @param {string} pipeline - The pipeline id to preprocess incoming documents with
* @param {object} body - The document
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'wait_for_active_shards',
'parent',
'refresh',
'routing',
'timeout',
@ -65,6 +33,13 @@ function buildCreate (opts) {
filterPath: 'filter_path'
}
/**
* Perform a create request
* Creates a new document in the index.
Returns a 409 response when a document with a same ID already exists in the index.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html
*/
return function create (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -97,24 +72,22 @@ function buildCreate (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, id, index, type } = params
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
var warnings = []
var { method, body, id, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'PUT'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null && (id) != null) {
if (method == null) method = 'PUT'
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create'
} else {
if (method == null) method = 'PUT'
path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id)
}
@ -126,34 +99,8 @@ function buildCreate (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,27 +9,10 @@
function buildDelete (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html) request
*
* @param {string} id - The document ID
* @param {string} index - The name of the index
* @param {string} type - The type of the document
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {string} parent - ID of parent document
* @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
* @param {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout
* @param {number} if_seq_no - only perform the delete operation if the last operation that has changed the document has the specified sequence number
* @param {number} if_primary_term - only perform the delete operation if the last operation that has changed the document has the specified primary term
* @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'wait_for_active_shards',
'parent',
'refresh',
'routing',
'timeout',
@ -68,6 +36,11 @@ function buildDelete (opts) {
filterPath: 'filter_path'
}
/**
* Perform a delete request
* Removes a document from the index.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html
*/
return function _delete (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -89,16 +62,6 @@ function buildDelete (opts) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// check required url components
if (params['id'] != null && (params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: index')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
@ -106,24 +69,22 @@ function buildDelete (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, id, index, type } = params
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
var warnings = []
var { method, body, id, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'DELETE'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null && (id) != null) {
if (method == null) method = 'DELETE'
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
} else {
if (method == null) method = 'DELETE'
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
}
@ -131,38 +92,12 @@ function buildDelete (opts) {
const request = {
method,
path,
body: '',
body: body || '',
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,46 +9,7 @@
function buildDeleteByQuery (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [delete_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html) request
*
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
* @param {string} analyzer - The analyzer to use for the query string
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {enum} default_operator - The default operator for query string query (AND or OR)
* @param {string} df - The field to use as default where no field prefix is given in the query string
* @param {number} from - Starting offset (default: 0)
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {enum} conflicts - What to do when the delete by query hits version conflicts?
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
* @param {string} q - Query in the Lucene query string syntax
* @param {list} routing - A comma-separated list of specific routing values
* @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search
* @param {enum} search_type - Search operation type
* @param {time} search_timeout - Explicit timeout for each search request. Defaults to no timeout.
* @param {number} size - Number of hits to return (default: 10)
* @param {list} sort - A comma-separated list of <field>:<direction> pairs
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
* @param {list} _source_excludes - A list of fields to exclude from the returned _source field
* @param {list} _source_includes - A list of fields to extract and return from the _source field
* @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
* @param {list} stats - Specific 'tag' of the request for logging and statistical purposes
* @param {boolean} version - Specify whether to return document version as part of a hit
* @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting
* @param {boolean} refresh - Should the effected indexes be refreshed?
* @param {time} timeout - Time each individual bulk request should wait for shards that are unavailable.
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {number} scroll_size - Size on the scroll request powering the delete by query
* @param {boolean} wait_for_completion - Should the request should block until the delete by query is complete.
* @param {number} requests_per_second - The throttle for this request in sub-requests per second. -1 means no throttle.
* @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.
* @param {object} body - The search definition using the Query DSL
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'analyzer',
@ -83,10 +29,13 @@ function buildDeleteByQuery (opts) {
'search_type',
'search_timeout',
'size',
'max_docs',
'sort',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'terminate_after',
'stats',
'version',
@ -113,8 +62,11 @@ function buildDeleteByQuery (opts) {
expandWildcards: 'expand_wildcards',
searchType: 'search_type',
searchTimeout: 'search_timeout',
maxDocs: 'max_docs',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include',
terminateAfter: 'terminate_after',
requestCache: 'request_cache',
waitForActiveShards: 'wait_for_active_shards',
@ -125,6 +77,11 @@ function buildDeleteByQuery (opts) {
filterPath: 'filter_path'
}
/**
* Perform a delete_by_query request
* Deletes documents matching the provided query.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html
*/
return function deleteByQuery (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -159,24 +116,22 @@ function buildDeleteByQuery (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, index, type } = params
var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
var warnings = []
var { method, body, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null) {
if (method == null) method = 'POST'
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_delete_by_query'
} else {
if (method == null) method = 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query'
}
@ -188,34 +143,8 @@ function buildDeleteByQuery (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,13 +9,7 @@
function buildDeleteByQueryRethrottle (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [delete_by_query_rethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html) request
*
* @param {string} task_id - The task id to rethrottle
* @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'requests_per_second',
@ -47,6 +26,11 @@ function buildDeleteByQueryRethrottle (opts) {
filterPath: 'filter_path'
}
/**
* Perform a delete_by_query_rethrottle request
* Changes the number of requests per second for a particular Delete By Query operation.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
*/
return function deleteByQueryRethrottle (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -68,10 +52,6 @@ function buildDeleteByQueryRethrottle (opts) {
const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond')
return handleError(err, callback)
}
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
@ -79,59 +59,30 @@ function buildDeleteByQueryRethrottle (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, taskId, task_id } = params
var querystring = semicopy(params, ['method', 'body', 'taskId', 'task_id'])
var warnings = []
var { method, body, taskId, task_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'POST'
path = '/' + '_delete_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle'
// build request object
const request = {
method,
path,
body: '',
body: body || '',
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,14 +9,7 @@
function buildDeleteScript (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [delete_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request
*
* @param {string} id - Script ID
* @param {time} timeout - Explicit operation timeout
* @param {time} master_timeout - Specify timeout for connection to master
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'timeout',
@ -49,6 +27,11 @@ function buildDeleteScript (opts) {
filterPath: 'filter_path'
}
/**
* Perform a delete_script request
* Deletes a script.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
*/
return function deleteScript (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -66,10 +49,6 @@ function buildDeleteScript (opts) {
const err = new ConfigurationError('Missing required parameter: id')
return handleError(err, callback)
}
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
@ -77,59 +56,30 @@ function buildDeleteScript (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, id } = params
var querystring = semicopy(params, ['method', 'body', 'id'])
var warnings = []
var { method, body, id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'DELETE'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'DELETE'
path = '/' + '_scripts' + '/' + encodeURIComponent(id)
// build request object
const request = {
method,
path,
body: '',
body: body || '',
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

View File

@ -0,0 +1,78 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildEnrichDeletePolicy (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a enrich.delete_policy request
* Deletes an existing enrich policy and its enrich index.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-enrich-policy-api.html
*/
return function enrichDeletePolicy (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['name'] == null) {
const err = new ConfigurationError('Missing required parameter: name')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'DELETE'
path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildEnrichDeletePolicy

View File

@ -0,0 +1,78 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildEnrichExecutePolicy (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'wait_for_completion'
]
const snakeCase = {
waitForCompletion: 'wait_for_completion'
}
/**
* Perform a enrich.execute_policy request
* Creates the enrich index for an existing enrich policy.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/execute-enrich-policy-api.html
*/
return function enrichExecutePolicy (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['name'] == null) {
const err = new ConfigurationError('Missing required parameter: name')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'PUT'
path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + '/' + '_execute'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildEnrichExecutePolicy

View File

@ -0,0 +1,77 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildEnrichGetPolicy (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a enrich.get_policy request
* Gets information about an enrich policy.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/get-enrich-policy-api.html
*/
return function enrichGetPolicy (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((name) != null) {
if (method == null) method = 'GET'
path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name)
} else {
if (method == null) method = 'GET'
path = '/' + '_enrich' + '/' + 'policy'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildEnrichGetPolicy

View File

@ -0,0 +1,82 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildEnrichPutPolicy (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a enrich.put_policy request
* Creates a new enrich policy.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/put-enrich-policy-api.html
*/
return function enrichPutPolicy (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['name'] == null) {
const err = new ConfigurationError('Missing required parameter: name')
return handleError(err, callback)
}
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'PUT'
path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildEnrichPutPolicy

72
api/api/enrich.stats.js Normal file
View File

@ -0,0 +1,72 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildEnrichStats (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a enrich.stats request
* Gets enrich coordinator statistics and information about enrich policies that are currently executing.
* https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats-api.html
*/
return function enrichStats (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = 'GET'
path = '/' + '_enrich' + '/' + '_stats'
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildEnrichStats

82
api/api/eql.search.js Normal file
View File

@ -0,0 +1,82 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildEqlSearch (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a eql.search request
* Returns results matching a query expressed in Event Query Language (EQL)
* https://www.elastic.co/guide/en/elasticsearch/reference/current/eql.html
*/
return function eqlSearch (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if (method == null) method = body == null ? 'GET' : 'POST'
path = '/' + encodeURIComponent(index) + '/' + '_eql' + '/' + 'search'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildEqlSearch

View File

@ -1,21 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
'use strict'
@ -24,36 +9,19 @@
function buildExists (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request
*
* @param {string} id - The document ID
* @param {string} index - The name of the index
* @param {string} type - The type of the document (use `_all` to fetch the first document matching the ID across all types)
* @param {list} stored_fields - A comma-separated list of stored fields to return in the response
* @param {string} parent - The ID of the parent document
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
* @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode
* @param {boolean} refresh - Refresh the shard containing the document before performing the operation
* @param {string} routing - Specific routing value
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
* @param {list} _source_excludes - A list of fields to exclude from the returned _source field
* @param {list} _source_includes - A list of fields to extract and return from the _source field
* @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type
*/
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'stored_fields',
'parent',
'preference',
'realtime',
'refresh',
'routing',
'_source',
'_source_excludes',
'_source_exclude',
'_source_includes',
'_source_include',
'version',
'version_type',
'pretty',
@ -66,12 +34,19 @@ function buildExists (opts) {
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'
}
/**
* Perform a exists request
* Returns information about whether a document exists in an index.
* https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
*/
return function exists (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
@ -93,10 +68,6 @@ function buildExists (opts) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
@ -104,24 +75,22 @@ function buildExists (opts) {
return handleError(err, callback)
}
var warnings = null
var { method, body, id, index, type } = params
var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
var warnings = []
var { method, body, id, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'HEAD'
}
var ignore = options.ignore || null
var ignore = options.ignore
if (typeof ignore === 'number') {
ignore = [ignore]
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null && (id) != null) {
if (method == null) method = 'HEAD'
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
} else {
if (method == null) method = 'HEAD'
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
}
@ -133,34 +102,8 @@ function buildExists (opts) {
querystring
}
const requestOptions = {
ignore,
requestTimeout: options.requestTimeout || null,
maxRetries: options.maxRetries || null,
asStream: options.asStream || false,
headers: options.headers || null,
querystring: options.querystring || null,
compression: options.compression || false,
warnings
}
return makeRequest(request, requestOptions, callback)
function semicopy (obj, exclude) {
var target = {}
var keys = Object.keys(obj)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (exclude.indexOf(key) === -1) {
target[snakeCase[key] || key] = obj[key]
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
warnings = warnings || []
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
}
}
}
return target
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}

Some files were not shown because too many files have changed in this diff Show More