Compare commits

..

55 Commits

Author SHA1 Message Date
9924ada7d7 Bumped v5.6.16-rc.2 2019-04-17 14:17:38 +02:00
2827708ca5 Updated typings (#819) 2019-04-17 11:25:18 +02:00
c2118c5168 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:25:18 +02:00
66b6c17ee1 Fix a typo in usage example (#806) 2019-04-11 16:38:30 +02:00
92e786e9c6 API generation 2019-04-10 11:47:21 +02:00
e6f0d272ca 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:46:29 +02:00
fb365c9adf Custom http agent support (#810) 2019-04-10 11:46:09 +02:00
bbd6b5a546 Support for publish_address as hostname/ip:port (#804) 2019-04-09 12:06:51 +02:00
729444c060 Updated README.md 2019-04-01 09:50:43 +02:00
6809a13ceb Handle bulk errors in examples 2019-04-01 09:09:21 +02:00
4973cf1250 Generated reference 2019-03-29 18:09:34 +01:00
96bee613f8 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:09:13 +01:00
1551c9c10a Docs: Set the stack docs branch to 5.6 2019-03-29 11:24:32 -04:00
d50cda1cfa 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:47:42 +01:00
1c0bc18165 Update asciidoc config 2019-03-29 15:42:52 +01:00
91a5b7acef Generated reference 2019-03-29 08:53:27 +01:00
65e56de52d Docs: Fix the API reference (#799) 2019-03-29 08:53:04 +01:00
8684126c7b Bumped v5.6.16-rc.1 2019-03-28 19:30:06 +01:00
1b59d21415 Generated reference 2019-03-28 17:38:08 +01:00
6b550b51e5 Fix docs (#796)
Follow up of https://github.com/elastic/docs/pull/701.
2019-03-28 17:37:36 +01:00
9fd8ed901d Updated CONTRIBUTING.md (#794)
As titled, also renamed the script files for a better DX.
2019-03-28 10:12:02 +01:00
bf97b20867 API generation 2019-03-27 19:25:10 +01:00
00e3941b3d Follow-up #790 2019-03-27 19:24:41 +01:00
9d7efff6d4 Added CONTRIBUTING.md and CODE_OF_CONDUCT.md 2019-03-27 16:48:20 +01:00
fc6b6469ae Improved integration test runner 2019-03-27 15:06:17 +01:00
e806a1412b Use ES 5.6.16 2019-03-27 11:52:29 +01:00
5224887f28 Regenerate doc 2019-03-27 07:47:44 +01:00
3d85d85e2d Doc updates (#791)
Updates for better displaying the documentation in the website.
2019-03-27 07:47:20 +01:00
081cac4813 API generation 2019-03-26 12:12:34 +01:00
79adf72145 Merge branch 'master' into 5.x 2019-03-26 12:12:01 +01:00
11481d4637 Remove url in jenkins job configuration 2019-03-21 11:16:46 -04:00
207d5e6ad8 Updated es settings 2019-03-21 14:23:53 +01:00
f6e3874a82 Updated test 2019-03-21 14:23:35 +01:00
09346b6926 Updated test 2019-03-21 11:58:41 +01:00
1889fd3b92 Updated ci config 2019-03-21 11:37:13 +01:00
9d3bd8836f CI config (#786)
* Updated ci config

* Minor fixes

* Minor fixes

* Added Node v11
2019-03-21 11:04:55 +01:00
459949028b Updated test 2019-03-19 16:44:51 +01:00
7dbfbcdf07 Updated ci config 2019-03-19 12:45:01 +01:00
986faf6cb0 Updated travis 2019-03-19 11:24:56 +01:00
6be881bee7 Support for ES5 2019-03-19 11:24:26 +01:00
fbba50ea6f Updated scripts 2019-03-19 11:24:13 +01:00
46f1436b68 regenerated typings and reference 2019-03-19 11:24:01 +01:00
b19f0d5fc7 API generation 2019-03-19 11:23:46 +01:00
070dd239bb 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 10:34:12 +01:00
8b3eca2611 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 10:34:12 +01:00
184aa3817f Added a note about the new client 2019-03-19 10:34:12 +01:00
796644fc0c 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 10:34:12 +01:00
2debb7ba64 Updated coverage script 2019-03-15 17:49:40 +01:00
80457fb34f Added codecov badge 2019-03-15 17:49:40 +01:00
9890a8ef72 Updated ignore files 2019-03-15 17:49:40 +01:00
a58d2edc88 Added codecov (#777) 2019-03-15 17:49:40 +01:00
12626feb40 Updated README 2019-03-14 18:33:43 +01:00
9e249b3d0c Use Elasticsearch 5.6.15 2019-03-13 16:15:39 +01:00
c9f044ef73 Updated code generation 2019-03-13 16:13:22 +01:00
1290b6e559 Revert d4d7d0bef5 2019-03-13 14:14:13 +01:00
352 changed files with 11707 additions and 25994 deletions

View File

@ -22,7 +22,7 @@ services:
- elasticsearch-oss - elasticsearch-oss
elasticsearch-oss: elasticsearch-oss:
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-8.0.0-SNAPSHOT} image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-5.6.15}
volumes: volumes:
- esvol:/tmp - esvol:/tmp
networks: networks:
@ -32,63 +32,10 @@ services:
- "repositories.url.allowed_urls=http://snapshot.*" - "repositories.url.allowed_urls=http://snapshot.*"
- node.attr.testattr=test - node.attr.testattr=test
- bootstrap.memory_lock=false - bootstrap.memory_lock=false
- "xpack.security.enabled=false"
- "discovery.type=single-node" - "discovery.type=single-node"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" - "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:-8.0.0-SNAPSHOT}
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: networks:
# we need two networks otherwise the two ES instances will join each other
esnet-oss: esnet-oss:
esnet-platinum:
volumes: volumes:
esvol: esvol:

View File

@ -65,6 +65,3 @@
publishers: publishers:
- email: - email:
recipients: infra-root+build@elastic.co recipients: infra-root+build@elastic.co
# - junit:
# results: "*-junit.xml"
# allow-empty-results: true

View File

@ -1,14 +0,0 @@
---
- 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 (<branchName>, <tagName>,
<commitId>, etc.)
triggers:
- github
- timed: '@weekly'

View File

@ -1,54 +0,0 @@
---
- job:
name: elastic+elasticsearch-js+jenkins-pipelines
display-name: 'elastic / elasticsearch-js # jenkins-pipelines'
description: Testing the elasticsearch-js jenkins-pipelines branch.
project-type: multibranch
logrotate:
daysToKeep: 30
numToKeep: 100
number-to-keep: '5'
days-to-keep: '1'
concurrent: true
node: linux
script-path: Jenkinsfile
scm:
- github:
branch-discovery: all
discover-pr-forks-strategy: merge-current
discover-pr-forks-trust: permission
discover-pr-origin: merge-current
discover-tags: true
repo: elasticsearch-js
repo-owner: elastic
credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
ssh-checkout:
credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
build-strategies:
- tags:
ignore-tags-older-than: -1
ignore-tags-newer-than: -1
- regular-branches: true
- change-request:
ignore-target-only-changes: false
clean:
after: true
before: true
prune: true
shallow-clone: true
depth: 3
do-not-fetch-tags: true
submodule:
disable: false
recursive: true
parent-credentials: true
timeout: 100
timeout: '15'
use-author: true
wipe-workspace: 'True'
periodic-folder-trigger: 1d
prune-dead-branches: true
publishers:
- email:
recipients: infra-root+build@elastic.co

View File

@ -20,18 +20,14 @@ set -x
function cleanup { function cleanup {
docker container rm --force --volumes elasticsearch-oss > /dev/null 2>&1 || true 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-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-oss > /dev/null
docker network rm esnet-platinum > /dev/null
} }
trap cleanup EXIT trap cleanup EXIT
# create network and volume # create network and volume
docker network create esnet-oss docker network create esnet-oss
docker network create esnet-platinum
# create client image # create client image
docker build \ docker build \
@ -46,43 +42,14 @@ docker run \
--env "node.attr.testattr=test" \ --env "node.attr.testattr=test" \
--env "path.repo=/tmp" \ --env "path.repo=/tmp" \
--env "repositories.url.allowed_urls=http://snapshot.*" \ --env "repositories.url.allowed_urls=http://snapshot.*" \
--env "discovery.type=single-node" \ --env "discovery.zen.ping.unicast.hosts=elasticsearch" \
--env "xpack.security.enabled=false" \
--env "xpack.monitoring.enabled=false" \
--env "xpack.ml.enabled=false" \
--env ES_JAVA_OPTS="-Xms1g -Xmx1g" \
--network=esnet-oss \ --network=esnet-oss \
--name=elasticsearch-oss \ --name=elasticsearch-oss \
--detach \ --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} docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION}
# run the client unit and oss integration test # run the client unit and oss integration test
@ -90,21 +57,9 @@ docker run \
--network=esnet-oss \ --network=esnet-oss \
--env "TEST_ES_SERVER=http://elasticsearch-oss:9200" \ --env "TEST_ES_SERVER=http://elasticsearch-oss:9200" \
--env "CODECOV_TOKEN" \ --env "CODECOV_TOKEN" \
--volume $repo:/usr/src/app \ --volume $(pwd):/usr/src/app \
--volume /usr/src/app/node_modules \ --volume /usr/src/app/node_modules \
--name elasticsearch-js-oss \ --name elasticsearch-js-oss \
--rm \ --rm \
elastic/elasticsearch-js \ elastic/elasticsearch-js \
npm run ci 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

View File

@ -1,10 +1,10 @@
--- ---
ELASTICSEARCH_VERSION: ELASTICSEARCH_VERSION:
- 7.3.0 - 5.6.16
NODE_JS_VERSION: NODE_JS_VERSION:
- 12 - 11
- 10 - 10
- 8 - 8
exclude: ~ exclude: ~

View File

@ -3,7 +3,7 @@
#### You have already researched for similar issues? #### 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. 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). 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,14 +23,6 @@ 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 ## Expected behavior
A clear and concise description of what you expected to happen. A clear and concise description of what you expected to happen.
@ -44,6 +36,6 @@ Paste the results here:
## Your Environment ## Your Environment
- *node version*: 6,8,10 - *node version*: 6,8,10
- `@elastic/elasticsearch` *version*: >=7.0.0 - *@elastic/elasticsearch version*: >=7.0.0
- *os*: Mac, Windows, Linux - *os*: Mac, Windows, Linux
- *any other relevant information* - *any other relevant information*

View File

@ -29,14 +29,6 @@ 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 ## Expected behavior
A clear and concise description of what you expected to happen. A clear and concise description of what you expected to happen.
@ -50,6 +42,6 @@ Paste the results here:
## Your Environment ## Your Environment
- *node version*: 6,8,10 - *node version*: 6,8,10
- `@elastic/elasticsearch` *version*: >=7.0.0 - *@elastic/elasticsearch version*: >=7.0.0
- *os*: Mac, Windows, Linux - *os*: Mac, Windows, Linux
- *any other relevant information* - *any other relevant information*

1
.github/stale.yml vendored
View File

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

6
.gitignore vendored
View File

@ -50,6 +50,8 @@ package-lock.json
# elasticsearch repo or binary files # elasticsearch repo or binary files
elasticsearch* elasticsearch*
test/benchmarks/macro/fixtures/* # Generated typings, we don't commit them
# because we should copy them in the main .d.ts file
api/generated.d.ts
*-junit.xml test/benchmarks/macro/fixtures/*

View File

@ -1,20 +1,29 @@
dist: trusty
sudo: required
language: node_js language: node_js
node_js: node_js:
- "12" - "11"
- "10" - "10"
- "8" - "8"
os: env:
- windows global:
- linux - ELASTICSEARCH_VERSION=5.6.16
- QUIET=true
before_install:
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz
- tar -xzf elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz
- ./elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch -Enode.attr.testattr=test -Epath.repo=/tmp -Erepositories.url.allowed_urls='http://snapshot.*' &> /dev/null &
install: install:
- npm install - npm install
script: script:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then npm run license-checker; fi - npm run ci
- npm run test
notifications: notifications:
email: email:

214
README.md
View File

@ -1,24 +1,23 @@
<img align="right" width="auto" height="auto" src="https://www.elastic.co/static-res/images/elastic-logo-200.png"> <img align="right" width="auto" height="auto" src="https://www.elastic.co/static-res/images/elastic-logo-200.png">
# Elasticsearch Node.js client # @elastic/elasticsearch
[![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) [![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, and 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).
---
The official Node.js client for 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 ## Features
- One-to-one mapping with REST API. - One-to-one mapping with REST API.
- Generalized, pluggable architecture. - Generalized, pluggable architecture.
- Configurable, automatic discovery of cluster nodes. - Configurable, automatic discovery of cluster nodes.
- Persistent, Keep-Alive connections. - Persistent, Keep-Alive connections.
- Load balancing across all available nodes. - Load balancing (with pluggable selection strategy) across all available nodes.
- Child client support.
- TypeScript support out of the box. - TypeScript support out of the box.
## Install ## Install
@ -30,49 +29,26 @@ npm install @elastic/elasticsearch
The minimum supported version of Node.js is `v8`. The minimum supported version of Node.js is `v8`.
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. 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.
| Elasticsearch Version | Client Version |
| --------------------- |----------------|
| `master` | `master` |
| `7.x` | `7.x` |
| `6.x` | `6.x` |
| `5.x` | `5.x` |
To install a specific major of the client, run the following command:
``` ```
npm install @elastic/elasticsearch@<major> # Elasticsearch 7.x
@elastic/elasticsearch@7
# Elasticsearch 6.x
@elastic/elasticsearch@6
# Elasticsearch 5.x
@elastic/elasticsearch@5
``` ```
#### Browser ## Usage
WARNING: There is no official support for the browser environment. It exposes your Elasticsearch instance to everyone, which could lead to security issues. You can find the full documentation in our [docs](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html) website.
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)
- [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)
- [Typescript support](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/typescript.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 ```js
const { Client } = require('@elastic/elasticsearch') const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' }) 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 // promise API
const result = await client.search({ const result = await client.search({
index: 'my-index', index: 'my-index',
@ -97,98 +73,78 @@ The returned value of **every** API call is formed as follows:
meta: object meta: object
} }
``` ```
### Client options
Let's see a complete example! 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.
```js
'use strict'
const { Client } = require('@elastic/elasticsearch') ```ts
const client = new Client({ node: 'http://localhost:9200' }) {
// the Elasticsearch endpoint to use
async function run () { node: string | string[];
// Let's start by indexing some data // alias of above
await client.index({ nodes: string | string[];
index: 'game-of-thrones', // custom connection class
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6 Connection: typeof Connection;
body: { // custom connection pool class
character: 'Ned Stark', ConnectionPool: typeof ConnectionPool;
quote: 'Winter is coming.' // custom transport class
} Transport: typeof Transport;
}) // custom serializer class
Serializer: typeof Serializer;
await client.index({ // max number of retries for each request
index: 'game-of-thrones', maxRetries: number;
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6 // max request timeout for each request
body: { requestTimeout: number;
character: 'Daenerys Targaryen', // max ping timeout for each request
quote: 'I am the blood of the dragon.' pingTimeout: number;
} // perform a sniff operation every `n` milliseconds
}) sniffInterval: number;
// perform a sniff once the client is started
await client.index({ sniffOnStart: boolean;
index: 'game-of-thrones', // custom sniff endpoint, defaults `_nodes/_all/http`
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6 sniffEndpoint: string;
body: { // perform a sniff on connection fault
character: 'Tyrion Lannister', sniffOnConnectionFault: boolean;
quote: 'A mind needs books like a sword needs a whetstone.' // configurethe node resurrection strategy, default `ping`
} resurrectStrategy: 'ping' | 'optimistic' | 'none';
}) // adds `accept-encoding` header to every request
suggestCompression: boolean;
// here we are forcing an index refresh, otherwise we will not // enable gzip request body compression
// get any result in the consequent search compression: 'gzip';
await client.indices.refresh({ index: 'game-of-thrones' }) // ssl configuraton
ssl: http.SecureContextOptions;
// Let's search! // http agent options
const { body } = await client.search({ agent: http.AgentOptions;
index: 'game-of-thrones', // filters which node not to use for a request
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6 nodeFilter: nodeFilterFn;
body: { // custom selection strategy, defaults `round-robin`
query: { nodeSelector: nodeSelectorFn | string;
match: { quote: 'winter' }
}
}
})
console.log(body.hits.hits)
}
run().catch(console.log)
```
## 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>
```
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.
### Request specific options
If needed you can pass request specific options in a second object:
```js ```js
const { Client: Client6 } = require('es6') // promise API
const { Client: Client7 } = require('es7') const result = await client.search({
index: 'my-index',
const client6 = new Client6({ node: 'http://localhost:9200' }) body: { foo: 'bar' }
const client7 = new Client7({ node: 'http://localhost:9201' }) }, {
ignore: [404],
client6.info(console.log) maxRetries: 3
client7.info(console.log) })
``` ```
The supported *request specific options* are:
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: ```ts
```sh {
npm install esmaster@github:elastic/elasticsearch-js 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`
}
``` ```
## License ## License

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildBulk (opts) { function buildBulk (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [bulk](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html) request * Perform a [bulk](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-bulk.html) request
* *
* @param {string} index - Default index for items which don't provide one * @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} type - Default document type for items which don't provide one
@ -20,9 +35,10 @@ function buildBulk (opts) {
* @param {string} routing - Specific routing value * @param {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout * @param {time} timeout - Explicit operation timeout
* @param {string} type - Default document type for items which don't provide one * @param {string} type - Default document type for items which don't provide one
* @param {list} fields - Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request
* @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 - 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_exclude - 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 {list} _source_include - 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 {string} pipeline - The pipeline id to preprocess incoming documents with
* @param {object} body - The operation definition and data (action-data pairs), separated by newlines * @param {object} body - The operation definition and data (action-data pairs), separated by newlines
*/ */
@ -33,10 +49,9 @@ function buildBulk (opts) {
'routing', 'routing',
'timeout', 'timeout',
'type', 'type',
'fields',
'_source', '_source',
'_source_excludes',
'_source_exclude', '_source_exclude',
'_source_includes',
'_source_include', '_source_include',
'pipeline', 'pipeline',
'pretty', 'pretty',
@ -48,9 +63,7 @@ function buildBulk (opts) {
const snakeCase = { const snakeCase = {
waitForActiveShards: 'wait_for_active_shards', waitForActiveShards: 'wait_for_active_shards',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude', _sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include', _sourceInclude: '_source_include',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
@ -86,17 +99,17 @@ function buildBulk (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, type, ...querystring } = params var { method, body, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
if (method == null) { if (method == null) {
method = 'POST' method = 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -117,8 +130,34 @@ function buildBulk (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatAliases (opts) { function buildCatAliases (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.aliases](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html) request * Perform a [cat.aliases](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-alias.html) request
* *
* @param {list} name - A comma-separated list of alias names to return * @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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -68,17 +83,17 @@ function buildCatAliases (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, name, ...querystring } = params var { method, body, name } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'name'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -97,8 +112,34 @@ function buildCatAliases (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatAllocation (opts) { function buildCatAllocation (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.allocation](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html) request * Perform a [cat.allocation](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-allocation.html) request
* *
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information * @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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -70,17 +85,17 @@ function buildCatAllocation (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, nodeId, node_id, ...querystring } = params var { method, body, nodeId, node_id } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -99,8 +114,34 @@ function buildCatAllocation (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatCount (opts) { function buildCatCount (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.count](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html) request * Perform a [cat.count](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-count.html) request
* *
* @param {list} index - A comma-separated list of index names to limit the returned information * @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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -68,17 +83,17 @@ function buildCatCount (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -97,8 +112,34 @@ function buildCatCount (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatFielddata (opts) { function buildCatFielddata (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.fielddata](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html) request * Perform a [cat.fielddata](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-fielddata.html) request
* *
* @param {list} fields - A comma-separated list of fields to return the fielddata size * @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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -72,17 +87,17 @@ function buildCatFielddata (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, fields, ...querystring } = params var { method, body, fields } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'fields'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -101,8 +116,34 @@ function buildCatFielddata (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatHealth (opts) { function buildCatHealth (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html) request * Perform a [cat.health](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-health.html) request
* *
* @param {string} format - a short version of the Accept header, e.g. json, yaml * @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 {boolean} local - Return local information, do not retrieve the state from master node (default: false)
@ -69,17 +84,17 @@ function buildCatHealth (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -94,8 +109,34 @@ function buildCatHealth (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatHelp (opts) { function buildCatHelp (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.help](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html) request * Perform a [cat.help](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat.html) request
* *
* @param {boolean} help - Return help information * @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {list} s - Comma-separated list of column names or column aliases to sort by
@ -56,17 +71,17 @@ function buildCatHelp (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -81,8 +96,34 @@ function buildCatHelp (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatIndices (opts) { function buildCatIndices (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.indices](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html) request * Perform a [cat.indices](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-indices.html) request
* *
* @param {list} index - A comma-separated list of index names to limit the returned information * @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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -24,7 +39,6 @@ function buildCatIndices (opts) {
* @param {boolean} pri - Set to true to return stats only for primary shards * @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 {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers * @param {boolean} v - Verbose mode. Display column headers
* @param {boolean} include_unloaded_segments - If set to true segment stats will include stats for segments that are not currently loaded into memory
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
@ -38,7 +52,6 @@ function buildCatIndices (opts) {
'pri', 'pri',
's', 's',
'v', 'v',
'include_unloaded_segments',
'pretty', 'pretty',
'human', 'human',
'error_trace', 'error_trace',
@ -48,7 +61,6 @@ function buildCatIndices (opts) {
const snakeCase = { const snakeCase = {
masterTimeout: 'master_timeout', masterTimeout: 'master_timeout',
includeUnloadedSegments: 'include_unloaded_segments',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
} }
@ -77,17 +89,17 @@ function buildCatIndices (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -106,8 +118,34 @@ function buildCatIndices (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatMaster (opts) { function buildCatMaster (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.master](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html) request * Perform a [cat.master](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-master.html) request
* *
* @param {string} format - a short version of the Accept header, e.g. json, yaml * @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 {boolean} local - Return local information, do not retrieve the state from master node (default: false)
@ -67,17 +82,17 @@ function buildCatMaster (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -92,8 +107,34 @@ function buildCatMaster (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatNodeattrs (opts) { function buildCatNodeattrs (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.nodeattrs](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html) request * Perform a [cat.nodeattrs](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-nodeattrs.html) request
* *
* @param {string} format - a short version of the Accept header, e.g. json, yaml * @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 {boolean} local - Return local information, do not retrieve the state from master node (default: false)
@ -67,17 +82,17 @@ function buildCatNodeattrs (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -92,8 +107,34 @@ function buildCatNodeattrs (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatNodes (opts) { function buildCatNodes (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.nodes](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html) request * Perform a [cat.nodes](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-nodes.html) request
* *
* @param {string} format - a short version of the Accept header, e.g. json, yaml * @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} full_id - Return the full node ID instead of the shortened version (default: false)
@ -70,17 +85,17 @@ function buildCatNodes (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -95,8 +110,34 @@ function buildCatNodes (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatPendingTasks (opts) { function buildCatPendingTasks (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html) request * Perform a [cat.pending_tasks](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-pending-tasks.html) request
* *
* @param {string} format - a short version of the Accept header, e.g. json, yaml * @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 {boolean} local - Return local information, do not retrieve the state from master node (default: false)
@ -67,17 +82,17 @@ function buildCatPendingTasks (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -92,8 +107,34 @@ function buildCatPendingTasks (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatPlugins (opts) { function buildCatPlugins (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.plugins](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html) request * Perform a [cat.plugins](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-plugins.html) request
* *
* @param {string} format - a short version of the Accept header, e.g. json, yaml * @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 {boolean} local - Return local information, do not retrieve the state from master node (default: false)
@ -67,17 +82,17 @@ function buildCatPlugins (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -92,8 +107,34 @@ function buildCatPlugins (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatRecovery (opts) { function buildCatRecovery (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html) request * Perform a [cat.recovery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-recovery.html) request
* *
* @param {list} index - A comma-separated list of index names to limit the returned information * @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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -68,17 +83,17 @@ function buildCatRecovery (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -97,8 +112,34 @@ function buildCatRecovery (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatRepositories (opts) { function buildCatRepositories (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.repositories](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html) request * Perform a [cat.repositories](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-repositories.html) request
* *
* @param {string} format - a short version of the Accept header, e.g. json, yaml * @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 {boolean} local - Return local information, do not retrieve the state from master node
@ -67,17 +82,17 @@ function buildCatRepositories (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -92,8 +107,34 @@ function buildCatRepositories (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatSegments (opts) { function buildCatSegments (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.segments](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html) request * Perform a [cat.segments](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-segments.html) request
* *
* @param {list} index - A comma-separated list of index names to limit the returned information * @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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -65,17 +80,17 @@ function buildCatSegments (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -94,8 +109,34 @@ function buildCatSegments (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatShards (opts) { function buildCatShards (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.shards](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html) request * Perform a [cat.shards](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-shards.html) request
* *
* @param {list} index - A comma-separated list of index names to limit the returned information * @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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -70,17 +85,17 @@ function buildCatShards (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -99,8 +114,34 @@ function buildCatShards (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatSnapshots (opts) { function buildCatSnapshots (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html) request * Perform a [cat.snapshots](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-snapshots.html) request
* *
* @param {list} repository - Name of repository from which to fetch the snapshot information * @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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -58,6 +73,10 @@ function buildCatSnapshots (opts) {
} }
// check required parameters // check required parameters
if (params['repository'] == null) {
const err = new ConfigurationError('Missing required parameter: repository')
return handleError(err, callback)
}
if (params.body != null) { if (params.body != null) {
const err = new ConfigurationError('This API does not require a body') const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback) return handleError(err, callback)
@ -69,17 +88,17 @@ function buildCatSnapshots (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, repository, ...querystring } = params var { method, body, repository } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'repository'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -98,8 +117,34 @@ function buildCatSnapshots (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,14 +24,15 @@
function buildCatTasks (opts) { function buildCatTasks (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request * Perform a [cat.tasks](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html) request
* *
* @param {string} format - a short version of the Accept header, e.g. json, yaml * @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} 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 {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 {boolean} detailed - Return detailed task information (default: false)
* @param {string} parent_node - Return tasks with specified parent node.
* @param {number} parent_task - Return tasks with specified parent task id. Set to -1 to return all. * @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 {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information * @param {boolean} help - Return help information
@ -29,6 +45,7 @@ function buildCatTasks (opts) {
'node_id', 'node_id',
'actions', 'actions',
'detailed', 'detailed',
'parent_node',
'parent_task', 'parent_task',
'h', 'h',
'help', 'help',
@ -43,6 +60,7 @@ function buildCatTasks (opts) {
const snakeCase = { const snakeCase = {
nodeId: 'node_id', nodeId: 'node_id',
parentNode: 'parent_node',
parentTask: 'parent_task', parentTask: 'parent_task',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
@ -72,17 +90,17 @@ function buildCatTasks (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -97,8 +115,34 @@ function buildCatTasks (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatTemplates (opts) { function buildCatTemplates (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.templates](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html) request * Perform a [cat.templates](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-templates.html) request
* *
* @param {string} name - A pattern that returned template names must match * @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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -68,17 +83,17 @@ function buildCatTemplates (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, name, ...querystring } = params var { method, body, name } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'name'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -97,8 +112,34 @@ function buildCatTemplates (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildCatThreadPool (opts) { function buildCatThreadPool (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cat.thread_pool](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html) request * Perform a [cat.thread_pool](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/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 {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 {string} format - a short version of the Accept header, e.g. json, yaml
@ -70,17 +85,17 @@ function buildCatThreadPool (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, threadPoolPatterns, thread_pool_patterns, ...querystring } = params var { method, body, threadPoolPatterns, thread_pool_patterns } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'threadPoolPatterns', 'thread_pool_patterns'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -99,8 +114,34 @@ function buildCatThreadPool (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,81 +0,0 @@
// 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 buildCcrDeleteAutoFollowPattern (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = 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 acceptedQuerystring = [
]
const snakeCase = {
}
return function ccrDeleteAutoFollowPattern (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)
if (method == null) {
method = 'DELETE'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + 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 = buildCcrDeleteAutoFollowPattern

View File

@ -1,87 +0,0 @@
// 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 buildCcrFollow (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = 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 acceptedQuerystring = [
'wait_for_active_shards'
]
const snakeCase = {
waitForActiveShards: 'wait_for_active_shards'
}
return function ccrFollow (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)
if (method == null) {
method = 'PUT'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'follow'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCcrFollow

View File

@ -1,75 +0,0 @@
// 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 buildCcrFollowInfo (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = 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 acceptedQuerystring = [
]
const snakeCase = {
}
return function ccrFollowInfo (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)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'info'
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCcrFollowInfo

View File

@ -1,81 +0,0 @@
// 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 buildCcrFollowStats (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = 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 acceptedQuerystring = [
]
const snakeCase = {
}
return function ccrFollowStats (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)
}
// 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)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + '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 = buildCcrFollowStats

View File

@ -1,86 +0,0 @@
// 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
/**
* Perform a [ccr.forget_follower](http://www.elastic.co/guide/en/elasticsearch/reference/current) request
*
* @param {string} index - the name of the leader index for which specified follower retention leases should be removed
* @param {object} body - the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
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)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
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,79 +0,0 @@
// 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 buildCcrGetAutoFollowPattern (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = 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 acceptedQuerystring = [
]
const snakeCase = {
}
return function ccrGetAutoFollowPattern (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)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((name) != null) {
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name)
} else {
path = '/' + '_ccr' + '/' + 'auto_follow'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCcrGetAutoFollowPattern

View File

@ -1,81 +0,0 @@
// 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 buildCcrPauseFollow (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = 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 acceptedQuerystring = [
]
const snakeCase = {
}
return function ccrPauseFollow (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)
}
// 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)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'pause_follow'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCcrPauseFollow

View File

@ -1,86 +0,0 @@
// 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 buildCcrPutAutoFollowPattern (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = 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 acceptedQuerystring = [
]
const snakeCase = {
}
return function ccrPutAutoFollowPattern (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)
if (method == null) {
method = 'PUT'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + 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 = buildCcrPutAutoFollowPattern

View File

@ -1,82 +0,0 @@
// 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 buildCcrResumeFollow (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = 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 acceptedQuerystring = [
]
const snakeCase = {
}
return function ccrResumeFollow (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)
}
// 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)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'resume_follow'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCcrResumeFollow

View File

@ -1,74 +0,0 @@
// 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 buildCcrStats (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ccr.stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html) request
*
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ccrStats (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)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ccr' + '/' + '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 = buildCcrStats

View File

@ -1,81 +0,0 @@
// 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 buildCcrUnfollow (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = 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 acceptedQuerystring = [
]
const snakeCase = {
}
return function ccrUnfollow (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)
}
// 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)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'unfollow'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildCcrUnfollow

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildClearScroll (opts) { function buildClearScroll (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [clear_scroll](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll) request * Perform a [clear_scroll](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html) request
* *
* @param {list} scroll_id - A comma-separated list of scroll IDs to clear * @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 * @param {object} body - A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter
@ -48,17 +63,17 @@ function buildClearScroll (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, scrollId, scroll_id, ...querystring } = params var { method, body, scrollId, scroll_id } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'scrollId', 'scroll_id'])
if (method == null) { if (method == null) {
method = 'DELETE' method = 'DELETE'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -77,8 +92,34 @@ function buildClearScroll (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildClusterAllocationExplain (opts) { function buildClusterAllocationExplain (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cluster.allocation_explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html) request * Perform a [cluster.allocation_explain](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-allocation-explain.html) request
* *
* @param {boolean} include_yes_decisions - Return 'YES' decisions in explanation (default: false) * @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 {boolean} include_disk_info - Return information about disk usage and shard sizes (default: false)
@ -53,17 +68,17 @@ function buildClusterAllocationExplain (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = body == null ? 'GET' : 'POST' method = body == null ? 'GET' : 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -78,8 +93,34 @@ function buildClusterAllocationExplain (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildClusterGetSettings (opts) { function buildClusterGetSettings (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cluster.get_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request * Perform a [cluster.get_settings](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html) request
* *
* @param {boolean} flat_settings - Return settings in flat format (default: false) * @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} master_timeout - Explicit operation timeout for connection to master node
@ -63,17 +78,17 @@ function buildClusterGetSettings (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -88,8 +103,34 @@ function buildClusterGetSettings (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,12 +24,11 @@
function buildClusterHealth (opts) { function buildClusterHealth (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cluster.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html) request * Perform a [cluster.health](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-health.html) request
* *
* @param {list} index - Limit the information returned to a specific index * @param {list} index - Limit the information returned to a specific index
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {enum} level - Specify the level of detail for returned information * @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 {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} master_timeout - Explicit operation timeout for connection to master node
@ -23,12 +37,10 @@ function buildClusterHealth (opts) {
* @param {string} wait_for_nodes - Wait until the specified number of nodes is available * @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 {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_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 * @param {enum} wait_for_status - Wait until cluster is in a specific state
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'expand_wildcards',
'level', 'level',
'local', 'local',
'master_timeout', 'master_timeout',
@ -37,7 +49,6 @@ function buildClusterHealth (opts) {
'wait_for_nodes', 'wait_for_nodes',
'wait_for_events', 'wait_for_events',
'wait_for_no_relocating_shards', 'wait_for_no_relocating_shards',
'wait_for_no_initializing_shards',
'wait_for_status', 'wait_for_status',
'pretty', 'pretty',
'human', 'human',
@ -47,13 +58,11 @@ function buildClusterHealth (opts) {
] ]
const snakeCase = { const snakeCase = {
expandWildcards: 'expand_wildcards',
masterTimeout: 'master_timeout', masterTimeout: 'master_timeout',
waitForActiveShards: 'wait_for_active_shards', waitForActiveShards: 'wait_for_active_shards',
waitForNodes: 'wait_for_nodes', waitForNodes: 'wait_for_nodes',
waitForEvents: 'wait_for_events', waitForEvents: 'wait_for_events',
waitForNoRelocatingShards: 'wait_for_no_relocating_shards', waitForNoRelocatingShards: 'wait_for_no_relocating_shards',
waitForNoInitializingShards: 'wait_for_no_initializing_shards',
waitForStatus: 'wait_for_status', waitForStatus: 'wait_for_status',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
@ -83,17 +92,17 @@ function buildClusterHealth (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -112,8 +121,34 @@ function buildClusterHealth (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildClusterPendingTasks (opts) { function buildClusterPendingTasks (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cluster.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html) request * Perform a [cluster.pending_tasks](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-pending.html) request
* *
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) * @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 {time} master_timeout - Specify timeout for connection to master
@ -57,17 +72,17 @@ function buildClusterPendingTasks (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -82,8 +97,34 @@ function buildClusterPendingTasks (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildClusterPutSettings (opts) { function buildClusterPutSettings (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cluster.put_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request * Perform a [cluster.put_settings](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html) request
* *
* @param {boolean} flat_settings - Return settings in flat format (default: false) * @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} master_timeout - Explicit operation timeout for connection to master node
@ -49,29 +64,23 @@ function buildClusterPutSettings (opts) {
options = {} options = {}
} }
// check required parameters
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// validate headers object // validate headers object
if (options.headers != null && typeof options.headers !== 'object') { if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'PUT' method = 'PUT'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -86,8 +95,34 @@ function buildClusterPutSettings (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildClusterRemoteInfo (opts) { function buildClusterRemoteInfo (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cluster.remote_info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html) request * Perform a [cluster.remote_info](http://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-remote-info.html) request
* *
*/ */
@ -52,17 +67,17 @@ function buildClusterRemoteInfo (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -77,8 +92,34 @@ function buildClusterRemoteInfo (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildClusterReroute (opts) { function buildClusterReroute (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cluster.reroute](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html) request * Perform a [cluster.reroute](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-reroute.html) request
* *
* @param {boolean} dry_run - Simulate the operation only and return the resulting state * @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} explain - Return an explanation of why the commands can or cannot be executed
@ -62,17 +77,17 @@ function buildClusterReroute (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, ...querystring } = params var { method, body } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body'])
if (method == null) { if (method == null) {
method = 'POST' method = 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -87,8 +102,34 @@ function buildClusterReroute (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,17 +24,15 @@
function buildClusterState (opts) { function buildClusterState (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cluster.state](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html) request * Perform a [cluster.state](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/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} 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 {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 {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 {time} master_timeout - Specify timeout for connection to master
* @param {boolean} flat_settings - Return settings in flat format (default: false) * @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} 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 {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 {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
@ -29,8 +42,6 @@ function buildClusterState (opts) {
'local', 'local',
'master_timeout', 'master_timeout',
'flat_settings', 'flat_settings',
'wait_for_metadata_version',
'wait_for_timeout',
'ignore_unavailable', 'ignore_unavailable',
'allow_no_indices', 'allow_no_indices',
'expand_wildcards', 'expand_wildcards',
@ -44,8 +55,6 @@ function buildClusterState (opts) {
const snakeCase = { const snakeCase = {
masterTimeout: 'master_timeout', masterTimeout: 'master_timeout',
flatSettings: 'flat_settings', flatSettings: 'flat_settings',
waitForMetadataVersion: 'wait_for_metadata_version',
waitForTimeout: 'wait_for_timeout',
ignoreUnavailable: 'ignore_unavailable', ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices', allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards', expandWildcards: 'expand_wildcards',
@ -83,17 +92,17 @@ function buildClusterState (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, metric, ...querystring } = params var { method, body, index, metric } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index', 'metric'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -114,8 +123,34 @@ function buildClusterState (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildClusterStats (opts) { function buildClusterStats (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [cluster.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html) request * Perform a [cluster.stats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/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 {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 {boolean} flat_settings - Return settings in flat format (default: false)
@ -58,17 +73,17 @@ function buildClusterStats (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, nodeId, node_id, ...querystring } = params var { method, body, nodeId, node_id } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -87,8 +102,34 @@ function buildClusterStats (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,14 +24,13 @@
function buildCount (opts) { function buildCount (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [count](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html) request * Perform a [count](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-count.html) request
* *
* @param {list} index - A comma-separated list of indices to restrict the results * @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 {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_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 {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 {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 {number} min_score - Include only documents with a specific `_score` value in the result
@ -34,7 +48,6 @@ function buildCount (opts) {
const acceptedQuerystring = [ const acceptedQuerystring = [
'ignore_unavailable', 'ignore_unavailable',
'ignore_throttled',
'allow_no_indices', 'allow_no_indices',
'expand_wildcards', 'expand_wildcards',
'min_score', 'min_score',
@ -56,7 +69,6 @@ function buildCount (opts) {
const snakeCase = { const snakeCase = {
ignoreUnavailable: 'ignore_unavailable', ignoreUnavailable: 'ignore_unavailable',
ignoreThrottled: 'ignore_throttled',
allowNoIndices: 'allow_no_indices', allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards', expandWildcards: 'expand_wildcards',
minScore: 'min_score', minScore: 'min_score',
@ -91,17 +103,17 @@ function buildCount (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, type, ...querystring } = params var { method, body, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
if (method == null) { if (method == null) {
method = body == null ? 'GET' : 'POST' method = body == null ? 'GET' : 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -122,8 +134,34 @@ function buildCount (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

171
api/api/count_percolate.js Normal file
View File

@ -0,0 +1,171 @@
/*
* 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.
*/
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildCountPercolate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [count_percolate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html) request
*
* @param {string} index - The index of the document being count percolated.
* @param {string} type - The type of the document being count percolated.
* @param {string} id - Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster.
* @param {list} routing - A comma-separated list of specific routing values
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
* @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.
* @param {string} percolate_index - The index to count percolate the document into. Defaults to index.
* @param {string} percolate_type - The type to count percolate document into. Defaults to type.
* @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type
* @param {object} body - The count percolator request definition using the percolate DSL
*/
const acceptedQuerystring = [
'routing',
'preference',
'ignore_unavailable',
'allow_no_indices',
'expand_wildcards',
'percolate_index',
'percolate_type',
'version',
'version_type',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',
percolateIndex: 'percolate_index',
percolateType: 'percolate_type',
versionType: 'version_type',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function countPercolate (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['type'] == null) {
const err = new ConfigurationError('Missing required parameter: type')
return handleError(err, callback)
}
// check required url components
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: type, index')
return handleError(err, callback)
} else if (params['type'] != 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') {
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, type, id } = params
var querystring = semicopy(params, ['method', 'body', 'index', 'type', 'id'])
if (method == null) {
method = body == null ? 'GET' : 'POST'
}
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_percolate' + '/' + 'count'
} else {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_percolate' + '/' + 'count'
}
// build request object
const request = {
method,
path,
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
}
}
}
module.exports = buildCountPercolate

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,17 +24,20 @@
function buildCreate (opts) { function buildCreate (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [create](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request * Perform a [create](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html) request
* *
* @param {string} id - Document ID * @param {string} id - Document ID
* @param {string} index - The name of the index * @param {string} index - The name of the index
* @param {string} type - The type of the document * @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} 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 {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 {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout * @param {time} timeout - Explicit operation timeout
* @param {time} timestamp - Explicit timestamp for the document
* @param {time} ttl - Expiration time for the document
* @param {number} version - Explicit version number for concurrency control * @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type * @param {enum} version_type - Specific version type
* @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {string} pipeline - The pipeline id to preprocess incoming documents with
@ -28,9 +46,12 @@ function buildCreate (opts) {
const acceptedQuerystring = [ const acceptedQuerystring = [
'wait_for_active_shards', 'wait_for_active_shards',
'parent',
'refresh', 'refresh',
'routing', 'routing',
'timeout', 'timeout',
'timestamp',
'ttl',
'version', 'version',
'version_type', 'version_type',
'pipeline', 'pipeline',
@ -69,6 +90,10 @@ function buildCreate (opts) {
const err = new ConfigurationError('Missing required parameter: index') const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback) return handleError(err, callback)
} }
if (params['type'] == null) {
const err = new ConfigurationError('Missing required parameter: type')
return handleError(err, callback)
}
if (params['body'] == null) { if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body') const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback) return handleError(err, callback)
@ -80,26 +105,22 @@ function buildCreate (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, id, index, type, ...querystring } = params var { method, body, id, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
if (method == null) { if (method == null) {
method = 'PUT' method = 'PUT'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
if ((index) != null && (type) != null && (id) != null) { path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create'
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id)
}
// build request object // build request object
const request = { const request = {
@ -109,8 +130,34 @@ function buildCreate (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,85 +0,0 @@
// 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 buildDataFrameDeleteDataFrameTransform (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [data_frame.delete_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-data-frame-transform.html) request
*
* @param {string} transform_id - The id of the transform to delete
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function dataFrameDeleteDataFrameTransform (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['transform_id'] == null && params['transformId'] == null) {
const err = new ConfigurationError('Missing required parameter: transform_id or transformId')
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') {
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)
if (method == null) {
method = 'DELETE'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId)
// build request object
const request = {
method,
path,
body: '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildDataFrameDeleteDataFrameTransform

View File

@ -1,90 +0,0 @@
// 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 buildDataFrameGetDataFrameTransform (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [data_frame.get_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform.html) request
*
* @param {string} transform_id - The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all transforms
* @param {int} from - skips a number of transform configs, defaults to 0
* @param {int} size - specifies a max number of transforms to get, defaults to 100
* @param {boolean} allow_no_match - Whether to ignore if a wildcard expression matches no data frame transforms. (This includes `_all` string or when no data frame transforms have been specified)
*/
const acceptedQuerystring = [
'from',
'size',
'allow_no_match'
]
const snakeCase = {
allowNoMatch: 'allow_no_match'
}
return function dataFrameGetDataFrameTransform (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.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 = []
var { method, body, transformId, transform_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((transform_id || transformId) != null) {
path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId)
} else {
path = '/' + '_data_frame' + '/' + '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 = buildDataFrameGetDataFrameTransform

View File

@ -1,86 +0,0 @@
// 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 buildDataFrameGetDataFrameTransformStats (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [data_frame.get_data_frame_transform_stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform-stats.html) request
*
* @param {string} transform_id - The id of the transform for which to get stats. '_all' or '*' implies all transforms
* @param {number} from - skips a number of transform stats, defaults to 0
* @param {number} size - specifies a max number of transform stats to get, defaults to 100
* @param {boolean} allow_no_match - Whether to ignore if a wildcard expression matches no data frame transforms. (This includes `_all` string or when no data frame transforms have been specified)
*/
const acceptedQuerystring = [
'from',
'size',
'allow_no_match'
]
const snakeCase = {
allowNoMatch: 'allow_no_match'
}
return function dataFrameGetDataFrameTransformStats (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.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 = []
var { method, body, transformId, transform_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_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 = buildDataFrameGetDataFrameTransformStats

View File

@ -1,81 +0,0 @@
// 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 buildDataFramePreviewDataFrameTransform (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [data_frame.preview_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-data-frame-transform.html) request
*
* @param {object} body - The definition for the data_frame transform to preview
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function dataFramePreviewDataFrameTransform (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['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, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_data_frame' + '/' + 'transforms' + '/' + '_preview'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildDataFramePreviewDataFrameTransform

View File

@ -1,86 +0,0 @@
// 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 buildDataFramePutDataFrameTransform (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [data_frame.put_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-data-frame-transform.html) request
*
* @param {string} transform_id - The id of the new transform.
* @param {object} body - The data frame transform definition
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function dataFramePutDataFrameTransform (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['transform_id'] == null && params['transformId'] == null) {
const err = new ConfigurationError('Missing required parameter: transform_id or transformId')
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, transformId, transform_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'PUT'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildDataFramePutDataFrameTransform

View File

@ -1,86 +0,0 @@
// 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 buildDataFrameStartDataFrameTransform (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [data_frame.start_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/start-data-frame-transform.html) request
*
* @param {string} transform_id - The id of the transform to start
* @param {time} timeout - Controls the time to wait for the transform to start
*/
const acceptedQuerystring = [
'timeout'
]
const snakeCase = {
}
return function dataFrameStartDataFrameTransform (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['transform_id'] == null && params['transformId'] == null) {
const err = new ConfigurationError('Missing required parameter: transform_id or transformId')
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') {
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)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_start'
// build request object
const request = {
method,
path,
body: '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildDataFrameStartDataFrameTransform

View File

@ -1,91 +0,0 @@
// 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 buildDataFrameStopDataFrameTransform (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [data_frame.stop_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-data-frame-transform.html) request
*
* @param {string} transform_id - The id of the transform to stop
* @param {boolean} wait_for_completion - Whether to wait for the transform to fully stop before returning or not. Default to false
* @param {time} timeout - Controls the time to wait until the transform has stopped. Default to 30 seconds
* @param {boolean} allow_no_match - Whether to ignore if a wildcard expression matches no data frame transforms. (This includes `_all` string or when no data frame transforms have been specified)
*/
const acceptedQuerystring = [
'wait_for_completion',
'timeout',
'allow_no_match'
]
const snakeCase = {
waitForCompletion: 'wait_for_completion',
allowNoMatch: 'allow_no_match'
}
return function dataFrameStopDataFrameTransform (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['transform_id'] == null && params['transformId'] == null) {
const err = new ConfigurationError('Missing required parameter: transform_id or transformId')
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') {
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)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stop'
// build request object
const request = {
method,
path,
body: '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildDataFrameStopDataFrameTransform

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,30 +24,28 @@
function buildDelete (opts) { function buildDelete (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html) request * Perform a [delete](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete.html) request
* *
* @param {string} id - The document ID * @param {string} id - The document ID
* @param {string} index - The name of the index * @param {string} index - The name of the index
* @param {string} type - The type of the document * @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} 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 {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 {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout * @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 {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type * @param {enum} version_type - Specific version type
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'wait_for_active_shards', 'wait_for_active_shards',
'parent',
'refresh', 'refresh',
'routing', 'routing',
'timeout', 'timeout',
'if_seq_no',
'if_primary_term',
'version', 'version',
'version_type', 'version_type',
'pretty', 'pretty',
@ -44,8 +57,6 @@ function buildDelete (opts) {
const snakeCase = { const snakeCase = {
waitForActiveShards: 'wait_for_active_shards', waitForActiveShards: 'wait_for_active_shards',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
versionType: 'version_type', versionType: 'version_type',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
@ -72,37 +83,46 @@ function buildDelete (opts) {
const err = new ConfigurationError('Missing required parameter: index') const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback) return handleError(err, callback)
} }
if (params['type'] == null) {
const err = new ConfigurationError('Missing required parameter: type')
return handleError(err, callback)
}
if (params.body != null) { if (params.body != null) {
const err = new ConfigurationError('This API does not require a body') const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback) return handleError(err, callback)
} }
// check required url components
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: type, index')
return handleError(err, callback)
} else if (params['type'] != null && (params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: index')
return handleError(err, callback)
}
// validate headers object // validate headers object
if (options.headers != null && typeof options.headers !== 'object') { if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, id, index, type, ...querystring } = params var { method, body, id, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
if (method == null) { if (method == null) {
method = 'DELETE' method = 'DELETE'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
if ((index) != null && (type) != null && (id) != null) { path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
} else {
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
}
// build request object // build request object
const request = { const request = {
@ -112,8 +132,34 @@ function buildDelete (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildDeleteByQuery (opts) { function buildDeleteByQuery (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts 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 * Perform a [delete_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/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} 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 {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
@ -22,7 +37,7 @@ function buildDeleteByQuery (opts) {
* @param {number} from - Starting offset (default: 0) * @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} 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 {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} 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 {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 {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} preference - Specify the node or shard the operation should be performed on (default: random)
@ -31,12 +46,11 @@ function buildDeleteByQuery (opts) {
* @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search * @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 {enum} search_type - Search operation type
* @param {time} search_timeout - Explicit timeout for each search request. Defaults to no timeout. * @param {time} search_timeout - Explicit timeout for each search request. Defaults to no timeout.
* @param {number} size - Deprecated, please use `max_docs` instead * @param {number} size - Number of hits to return (default: 10)
* @param {number} max_docs - Maximum number of documents to process (default: all documents)
* @param {list} sort - A comma-separated list of <field>:<direction> pairs * @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 - 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_exclude - 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 {list} _source_include - 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 {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 {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} version - Specify whether to return document version as part of a hit
@ -44,8 +58,8 @@ function buildDeleteByQuery (opts) {
* @param {boolean} refresh - Should the effected indexes be refreshed? * @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 {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 {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 {number} scroll_size - Size on the scroll request powering the update_by_query
* @param {boolean} wait_for_completion - Should the request should block until the delete by query is complete. * @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} 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 {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 * @param {object} body - The search definition using the Query DSL
@ -69,12 +83,9 @@ function buildDeleteByQuery (opts) {
'search_type', 'search_type',
'search_timeout', 'search_timeout',
'size', 'size',
'max_docs',
'sort', 'sort',
'_source', '_source',
'_source_excludes',
'_source_exclude', '_source_exclude',
'_source_includes',
'_source_include', '_source_include',
'terminate_after', 'terminate_after',
'stats', 'stats',
@ -102,10 +113,7 @@ function buildDeleteByQuery (opts) {
expandWildcards: 'expand_wildcards', expandWildcards: 'expand_wildcards',
searchType: 'search_type', searchType: 'search_type',
searchTimeout: 'search_timeout', searchTimeout: 'search_timeout',
maxDocs: 'max_docs',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude', _sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include', _sourceInclude: '_source_include',
terminateAfter: 'terminate_after', terminateAfter: 'terminate_after',
requestCache: 'request_cache', requestCache: 'request_cache',
@ -151,17 +159,17 @@ function buildDeleteByQuery (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, type, ...querystring } = params var { method, body, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index', 'type'])
if (method == null) { if (method == null) {
method = 'POST' method = 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -180,8 +188,34 @@ function buildDeleteByQuery (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,97 +0,0 @@
// 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 buildDeleteByQueryRethrottle (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = 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 acceptedQuerystring = [
'requests_per_second',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
requestsPerSecond: 'requests_per_second',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function deleteByQueryRethrottle (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['task_id'] == null && params['taskId'] == null) {
const err = new ConfigurationError('Missing required parameter: task_id or taskId')
return handleError(err, callback)
}
if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) {
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') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
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
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_delete_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle'
// build request object
const request = {
method,
path,
body: '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildDeleteByQueryRethrottle

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,11 +24,12 @@
function buildDeleteScript (opts) { function buildDeleteScript (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [delete_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request * Perform a [delete_script](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html) request
* *
* @param {string} id - Script ID * @param {string} id - Script ID
* @param {string} lang - Script language
* @param {time} timeout - Explicit operation timeout * @param {time} timeout - Explicit operation timeout
* @param {time} master_timeout - Specify timeout for connection to master * @param {time} master_timeout - Specify timeout for connection to master
*/ */
@ -51,33 +67,47 @@ function buildDeleteScript (opts) {
const err = new ConfigurationError('Missing required parameter: id') const err = new ConfigurationError('Missing required parameter: id')
return handleError(err, callback) return handleError(err, callback)
} }
if (params['lang'] == null) {
const err = new ConfigurationError('Missing required parameter: lang')
return handleError(err, callback)
}
if (params.body != null) { if (params.body != null) {
const err = new ConfigurationError('This API does not require a body') const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback) return handleError(err, callback)
} }
// check required url components
if (params['id'] != null && (params['lang'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: lang')
return handleError(err, callback)
}
// validate headers object // validate headers object
if (options.headers != null && typeof options.headers !== 'object') { if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, id, ...querystring } = params var { method, body, id, lang } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'id', 'lang'])
if (method == null) { if (method == null) {
method = 'DELETE' method = 'DELETE'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
path = '/' + '_scripts' + '/' + encodeURIComponent(id) if ((lang) != null && (id) != null) {
path = '/' + '_scripts' + '/' + encodeURIComponent(lang) + '/' + encodeURIComponent(id)
} else {
path = '/' + '_scripts' + '/' + encodeURIComponent(lang)
}
// build request object // build request object
const request = { const request = {
@ -87,8 +117,34 @@ function buildDeleteScript (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

131
api/api/delete_template.js Normal file
View File

@ -0,0 +1,131 @@
/*
* 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.
*/
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildDeleteTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [delete_template](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html) request
*
* @param {string} id - Template ID
*/
const acceptedQuerystring = [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function deleteTemplate (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)
}
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, id } = params
var querystring = semicopy(params, ['method', 'body', 'id'])
if (method == null) {
method = 'DELETE'
}
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
var path = ''
path = '/' + '_search' + '/' + 'template' + '/' + encodeURIComponent(id)
// build request object
const request = {
method,
path,
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
}
}
}
module.exports = buildDeleteTemplate

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,35 +24,35 @@
function buildExists (opts) { function buildExists (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * Perform a [exists](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html) request
* *
* @param {string} id - The document ID * @param {string} id - The document ID
* @param {string} index - The name of the index * @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 {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 {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 {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} 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 {boolean} refresh - Refresh the shard containing the document before performing the operation
* @param {string} routing - Specific routing value * @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 - 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_exclude - 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 {list} _source_include - A list of fields to extract and return from the _source field
* @param {number} version - Explicit version number for concurrency control * @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type * @param {enum} version_type - Specific version type
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'stored_fields', 'stored_fields',
'parent',
'preference', 'preference',
'realtime', 'realtime',
'refresh', 'refresh',
'routing', 'routing',
'_source', '_source',
'_source_excludes',
'_source_exclude', '_source_exclude',
'_source_includes',
'_source_include', '_source_include',
'version', 'version',
'version_type', 'version_type',
@ -50,9 +65,7 @@ function buildExists (opts) {
const snakeCase = { const snakeCase = {
storedFields: 'stored_fields', storedFields: 'stored_fields',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude', _sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include', _sourceInclude: '_source_include',
versionType: 'version_type', versionType: 'version_type',
errorTrace: 'error_trace', errorTrace: 'error_trace',
@ -80,6 +93,10 @@ function buildExists (opts) {
const err = new ConfigurationError('Missing required parameter: index') const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback) return handleError(err, callback)
} }
if (params['type'] == null) {
const err = new ConfigurationError('Missing required parameter: type')
return handleError(err, callback)
}
if (params.body != null) { if (params.body != null) {
const err = new ConfigurationError('This API does not require a body') const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback) return handleError(err, callback)
@ -91,26 +108,22 @@ function buildExists (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, id, index, type, ...querystring } = params var { method, body, id, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
if (method == null) { if (method == null) {
method = 'HEAD' method = 'HEAD'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
if ((index) != null && (type) != null && (id) != null) { path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
} else {
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
}
// build request object // build request object
const request = { const request = {
@ -120,8 +133,34 @@ function buildExists (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,33 +24,33 @@
function buildExistsSource (opts) { function buildExistsSource (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [exists_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * Perform a [exists_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request
* *
* @param {string} id - The document ID * @param {string} id - The document ID
* @param {string} index - The name of the index * @param {string} index - The name of the index
* @param {string} type - The type of the document; deprecated and optional starting with 7.0 * @param {string} type - The type of the document; use `_all` to fetch the first document matching the ID across all types
* @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 {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} 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 {boolean} refresh - Refresh the shard containing the document before performing the operation
* @param {string} routing - Specific routing value * @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 - 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_exclude - 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 {list} _source_include - A list of fields to extract and return from the _source field
* @param {number} version - Explicit version number for concurrency control * @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type * @param {enum} version_type - Specific version type
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'parent',
'preference', 'preference',
'realtime', 'realtime',
'refresh', 'refresh',
'routing', 'routing',
'_source', '_source',
'_source_excludes',
'_source_exclude', '_source_exclude',
'_source_includes',
'_source_include', '_source_include',
'version', 'version',
'version_type', 'version_type',
@ -47,9 +62,7 @@ function buildExistsSource (opts) {
] ]
const snakeCase = { const snakeCase = {
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude', _sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include', _sourceInclude: '_source_include',
versionType: 'version_type', versionType: 'version_type',
errorTrace: 'error_trace', errorTrace: 'error_trace',
@ -77,6 +90,10 @@ function buildExistsSource (opts) {
const err = new ConfigurationError('Missing required parameter: index') const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback) return handleError(err, callback)
} }
if (params['type'] == null) {
const err = new ConfigurationError('Missing required parameter: type')
return handleError(err, callback)
}
if (params.body != null) { if (params.body != null) {
const err = new ConfigurationError('This API does not require a body') const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback) return handleError(err, callback)
@ -97,26 +114,22 @@ function buildExistsSource (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, id, index, type, ...querystring } = params var { method, body, id, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
if (method == null) { if (method == null) {
method = 'HEAD' method = 'HEAD'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
if ((index) != null && (type) != null && (id) != null) { path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id)
}
// build request object // build request object
const request = { const request = {
@ -126,8 +139,34 @@ function buildExistsSource (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildExplain (opts) { function buildExplain (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html) request * Perform a [explain](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-explain.html) request
* *
* @param {string} id - The document ID * @param {string} id - The document ID
* @param {string} index - The name of the index * @param {string} index - The name of the index
@ -22,12 +37,13 @@ function buildExplain (opts) {
* @param {string} df - The default field for query string query (default: _all) * @param {string} df - The default field for query string query (default: _all)
* @param {list} stored_fields - A comma-separated list of stored fields to return in the response * @param {list} stored_fields - A comma-separated list of stored fields to return in the response
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored * @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @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 {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 {string} q - Query in the Lucene query string syntax
* @param {string} routing - Specific routing value * @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 - 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_exclude - 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 {list} _source_include - A list of fields to extract and return from the _source field
* @param {object} body - The query definition using the Query DSL * @param {object} body - The query definition using the Query DSL
*/ */
@ -38,13 +54,12 @@ function buildExplain (opts) {
'df', 'df',
'stored_fields', 'stored_fields',
'lenient', 'lenient',
'parent',
'preference', 'preference',
'q', 'q',
'routing', 'routing',
'_source', '_source',
'_source_excludes',
'_source_exclude', '_source_exclude',
'_source_includes',
'_source_include', '_source_include',
'pretty', 'pretty',
'human', 'human',
@ -57,9 +72,7 @@ function buildExplain (opts) {
analyzeWildcard: 'analyze_wildcard', analyzeWildcard: 'analyze_wildcard',
defaultOperator: 'default_operator', defaultOperator: 'default_operator',
storedFields: 'stored_fields', storedFields: 'stored_fields',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude', _sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include', _sourceInclude: '_source_include',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
@ -86,6 +99,10 @@ function buildExplain (opts) {
const err = new ConfigurationError('Missing required parameter: index') const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback) return handleError(err, callback)
} }
if (params['type'] == null) {
const err = new ConfigurationError('Missing required parameter: type')
return handleError(err, callback)
}
// validate headers object // validate headers object
if (options.headers != null && typeof options.headers !== 'object') { if (options.headers != null && typeof options.headers !== 'object') {
@ -93,26 +110,22 @@ function buildExplain (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, id, index, type, ...querystring } = params var { method, body, id, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
if (method == null) { if (method == null) {
method = body == null ? 'GET' : 'POST' method = body == null ? 'GET' : 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
if ((index) != null && (type) != null && (id) != null) { path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_explain'
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_explain'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_explain' + '/' + encodeURIComponent(id)
}
// build request object // build request object
const request = { const request = {
@ -122,8 +135,34 @@ function buildExplain (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,16 +24,16 @@
function buildFieldCaps (opts) { function buildFieldCaps (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [field_caps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request * Perform a [field_caps](http://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-field-caps.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} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
* @param {list} fields - A comma-separated list of field names * @param {list} fields - A comma-separated list of field names
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @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 {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 {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {boolean} include_unmapped - Indicates whether unmapped fields should be included in the response. * @param {object} body - Field json objects containing an array of field names
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
@ -26,7 +41,6 @@ function buildFieldCaps (opts) {
'ignore_unavailable', 'ignore_unavailable',
'allow_no_indices', 'allow_no_indices',
'expand_wildcards', 'expand_wildcards',
'include_unmapped',
'pretty', 'pretty',
'human', 'human',
'error_trace', 'error_trace',
@ -38,7 +52,6 @@ function buildFieldCaps (opts) {
ignoreUnavailable: 'ignore_unavailable', ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices', allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards', expandWildcards: 'expand_wildcards',
includeUnmapped: 'include_unmapped',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
} }
@ -55,29 +68,23 @@ function buildFieldCaps (opts) {
options = {} 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 // validate headers object
if (options.headers != null && typeof options.headers !== 'object') { if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = body == null ? 'GET' : 'POST' method = body == null ? 'GET' : 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -92,12 +99,38 @@ function buildFieldCaps (opts) {
const request = { const request = {
method, method,
path, path,
body: '', body: body || '',
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

139
api/api/field_stats.js Normal file
View File

@ -0,0 +1,139 @@
/*
* 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.
*/
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildFieldStats (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [field_stats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-field-stats.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} fields - A comma-separated list of fields for to get field statistics for (min value, max value, and more)
* @param {enum} level - Defines if field stats should be returned on a per index level or on a cluster wide level
* @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.
* @param {object} body - Field json objects containing the name and optionally a range to filter out indices result, that have results outside the defined bounds
*/
const acceptedQuerystring = [
'fields',
'level',
'ignore_unavailable',
'allow_no_indices',
'expand_wildcards',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function fieldStats (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 = null
var { method, body, index } = params
var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) {
method = body == null ? 'GET' : 'POST'
}
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
var path = ''
if ((index) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_field_stats'
} else {
path = '/' + '_field_stats'
}
// build request object
const request = {
method,
path,
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
}
}
}
module.exports = buildFieldStats

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,35 +24,35 @@
function buildGet (opts) { function buildGet (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [get](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * Perform a [get](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html) request
* *
* @param {string} id - The document ID * @param {string} id - The document ID
* @param {string} index - The name of the index * @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 {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 {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 {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} 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 {boolean} refresh - Refresh the shard containing the document before performing the operation
* @param {string} routing - Specific routing value * @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 - 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_exclude - 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 {list} _source_include - A list of fields to extract and return from the _source field
* @param {number} version - Explicit version number for concurrency control * @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type * @param {enum} version_type - Specific version type
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'stored_fields', 'stored_fields',
'parent',
'preference', 'preference',
'realtime', 'realtime',
'refresh', 'refresh',
'routing', 'routing',
'_source', '_source',
'_source_excludes',
'_source_exclude', '_source_exclude',
'_source_includes',
'_source_include', '_source_include',
'version', 'version',
'version_type', 'version_type',
@ -50,9 +65,7 @@ function buildGet (opts) {
const snakeCase = { const snakeCase = {
storedFields: 'stored_fields', storedFields: 'stored_fields',
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude', _sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include', _sourceInclude: '_source_include',
versionType: 'version_type', versionType: 'version_type',
errorTrace: 'error_trace', errorTrace: 'error_trace',
@ -80,6 +93,10 @@ function buildGet (opts) {
const err = new ConfigurationError('Missing required parameter: index') const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback) return handleError(err, callback)
} }
if (params['type'] == null) {
const err = new ConfigurationError('Missing required parameter: type')
return handleError(err, callback)
}
if (params.body != null) { if (params.body != null) {
const err = new ConfigurationError('This API does not require a body') const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback) return handleError(err, callback)
@ -91,26 +108,22 @@ function buildGet (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, id, index, type, ...querystring } = params var { method, body, id, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
if ((index) != null && (type) != null && (id) != null) { path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
} else {
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
}
// build request object // build request object
const request = { const request = {
@ -120,8 +133,34 @@ function buildGet (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,16 +24,15 @@
function buildGetScript (opts) { function buildGetScript (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [get_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request * Perform a [get_script](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html) request
* *
* @param {string} id - Script ID * @param {string} id - Script ID
* @param {time} master_timeout - Specify timeout for connection to master * @param {string} lang - Script language
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'master_timeout',
'pretty', 'pretty',
'human', 'human',
'error_trace', 'error_trace',
@ -27,7 +41,6 @@ function buildGetScript (opts) {
] ]
const snakeCase = { const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
} }
@ -49,33 +62,47 @@ function buildGetScript (opts) {
const err = new ConfigurationError('Missing required parameter: id') const err = new ConfigurationError('Missing required parameter: id')
return handleError(err, callback) return handleError(err, callback)
} }
if (params['lang'] == null) {
const err = new ConfigurationError('Missing required parameter: lang')
return handleError(err, callback)
}
if (params.body != null) { if (params.body != null) {
const err = new ConfigurationError('This API does not require a body') const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback) return handleError(err, callback)
} }
// check required url components
if (params['id'] != null && (params['lang'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: lang')
return handleError(err, callback)
}
// validate headers object // validate headers object
if (options.headers != null && typeof options.headers !== 'object') { if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, id, ...querystring } = params var { method, body, id, lang } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'id', 'lang'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
path = '/' + '_scripts' + '/' + encodeURIComponent(id) if ((lang) != null && (id) != null) {
path = '/' + '_scripts' + '/' + encodeURIComponent(lang) + '/' + encodeURIComponent(id)
} else {
path = '/' + '_scripts' + '/' + encodeURIComponent(lang)
}
// build request object // build request object
const request = { const request = {
@ -85,8 +112,34 @@ function buildGetScript (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,33 +24,33 @@
function buildGetSource (opts) { function buildGetSource (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [get_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * Perform a [get_source](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html) request
* *
* @param {string} id - The document ID * @param {string} id - The document ID
* @param {string} index - The name of the index * @param {string} index - The name of the index
* @param {string} type - The type of the document; deprecated and optional starting with 7.0 * @param {string} type - The type of the document; use `_all` to fetch the first document matching the ID across all types
* @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 {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} 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 {boolean} refresh - Refresh the shard containing the document before performing the operation
* @param {string} routing - Specific routing value * @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 - 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_exclude - 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 {list} _source_include - A list of fields to extract and return from the _source field
* @param {number} version - Explicit version number for concurrency control * @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type * @param {enum} version_type - Specific version type
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'parent',
'preference', 'preference',
'realtime', 'realtime',
'refresh', 'refresh',
'routing', 'routing',
'_source', '_source',
'_source_excludes',
'_source_exclude', '_source_exclude',
'_source_includes',
'_source_include', '_source_include',
'version', 'version',
'version_type', 'version_type',
@ -47,9 +62,7 @@ function buildGetSource (opts) {
] ]
const snakeCase = { const snakeCase = {
_sourceExcludes: '_source_excludes',
_sourceExclude: '_source_exclude', _sourceExclude: '_source_exclude',
_sourceIncludes: '_source_includes',
_sourceInclude: '_source_include', _sourceInclude: '_source_include',
versionType: 'version_type', versionType: 'version_type',
errorTrace: 'error_trace', errorTrace: 'error_trace',
@ -77,6 +90,10 @@ function buildGetSource (opts) {
const err = new ConfigurationError('Missing required parameter: index') const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback) return handleError(err, callback)
} }
if (params['type'] == null) {
const err = new ConfigurationError('Missing required parameter: type')
return handleError(err, callback)
}
if (params.body != null) { if (params.body != null) {
const err = new ConfigurationError('This API does not require a body') const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback) return handleError(err, callback)
@ -88,26 +105,22 @@ function buildGetSource (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, id, index, type, ...querystring } = params var { method, body, id, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
if (method == null) { if (method == null) {
method = 'GET' method = 'GET'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
if ((index) != null && (type) != null && (id) != null) { path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id)
}
// build request object // build request object
const request = { const request = {
@ -117,8 +130,34 @@ function buildGetSource (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

131
api/api/get_template.js Normal file
View File

@ -0,0 +1,131 @@
/*
* 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.
*/
'use strict'
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
function buildGetTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError } = opts
/**
* Perform a [get_template](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html) request
*
* @param {string} id - Template ID
*/
const acceptedQuerystring = [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function getTemplate (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)
}
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, id } = params
var querystring = semicopy(params, ['method', 'body', 'id'])
if (method == null) {
method = 'GET'
}
var ignore = options.ignore || null
if (typeof ignore === 'number') {
ignore = [ignore]
}
var path = ''
path = '/' + '_search' + '/' + 'template' + '/' + encodeURIComponent(id)
// build request object
const request = {
method,
path,
body: null,
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
}
}
}
module.exports = buildGetTemplate

View File

@ -1,90 +0,0 @@
// 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 buildGraphExplore (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [graph.explore](https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.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} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout
* @param {object} body - Graph Query DSL
*/
const acceptedQuerystring = [
'routing',
'timeout'
]
const snakeCase = {
}
return function graphExplore (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required url components
if (params['type'] != 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') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
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
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_graph' + '/' + 'explore'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_graph' + '/' + 'explore'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildGraphExplore

View File

@ -1,81 +0,0 @@
// 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 buildIlmDeleteLifecycle (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ilm.delete_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html) request
*
* @param {string} policy - The name of the index lifecycle policy
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ilmDeleteLifecycle (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.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 = []
var { method, body, policy, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'DELETE'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy)
// build request object
const request = {
method,
path,
body: '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIlmDeleteLifecycle

View File

@ -1,81 +0,0 @@
// 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 buildIlmExplainLifecycle (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ilm.explain_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html) request
*
* @param {string} index - The name of the index to explain
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ilmExplainLifecycle (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.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 = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'explain'
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIlmExplainLifecycle

View File

@ -1,85 +0,0 @@
// 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 buildIlmGetLifecycle (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ilm.get_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html) request
*
* @param {string} policy - The name of the index lifecycle policy
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ilmGetLifecycle (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.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 = []
var { method, body, policy, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((policy) != null) {
path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy)
} else {
path = '/' + '_ilm' + '/' + '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 = buildIlmGetLifecycle

View File

@ -1,80 +0,0 @@
// 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 buildIlmGetStatus (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ilm.get_status](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html) request
*
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ilmGetStatus (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.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 = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ilm' + '/' + 'status'
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIlmGetStatus

View File

@ -1,76 +0,0 @@
// 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 buildIlmMoveToStep (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ilm.move_to_step](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html) request
*
* @param {string} index - The name of the index whose lifecycle step is to change
* @param {object} body - The new lifecycle step to move to
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ilmMoveToStep (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)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(index)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIlmMoveToStep

View File

@ -1,76 +0,0 @@
// 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 buildIlmPutLifecycle (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ilm.put_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html) request
*
* @param {string} policy - The name of the index lifecycle policy
* @param {object} body - The lifecycle policy definition to register
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ilmPutLifecycle (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, policy, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'PUT'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIlmPutLifecycle

View File

@ -1,81 +0,0 @@
// 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 buildIlmRemovePolicy (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ilm.remove_policy](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html) request
*
* @param {string} index - The name of the index to remove policy on
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ilmRemovePolicy (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.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 = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'remove'
// build request object
const request = {
method,
path,
body: '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIlmRemovePolicy

View File

@ -1,81 +0,0 @@
// 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 buildIlmRetry (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ilm.retry](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html) request
*
* @param {string} index - The name of the indices (comma-separated) whose failed lifecycle step is to be retry
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ilmRetry (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.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 = []
var { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'retry'
// build request object
const request = {
method,
path,
body: '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIlmRetry

View File

@ -1,80 +0,0 @@
// 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 buildIlmStart (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ilm.start](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html) request
*
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ilmStart (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.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 = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ilm' + '/' + 'start'
// build request object
const request = {
method,
path,
body: '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIlmStart

View File

@ -1,80 +0,0 @@
// 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 buildIlmStop (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ilm.stop](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html) request
*
*/
const acceptedQuerystring = [
]
const snakeCase = {
}
return function ilmStop (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.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 = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ilm' + '/' + 'stop'
// build request object
const request = {
method,
path,
body: '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildIlmStop

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,22 +24,23 @@
function buildIndex (opts) { function buildIndex (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [index](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request * Perform a [index](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html) request
* *
* @param {string} id - Document ID * @param {string} id - Document ID
* @param {string} index - The name of the index * @param {string} index - The name of the index
* @param {string} type - The type of the document * @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} 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 {enum} op_type - Explicit operation type * @param {enum} op_type - Explicit operation type
* @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 {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 {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout * @param {time} timeout - Explicit operation timeout
* @param {time} timestamp - Explicit timestamp for the document
* @param {time} ttl - Expiration time for the document
* @param {number} version - Explicit version number for concurrency control * @param {number} version - Explicit version number for concurrency control
* @param {enum} version_type - Specific version type * @param {enum} version_type - Specific version type
* @param {number} if_seq_no - only perform the index operation if the last operation that has changed the document has the specified sequence number
* @param {number} if_primary_term - only perform the index operation if the last operation that has changed the document has the specified primary term
* @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {string} pipeline - The pipeline id to preprocess incoming documents with
* @param {object} body - The document * @param {object} body - The document
*/ */
@ -32,13 +48,14 @@ function buildIndex (opts) {
const acceptedQuerystring = [ const acceptedQuerystring = [
'wait_for_active_shards', 'wait_for_active_shards',
'op_type', 'op_type',
'parent',
'refresh', 'refresh',
'routing', 'routing',
'timeout', 'timeout',
'timestamp',
'ttl',
'version', 'version',
'version_type', 'version_type',
'if_seq_no',
'if_primary_term',
'pipeline', 'pipeline',
'pretty', 'pretty',
'human', 'human',
@ -51,8 +68,6 @@ function buildIndex (opts) {
waitForActiveShards: 'wait_for_active_shards', waitForActiveShards: 'wait_for_active_shards',
opType: 'op_type', opType: 'op_type',
versionType: 'version_type', versionType: 'version_type',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
} }
@ -74,40 +89,49 @@ function buildIndex (opts) {
const err = new ConfigurationError('Missing required parameter: index') const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback) return handleError(err, callback)
} }
if (params['type'] == null) {
const err = new ConfigurationError('Missing required parameter: type')
return handleError(err, callback)
}
if (params['body'] == null) { if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body') const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback) return handleError(err, callback)
} }
// check required url components
if (params['id'] != null && (params['type'] == null || params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: type, index')
return handleError(err, callback)
} else if (params['type'] != null && (params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: index')
return handleError(err, callback)
}
// validate headers object // validate headers object
if (options.headers != null && typeof options.headers !== 'object') { if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, id, index, type, ...querystring } = params var { method, body, id, index, type } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type'])
if (method == null) { if (method == null) {
method = 'POST' method = 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
if ((index) != null && (type) != null && (id) != null) { if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
} else if ((index) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
} else if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type)
} else { } else {
path = '/' + encodeURIComponent(index) + '/' + '_doc' path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type)
} }
// build request object // build request object
@ -118,8 +142,34 @@ function buildIndex (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,17 +24,37 @@
function buildIndicesAnalyze (opts) { function buildIndicesAnalyze (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [indices.analyze](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html) request * Perform a [indices.analyze](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-analyze.html) request
* *
* @param {string} index - The name of the index to scope the operation * @param {string} index - The name of the index to scope the operation
* @param {string} analyzer - The name of the analyzer to use
* @param {list} char_filter - A comma-separated list of character filters to use for the analysis
* @param {string} field - Use the analyzer configured for this field (instead of passing the analyzer name)
* @param {list} filter - A comma-separated list of filters to use for the analysis
* @param {string} index - The name of the index to scope the operation * @param {string} index - The name of the index to scope the operation
* @param {object} body - Define analyzer/tokenizer parameters and the text on which the analysis should be performed * @param {boolean} prefer_local - With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true)
* @param {list} text - The text on which the analysis should be performed (when request body is not used)
* @param {string} tokenizer - The name of the tokenizer to use for the analysis
* @param {boolean} explain - With `true`, outputs more advanced details. (default: false)
* @param {list} attributes - A comma-separated list of token attributes to output, this parameter works only with `explain=true`
* @param {enum} format - Format of the output
* @param {object} body - The text on which the analysis should be performed
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'analyzer',
'char_filter',
'field',
'filter',
'index', 'index',
'prefer_local',
'text',
'tokenizer',
'explain',
'attributes',
'format',
'pretty', 'pretty',
'human', 'human',
'error_trace', 'error_trace',
@ -28,6 +63,8 @@ function buildIndicesAnalyze (opts) {
] ]
const snakeCase = { const snakeCase = {
charFilter: 'char_filter',
preferLocal: 'prefer_local',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
} }
@ -50,17 +87,17 @@ function buildIndicesAnalyze (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = body == null ? 'GET' : 'POST' method = body == null ? 'GET' : 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -79,8 +116,34 @@ function buildIndicesAnalyze (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,22 +24,26 @@
function buildIndicesClearCache (opts) { function buildIndicesClearCache (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [indices.clear_cache](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html) request * Perform a [indices.clear_cache](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-clearcache.html) request
* *
* @param {list} index - A comma-separated list of index name to limit the operation * @param {list} index - A comma-separated list of index name to limit the operation
* @param {boolean} field_data - Clear field data
* @param {boolean} fielddata - Clear field data * @param {boolean} fielddata - Clear field data
* @param {list} fields - A comma-separated list of fields to clear when using the `fielddata` parameter (default: all) * @param {list} fields - A comma-separated list of fields to clear when using the `field_data` parameter (default: all)
* @param {boolean} query - Clear query caches * @param {boolean} query - Clear query caches
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @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 {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 {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {list} index - A comma-separated list of index name to limit the operation * @param {list} index - A comma-separated list of index name to limit the operation
* @param {boolean} recycler - Clear the recycler cache
* @param {boolean} request_cache - Clear request cache
* @param {boolean} request - Clear request cache * @param {boolean} request - Clear request cache
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'field_data',
'fielddata', 'fielddata',
'fields', 'fields',
'query', 'query',
@ -32,6 +51,8 @@ function buildIndicesClearCache (opts) {
'allow_no_indices', 'allow_no_indices',
'expand_wildcards', 'expand_wildcards',
'index', 'index',
'recycler',
'request_cache',
'request', 'request',
'pretty', 'pretty',
'human', 'human',
@ -41,9 +62,11 @@ function buildIndicesClearCache (opts) {
] ]
const snakeCase = { const snakeCase = {
fieldData: 'field_data',
ignoreUnavailable: 'ignore_unavailable', ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices', allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards', expandWildcards: 'expand_wildcards',
requestCache: 'request_cache',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
} }
@ -72,17 +95,17 @@ function buildIndicesClearCache (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'POST' method = body == null ? 'GET' : 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -101,8 +124,34 @@ function buildIndicesClearCache (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildIndicesClose (opts) { function buildIndicesClose (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [indices.close](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html) request * Perform a [indices.close](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html) request
* *
* @param {list} index - A comma separated list of indices to close * @param {list} index - A comma separated list of indices to close
* @param {time} timeout - Explicit operation timeout * @param {time} timeout - Explicit operation timeout
@ -19,7 +34,6 @@ function buildIndicesClose (opts) {
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @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 {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 {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns.
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
@ -28,7 +42,6 @@ function buildIndicesClose (opts) {
'ignore_unavailable', 'ignore_unavailable',
'allow_no_indices', 'allow_no_indices',
'expand_wildcards', 'expand_wildcards',
'wait_for_active_shards',
'pretty', 'pretty',
'human', 'human',
'error_trace', 'error_trace',
@ -41,7 +54,6 @@ function buildIndicesClose (opts) {
ignoreUnavailable: 'ignore_unavailable', ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices', allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards', expandWildcards: 'expand_wildcards',
waitForActiveShards: 'wait_for_active_shards',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
} }
@ -74,17 +86,17 @@ function buildIndicesClose (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'POST' method = 'POST'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -99,8 +111,34 @@ function buildIndicesClose (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,23 +24,23 @@
function buildIndicesCreate (opts) { function buildIndicesCreate (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [indices.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html) request * Perform a [indices.create](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-create-index.html) request
* *
* @param {string} index - The name of the index * @param {string} index - The name of the index
* @param {boolean} include_type_name - Whether a type should be expected in the body of the mappings.
* @param {string} wait_for_active_shards - Set the number of active shards to wait for before the operation returns. * @param {string} wait_for_active_shards - Set the number of active shards to wait for before the operation returns.
* @param {time} timeout - Explicit operation timeout * @param {time} timeout - Explicit operation timeout
* @param {time} master_timeout - Specify timeout for connection to master * @param {time} master_timeout - Specify timeout for connection to master
* @param {boolean} update_all_types - Whether to update the mapping for all fields with the same name across all types or not
* @param {object} body - The configuration for the index (`settings` and `mappings`) * @param {object} body - The configuration for the index (`settings` and `mappings`)
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'include_type_name',
'wait_for_active_shards', 'wait_for_active_shards',
'timeout', 'timeout',
'master_timeout', 'master_timeout',
'update_all_types',
'pretty', 'pretty',
'human', 'human',
'error_trace', 'error_trace',
@ -34,9 +49,9 @@ function buildIndicesCreate (opts) {
] ]
const snakeCase = { const snakeCase = {
includeTypeName: 'include_type_name',
waitForActiveShards: 'wait_for_active_shards', waitForActiveShards: 'wait_for_active_shards',
masterTimeout: 'master_timeout', masterTimeout: 'master_timeout',
updateAllTypes: 'update_all_types',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
} }
@ -65,17 +80,17 @@ function buildIndicesCreate (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'PUT' method = 'PUT'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -90,8 +105,34 @@ function buildIndicesCreate (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,24 +24,18 @@
function buildIndicesDelete (opts) { function buildIndicesDelete (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [indices.delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html) request * Perform a [indices.delete](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-delete-index.html) request
* *
* @param {list} index - A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices * @param {list} index - A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices
* @param {time} timeout - Explicit operation timeout * @param {time} timeout - Explicit operation timeout
* @param {time} master_timeout - Specify timeout for connection to master * @param {time} master_timeout - Specify timeout for connection to master
* @param {boolean} ignore_unavailable - Ignore unavailable indexes (default: false)
* @param {boolean} allow_no_indices - Ignore if a wildcard expression resolves to no concrete indices (default: false)
* @param {enum} expand_wildcards - Whether wildcard expressions should get expanded to open or closed indices (default: open)
*/ */
const acceptedQuerystring = [ const acceptedQuerystring = [
'timeout', 'timeout',
'master_timeout', 'master_timeout',
'ignore_unavailable',
'allow_no_indices',
'expand_wildcards',
'pretty', 'pretty',
'human', 'human',
'error_trace', 'error_trace',
@ -36,9 +45,6 @@ function buildIndicesDelete (opts) {
const snakeCase = { const snakeCase = {
masterTimeout: 'master_timeout', masterTimeout: 'master_timeout',
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',
errorTrace: 'error_trace', errorTrace: 'error_trace',
filterPath: 'filter_path' filterPath: 'filter_path'
} }
@ -71,17 +77,17 @@ function buildIndicesDelete (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'DELETE' method = 'DELETE'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -96,8 +102,34 @@ function buildIndicesDelete (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildIndicesDeleteAlias (opts) { function buildIndicesDeleteAlias (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [indices.delete_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * Perform a [indices.delete_alias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request
* *
* @param {list} index - A comma-separated list of index names (supports wildcards); use `_all` for all indices * @param {list} index - A comma-separated list of index names (supports wildcards); use `_all` for all indices
* @param {list} name - A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. * @param {list} name - A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices.
@ -73,17 +88,17 @@ function buildIndicesDeleteAlias (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, name, ...querystring } = params var { method, body, index, name } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index', 'name'])
if (method == null) { if (method == null) {
method = 'DELETE' method = 'DELETE'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -102,8 +117,34 @@ function buildIndicesDeleteAlias (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildIndicesDeleteTemplate (opts) { function buildIndicesDeleteTemplate (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [indices.delete_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * Perform a [indices.delete_template](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html) request
* *
* @param {string} name - The name of the template * @param {string} name - The name of the template
* @param {time} timeout - Explicit operation timeout * @param {time} timeout - Explicit operation timeout
@ -62,17 +77,17 @@ function buildIndicesDeleteTemplate (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, name, ...querystring } = params var { method, body, name } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'name'])
if (method == null) { if (method == null) {
method = 'DELETE' method = 'DELETE'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -87,8 +102,34 @@ function buildIndicesDeleteTemplate (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildIndicesExists (opts) { function buildIndicesExists (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [indices.exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html) request * Perform a [indices.exists](http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html) request
* *
* @param {list} index - A comma-separated list of index names * @param {list} index - A comma-separated list of index names
* @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false)
@ -74,17 +89,17 @@ function buildIndicesExists (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, ...querystring } = params var { method, body, index } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index'])
if (method == null) { if (method == null) {
method = 'HEAD' method = 'HEAD'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -99,8 +114,34 @@ function buildIndicesExists (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

View File

@ -1,6 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements. /*
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. * Licensed to Elasticsearch B.V. under one or more contributor
// See the LICENSE file in the project root for more information * 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.
*/
'use strict' 'use strict'
@ -9,9 +24,9 @@
function buildIndicesExistsAlias (opts) { function buildIndicesExistsAlias (opts) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const { makeRequest, ConfigurationError, handleError } = opts
/** /**
* Perform a [indices.exists_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * Perform a [indices.exists_alias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request
* *
* @param {list} index - A comma-separated list of index names to filter aliases * @param {list} index - A comma-separated list of index names to filter aliases
* @param {list} name - A comma-separated list of alias names to return * @param {list} name - A comma-separated list of alias names to return
@ -54,10 +69,6 @@ function buildIndicesExistsAlias (opts) {
} }
// check required parameters // check required parameters
if (params['name'] == null) {
const err = new ConfigurationError('Missing required parameter: name')
return handleError(err, callback)
}
if (params.body != null) { if (params.body != null) {
const err = new ConfigurationError('This API does not require a body') const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback) return handleError(err, callback)
@ -69,17 +80,17 @@ function buildIndicesExistsAlias (opts) {
return handleError(err, callback) return handleError(err, callback)
} }
var warnings = [] var warnings = null
var { method, body, index, name, ...querystring } = params var { method, body, index, name } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) var querystring = semicopy(params, ['method', 'body', 'index', 'name'])
if (method == null) { if (method == null) {
method = 'HEAD' method = 'HEAD'
} }
var ignore = options.ignore var ignore = options.ignore || null
if (typeof ignore === 'number') { if (typeof ignore === 'number') {
options.ignore = [ignore] ignore = [ignore]
} }
var path = '' var path = ''
@ -98,8 +109,34 @@ function buildIndicesExistsAlias (opts) {
querystring querystring
} }
options.warnings = warnings.length === 0 ? null : warnings const requestOptions = {
return makeRequest(request, options, callback) 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
}
} }
} }

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