Compare commits

...

24 Commits

Author SHA1 Message Date
dea4db1736 Bump to 9.0.0-alpha.5 (#2701) 2025-04-04 13:18:12 -05:00
d5bd34fc23 Auto-generated API code (#2700) 2025-04-04 13:02:57 -05:00
b2a490718d Update helpers to use new multisearch types (#2697)
* Update helpers to use correct multisearch types

The spec combined definitions for search and multisearch bodies in
https://github.com/elastic/elasticsearch-specification/pull/2960.

* Stop copying project files to Dockerfile

Slightly faster run times for codegen, hopefully.
2025-04-04 12:32:12 -05:00
e8dc747c61 Merge serverless functionality from @elastic/elasticsearch-serverless (#2695)
* Expose a serverMode option to enable serverless-friendly defaults

* Update basic config docs to note how the serverMode flag works

* Docs cleanup

* Add another note to docs about connecting to serverless
2025-04-03 14:41:58 -05:00
c5f9625463 replace mis-converted table (#2685) 2025-04-01 10:36:18 -05:00
a9a5aca736 Update dependency @elastic/request-converter to v9 (#2687)
Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2025-03-31 16:11:46 +00:00
64ef5359e7 Update dependency @types/node to v22.13.14 (#2686)
Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
2025-03-31 11:07:04 -05:00
1abb4e3c9f add missing mapped pages (#2684) 2025-03-27 14:01:57 -05:00
d9e9906c4e Update dependency @types/node to v22.13.13 (#2677)
Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2025-03-26 15:08:41 +00:00
1519963dd9 Update actions/setup-node digest to cdca736 (#2676)
Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
2025-03-26 10:04:59 -05:00
867ceda5a3 Auto-generated API code (#2645) 2025-03-24 17:55:18 +00:00
88270bf354 Updates navigation titles and descriptions for release notes (#2665) 2025-03-21 12:49:56 -05:00
0f09faefbd Update dependency tap to v21.1.0 (#2659)
Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
2025-03-21 12:47:43 -05:00
b775456296 Update dependency typescript to v5.8.2 (#2660)
Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
2025-03-21 12:44:48 -05:00
9de4dc5009 [docs] Miscellaneous docs clean up (#2663)
* remove unused substitutions

* move images
2025-03-21 12:42:42 -05:00
461f9b7f66 SPDX license format (#2667)
* Switch to SPDX license format for all non-codegen files

* Add test to ensure all committed JS files have SPDX header
2025-03-21 12:31:38 -05:00
afc83338b0 Assume codegen renders markdown, not asciidoc (#2664)
* Assume codegen renders markdown, not asciidoc

* Drop accidental local dev tweak
2025-03-21 11:16:10 -05:00
85396ddc67 Update dependency semver to v7.7.1 (#2654)
Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
2025-03-18 11:54:15 -05:00
16b51c2315 Update dependency @types/node to v22.13.10 (#2653)
Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
2025-03-18 10:47:34 -05:00
3ed94d71e0 fix external links (#2649) 2025-03-07 15:11:18 -06:00
e2eb6ef586 Update dependency @types/node to v22.13.9 (#2641)
Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
2025-03-07 14:59:54 -06:00
6836a3f1c7 Update dependency @elastic/request-converter to v8.18.0 (#2642)
Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2025-03-07 20:39:26 +00:00
0eaeb78c96 Fix npm-publish workflow (#2650)
Reverting an accidental revert
2025-03-07 10:30:34 -06:00
c713e599d1 Put version back to correct value (#2648) 2025-03-06 10:43:53 -06:00
204 changed files with 36249 additions and 15671 deletions

View File

@ -12,5 +12,3 @@ WORKDIR /usr/src/app
COPY package.json .
RUN npm install
COPY . .

View File

@ -25,6 +25,3 @@ USER ${BUILDER_UID}:${BUILDER_GID}
# install dependencies
COPY package.json .
RUN npm install
# copy project files
COPY . .

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
/* global $ argv */
@ -123,7 +109,7 @@ async function codegen (args) {
await $`rm -rf ${join(import.meta.url, '..', 'src', 'api')}`
await $`mkdir ${join(import.meta.url, '..', 'src', 'api')}`
await $`cp -R ${join(import.meta.url, '..', '..', 'elastic-client-generator-js', 'output')}/* ${join(import.meta.url, '..', 'src', 'api')}`
await $`mv ${join(import.meta.url, '..', 'src', 'api', 'reference.asciidoc')} ${join(import.meta.url, '..', 'docs', 'reference.asciidoc')}`
await $`mv ${join(import.meta.url, '..', 'src', 'api', 'reference.md')} ${join(import.meta.url, '..', 'docs', 'reference', 'api-reference.md')}`
await $`npm run build`
// run docs example generation

View File

@ -41,7 +41,7 @@ jobs:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
with:
node-version: ${{ matrix.node-version }}
@ -71,7 +71,7 @@ jobs:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
with:
node-version: 22.x
@ -83,6 +83,9 @@ jobs:
run: |
npm run license-checker
- name: SPDX header check
run: npm run license-header
test-bun:
name: Test Bun
runs-on: ${{ matrix.os }}

View File

@ -16,26 +16,45 @@ jobs:
with:
persist-credentials: false
ref: ${{ github.event.inputs.branch }}
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
with:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"
- run: npm install -g npm
- run: npm install
- run: npm test
- run: npm publish --provenance --access public --tag alpha
- name: npm publish
run: |
version=$(jq -r .version package.json)
tag_meta=$(echo "$version" | cut -s -d '-' -f2)
if [[ -z "$tag_meta" ]]; then
npm publish --provenance --access public
else
tag=$(echo "$tag_meta" | cut -d '.' -f1)
npm publish --provenance --access public --tag "$tag"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish version on GitHub
run: |
version=$(jq -r .version package.json)
gh release create \
-n "This is a 9.0.0 pre-release alpha. Changes may not be stable." \
--latest=false \
--prerelease \
--target "$BRANCH_NAME" \
--title "v$version" \
"v$version"
tag_meta=$(echo "$version" | cut -s -d '-' -f2)
if [[ -z "$tag_meta" ]]; then
gh release create \
-n "[Changelog](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/$BRANCH_NAME/changelog-client.html)"
--target "$BRANCH_NAME" \
--title "v$version" \
"v$version"
else
tag_main=$(echo "$version" | cut -d '-' -f1)
gh release create \
-n "This is a $tag_main pre-release. Changes may not be stable." \
--latest=false \
--prerelease \
--target "$BRANCH_NAME" \
--title "v$version" \
"v$version"
fi
env:
BRANCH_NAME: ${{ github.event.inputs.branch }}
GH_TOKEN: ${{ github.token }}

View File

@ -3,17 +3,11 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_query/async",
querystring: {
format: "json",
},
body: {
query:
"\n FROM my-index-000001,cluster_one:my-index-000001,cluster_two:my-index*\n | STATS COUNT(http.response.status_code) BY user.id\n | LIMIT 2\n ",
include_ccs_metadata: true,
},
const response = await client.esql.asyncQuery({
format: "json",
query:
"\n FROM my-index-000001,cluster_one:my-index-000001,cluster_two:my-index*\n | STATS COUNT(http.response.status_code) BY user.id\n | LIMIT 2\n ",
include_ccs_metadata: true,
});
console.log(response);
----

View File

@ -3,23 +3,20 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_application/search_application/my-app/_render_query",
body: {
params: {
query_string: "my first query",
text_fields: [
{
name: "title",
boost: 5,
},
{
name: "description",
boost: 1,
},
],
},
const response = await client.searchApplication.renderQuery({
name: "my-app",
params: {
query_string: "my first query",
text_fields: [
{
name: "title",
boost: 5,
},
{
name: "description",
boost: 1,
},
],
},
});
console.log(response);

View File

@ -3,18 +3,16 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_inference/chat_completion/openai-completion/_stream",
body: {
model: "gpt-4o",
messages: [
{
role: "user",
content: "What is Elastic?",
},
],
},
const response = await client.inference.streamInference({
task_type: "chat_completion",
inference_id: "openai-completion",
model: "gpt-4o",
messages: [
{
role: "user",
content: "What is Elastic?",
},
],
});
console.log(response);
----

View File

@ -0,0 +1,25 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.createFrom({
source: "my-index",
dest: "my-new-index",
create_from: {
settings_override: {
index: {
number_of_shards: 5,
},
},
mappings_override: {
properties: {
field2: {
type: "boolean",
},
},
},
},
});
console.log(response);
----

View File

@ -0,0 +1,10 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.cancelMigrateReindex({
index: "my-data-stream",
});
console.log(response);
----

View File

@ -0,0 +1,12 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.security.delegatePki({
x509_certificate_chain: [
"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==",
],
});
console.log(response);
----

View File

@ -3,27 +3,23 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_ingest/_simulate",
body: {
docs: [
{
_index: "my-index",
_id: "123",
_source: {
foo: "bar",
},
const response = await client.simulate.ingest({
docs: [
{
_index: "my-index",
_id: "123",
_source: {
foo: "bar",
},
{
_index: "my-index",
_id: "456",
_source: {
foo: "rab",
},
},
{
_index: "my-index",
_id: "456",
_source: {
foo: "rab",
},
],
},
},
],
});
console.log(response);
----

View File

@ -0,0 +1,15 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.migrateReindex({
reindex: {
source: {
index: "my-data-stream",
},
mode: "upgrade",
},
});
console.log(response);
----

View File

@ -3,14 +3,10 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_security/oidc/logout",
body: {
token:
"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==",
refresh_token: "vLBPvmAB6KvwvJZr27cS",
},
const response = await client.security.oidcLogout({
token:
"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==",
refresh_token: "vLBPvmAB6KvwvJZr27cS",
});
console.log(response);
----

View File

@ -3,12 +3,9 @@
[source, js]
----
const response = await client.transport.request({
method: "GET",
path: "/_query/async/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE&#x3D;",
querystring: {
wait_for_completion_timeout: "30s",
},
const response = await client.esql.asyncQueryGet({
id: "FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=",
wait_for_completion_timeout: "30s",
});
console.log(response);
----

View File

@ -0,0 +1,22 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.createFrom({
source: "my-index",
dest: "my-new-index",
create_from: {
settings_override: {
index: {
"blocks.write": null,
"blocks.read": null,
"blocks.read_only": null,
"blocks.read_only_allow_delete": null,
"blocks.metadata": null,
},
},
},
});
console.log(response);
----

View File

@ -0,0 +1,21 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.create({
index: "semantic-embeddings",
mappings: {
properties: {
semantic_text: {
type: "semantic_text",
},
content: {
type: "text",
copy_to: "semantic_text",
},
},
},
});
console.log(response);
----

View File

@ -3,14 +3,10 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_query/async",
body: {
query:
"\n FROM library\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\n | STATS MAX(page_count) BY year\n | SORT year\n | LIMIT 5\n ",
wait_for_completion_timeout: "2s",
},
const response = await client.esql.asyncQuery({
query:
"\n FROM library\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\n | STATS MAX(page_count) BY year\n | SORT year\n | LIMIT 5\n ",
wait_for_completion_timeout: "2s",
});
console.log(response);
----

View File

@ -3,9 +3,8 @@
[source, js]
----
const response = await client.transport.request({
method: "GET",
path: "/_query/async/FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM&#x3D;",
const response = await client.esql.asyncQueryGet({
id: "FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=",
});
console.log(response);
----

View File

@ -3,43 +3,41 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_inference/chat_completion/openai-completion/_stream",
body: {
messages: [
{
role: "user",
content: [
{
type: "text",
text: "What's the price of a scarf?",
},
],
},
],
tools: [
{
type: "function",
function: {
name: "get_current_price",
description: "Get the current price of a item",
parameters: {
type: "object",
properties: {
item: {
id: "123",
},
const response = await client.inference.streamInference({
task_type: "chat_completion",
inference_id: "openai-completion",
messages: [
{
role: "user",
content: [
{
type: "text",
text: "What's the price of a scarf?",
},
],
},
],
tools: [
{
type: "function",
function: {
name: "get_current_price",
description: "Get the current price of a item",
parameters: {
type: "object",
properties: {
item: {
id: "123",
},
},
},
},
],
tool_choice: {
type: "function",
function: {
name: "get_current_price",
},
},
],
tool_choice: {
type: "function",
function: {
name: "get_current_price",
},
},
});

View File

@ -0,0 +1,10 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.getMigrateReindexStatus({
index: "my-data-stream",
});
console.log(response);
----

View File

@ -6,6 +6,11 @@
const response = await client.ml.startTrainedModelDeployment({
model_id: "my_model",
deployment_id: "my_model_for_search",
adaptive_allocations: {
enabled: true,
min_number_of_allocations: 3,
max_number_of_allocations: 10,
},
});
console.log(response);
----

View File

@ -3,12 +3,10 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_inference/completion/openai-completion/_stream",
body: {
input: "What is Elastic?",
},
const response = await client.inference.streamInference({
task_type: "completion",
inference_id: "openai-completion",
input: "What is Elastic?",
});
console.log(response);
----

View File

@ -3,14 +3,10 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_security/oidc/prepare",
body: {
realm: "oidc1",
state: "lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO",
nonce: "zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5",
},
const response = await client.security.oidcPrepareAuthentication({
realm: "oidc1",
state: "lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO",
nonce: "zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5",
});
console.log(response);
----

View File

@ -3,17 +3,11 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_query/async",
querystring: {
format: "json",
},
body: {
query:
"\n FROM cluster_one:my-index*,cluster_two:logs*\n | STATS COUNT(http.response.status_code) BY user.id\n | LIMIT 2\n ",
include_ccs_metadata: true,
},
const response = await client.esql.asyncQuery({
format: "json",
query:
"\n FROM cluster_one:my-index*,cluster_two:logs*\n | STATS COUNT(http.response.status_code) BY user.id\n | LIMIT 2\n ",
include_ccs_metadata: true,
});
console.log(response);
----

View File

@ -0,0 +1,11 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.getDataLifecycleStats({
human: "true",
pretty: "true",
});
console.log(response);
----

View File

@ -0,0 +1,12 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.createFrom({
source: "my-index",
dest: "my-new-index",
create_from: null,
});
console.log(response);
----

View File

@ -0,0 +1,10 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.esql.asyncQueryDelete({
id: "FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=",
});
console.log(response);
----

View File

@ -3,12 +3,8 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_security/api_key/_bulk_update",
body: {
ids: ["VuaCfGcBCdbkQm-e5aOx", "H3_AhoIBA9hmeQJdg7ij"],
},
const response = await client.security.bulkUpdateApiKeys({
ids: ["VuaCfGcBCdbkQm-e5aOx", "H3_AhoIBA9hmeQJdg7ij"],
});
console.log(response);
----

View File

@ -3,35 +3,31 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_text_structure/find_message_structure",
body: {
messages: [
"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128",
"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]",
"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]",
"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]",
"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]",
"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]",
"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]",
"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]",
"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]",
"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled",
"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled",
"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled",
"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]",
"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]",
"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized",
"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...",
],
},
const response = await client.textStructure.findMessageStructure({
messages: [
"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128",
"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]",
"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]",
"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]",
"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]",
"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]",
"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]",
"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]",
"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]",
"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]",
"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled",
"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled",
"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled",
"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]",
"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]",
"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized",
"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...",
],
});
console.log(response);
----

View File

@ -3,9 +3,8 @@
[source, js]
----
const response = await client.transport.request({
method: "DELETE",
path: "/_ingest/ip_location/database/my-database-id",
const response = await client.ingest.deleteIpLocationDatabase({
id: "my-database-id",
});
console.log(response);
----

View File

@ -3,30 +3,26 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_security/api_key/_bulk_update",
body: {
ids: ["VuaCfGcBCdbkQm-e5aOx", "H3_AhoIBA9hmeQJdg7ij"],
role_descriptors: {
"role-a": {
indices: [
{
names: ["*"],
privileges: ["write"],
},
],
},
const response = await client.security.bulkUpdateApiKeys({
ids: ["VuaCfGcBCdbkQm-e5aOx", "H3_AhoIBA9hmeQJdg7ij"],
role_descriptors: {
"role-a": {
indices: [
{
names: ["*"],
privileges: ["write"],
},
],
},
metadata: {
environment: {
level: 2,
trusted: true,
tags: ["production"],
},
},
expiration: "30d",
},
metadata: {
environment: {
level: 2,
trusted: true,
tags: ["production"],
},
},
expiration: "30d",
});
console.log(response);
----

View File

@ -3,32 +3,30 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_inference/chat_completion/openai-completion/_stream",
body: {
messages: [
{
role: "assistant",
content: "Let's find out what the weather is",
tool_calls: [
{
id: "call_KcAjWtAww20AihPHphUh46Gd",
type: "function",
function: {
name: "get_current_weather",
arguments: '{"location":"Boston, MA"}',
},
const response = await client.inference.streamInference({
task_type: "chat_completion",
inference_id: "openai-completion",
messages: [
{
role: "assistant",
content: "Let's find out what the weather is",
tool_calls: [
{
id: "call_KcAjWtAww20AihPHphUh46Gd",
type: "function",
function: {
name: "get_current_weather",
arguments: '{"location":"Boston, MA"}',
},
],
},
{
role: "tool",
content: "The weather is cold",
tool_call_id: "call_KcAjWtAww20AihPHphUh46Gd",
},
],
},
},
],
},
{
role: "tool",
content: "The weather is cold",
tool_call_id: "call_KcAjWtAww20AihPHphUh46Gd",
},
],
});
console.log(response);
----

View File

@ -3,10 +3,9 @@
[source, js]
----
const response = await client.transport.request({
method: "PUT",
path: "/_ingest/ip_location/database/my-database-1",
body: {
const response = await client.ingest.putIpLocationDatabase({
id: "my-database-1",
configuration: {
name: "GeoIP2-Domain",
maxmind: {
account_id: "1234567",

View File

@ -0,0 +1,8 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.resolveCluster();
console.log(response);
----

View File

@ -3,9 +3,8 @@
[source, js]
----
const response = await client.transport.request({
method: "DELETE",
path: "/_ingest/ip_location/database/example-database-id",
const response = await client.ingest.deleteIpLocationDatabase({
id: "example-database-id",
});
console.log(response);
----

View File

@ -3,10 +3,10 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_application/analytics/my_analytics_collection/event/search_click",
body: {
const response = await client.searchApplication.postBehavioralAnalyticsEvent({
collection_name: "my_analytics_collection",
event_type: "search_click",
payload: {
session: {
id: "1797ca95-91c9-4e2e-b1bd-9c38e6f386a9",
},

View File

@ -3,16 +3,12 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_security/oidc/authenticate",
body: {
redirect_uri:
"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I",
state: "4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I",
nonce: "WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM",
realm: "oidc1",
},
const response = await client.security.oidcAuthenticate({
redirect_uri:
"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I",
state: "4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I",
nonce: "WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM",
realm: "oidc1",
});
console.log(response);
----

View File

@ -3,13 +3,10 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_application/search_application/my_search_application/_render_query",
body: {
params: {
query_string: "rock climbing",
},
const response = await client.searchApplication.renderQuery({
name: "my_search_application",
params: {
query_string: "rock climbing",
},
});
console.log(response);

View File

@ -0,0 +1,10 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.cancelMigrateReindex({
index: "my-data-stream",
});
console.log(response);
----

View File

@ -0,0 +1,10 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.getMigrateReindexStatus({
index: "my-data-stream",
});
console.log(response);
----

View File

@ -3,9 +3,8 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_application/search_application/my_search_application/_render_query",
const response = await client.searchApplication.renderQuery({
name: "my_search_application",
});
console.log(response);
----

View File

@ -0,0 +1,10 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.esql.asyncQueryStop({
id: "FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=",
});
console.log(response);
----

View File

@ -208,13 +208,9 @@ const response = await client.bulk({
});
console.log(response);
const response1 = await client.transport.request({
method: "GET",
path: "/_text_structure/find_field_structure",
querystring: {
index: "test-logs",
field: "message",
},
const response1 = await client.textStructure.findFieldStructure({
index: "test-logs",
field: "message",
});
console.log(response1);
----

View File

@ -3,36 +3,32 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_ingest/_simulate",
body: {
docs: [
{
_index: "my-index",
_id: "123",
_source: {
foo: "bar",
},
const response = await client.simulate.ingest({
docs: [
{
_index: "my-index",
_id: "123",
_source: {
foo: "bar",
},
{
_index: "my-index",
_id: "456",
_source: {
foo: "rab",
},
},
{
_index: "my-index",
_id: "456",
_source: {
foo: "rab",
},
],
pipeline_substitutions: {
"my-pipeline": {
processors: [
{
uppercase: {
field: "foo",
},
},
],
pipeline_substitutions: {
"my-pipeline": {
processors: [
{
uppercase: {
field: "foo",
},
],
},
},
],
},
},
});

View File

@ -3,13 +3,9 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_security/api_key/_bulk_update",
body: {
ids: ["VuaCfGcBCdbkQm-e5aOx", "H3_AhoIBA9hmeQJdg7ij"],
role_descriptors: {},
},
const response = await client.security.bulkUpdateApiKeys({
ids: ["VuaCfGcBCdbkQm-e5aOx", "H3_AhoIBA9hmeQJdg7ij"],
role_descriptors: {},
});
console.log(response);
----

View File

@ -3,69 +3,65 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_ingest/_simulate",
body: {
docs: [
{
_index: "my-index",
_id: "id",
_source: {
foo: "bar",
},
},
{
_index: "my-index",
_id: "id",
_source: {
foo: "rab",
},
},
],
pipeline_substitutions: {
"my-pipeline": {
processors: [
{
set: {
field: "field3",
value: "value3",
},
},
],
const response = await client.simulate.ingest({
docs: [
{
_index: "my-index",
_id: "id",
_source: {
foo: "bar",
},
},
component_template_substitutions: {
"my-component-template": {
template: {
mappings: {
dynamic: "true",
properties: {
field3: {
type: "keyword",
},
{
_index: "my-index",
_id: "id",
_source: {
foo: "rab",
},
},
],
pipeline_substitutions: {
"my-pipeline": {
processors: [
{
set: {
field: "field3",
value: "value3",
},
},
],
},
},
component_template_substitutions: {
"my-component-template": {
template: {
mappings: {
dynamic: "true",
properties: {
field3: {
type: "keyword",
},
},
settings: {
index: {
default_pipeline: "my-pipeline",
},
},
settings: {
index: {
default_pipeline: "my-pipeline",
},
},
},
},
index_template_substitutions: {
"my-index-template": {
index_patterns: ["my-index-*"],
composed_of: ["component_template_1", "component_template_2"],
},
},
index_template_substitutions: {
"my-index-template": {
index_patterns: ["my-index-*"],
composed_of: ["component_template_1", "component_template_2"],
},
mapping_addition: {
dynamic: "strict",
properties: {
foo: {
type: "keyword",
},
},
mapping_addition: {
dynamic: "strict",
properties: {
foo: {
type: "keyword",
},
},
},

View File

@ -3,13 +3,9 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_security/oidc/prepare",
body: {
iss: "http://127.0.0.1:8080",
login_hint: "this_is_an_opaque_string",
},
const response = await client.security.oidcPrepareAuthentication({
iss: "http://127.0.0.1:8080",
login_hint: "this_is_an_opaque_string",
});
console.log(response);
----

View File

@ -3,10 +3,9 @@
[source, js]
----
const response = await client.transport.request({
method: "PUT",
path: "/_ingest/ip_location/database/my-database-2",
body: {
const response = await client.ingest.putIpLocationDatabase({
id: "my-database-2",
configuration: {
name: "standard_location",
ipinfo: {},
},

View File

@ -3,9 +3,8 @@
[source, js]
----
const response = await client.transport.request({
method: "GET",
path: "/_ingest/ip_location/database/my-database-id",
const response = await client.ingest.getIpLocationDatabase({
id: "my-database-id",
});
console.log(response);
----

View File

@ -3,9 +3,6 @@
[source, js]
----
const response = await client.transport.request({
method: "GET",
path: "/_security/settings",
});
const response = await client.security.getSettings();
console.log(response);
----

View File

@ -0,0 +1,14 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.createFrom({
source: "my-index",
dest: "my-new-index",
create_from: {
remove_index_blocks: false,
},
});
console.log(response);
----

View File

@ -3,12 +3,8 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_security/oidc/prepare",
body: {
realm: "oidc1",
},
const response = await client.security.oidcPrepareAuthentication({
realm: "oidc1",
});
console.log(response);
----

View File

@ -3,38 +3,34 @@
[source, js]
----
const response = await client.transport.request({
method: "POST",
path: "/_ingest/_simulate",
body: {
docs: [
{
_index: "my-index",
_id: "123",
_source: {
foo: "foo",
},
const response = await client.simulate.ingest({
docs: [
{
_index: "my-index",
_id: "123",
_source: {
foo: "foo",
},
{
_index: "my-index",
_id: "456",
_source: {
bar: "rab",
},
},
{
_index: "my-index",
_id: "456",
_source: {
bar: "rab",
},
],
component_template_substitutions: {
"my-mappings_template": {
template: {
mappings: {
dynamic: "strict",
properties: {
foo: {
type: "keyword",
},
bar: {
type: "keyword",
},
},
],
component_template_substitutions: {
"my-mappings_template": {
template: {
mappings: {
dynamic: "strict",
properties: {
foo: {
type: "keyword",
},
bar: {
type: "keyword",
},
},
},

View File

@ -0,0 +1,12 @@
// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
[source, js]
----
const response = await client.indices.createFrom({
source: ".ml-anomalies-custom-example",
dest: ".reindexed-v9-ml-anomalies-custom-example",
create_from: null,
});
console.log(response);
----

View File

@ -8,482 +8,5 @@ toc:
- toc: reference
- toc: release-notes
subs:
ref: "https://www.elastic.co/guide/en/elasticsearch/reference/current"
ref-bare: "https://www.elastic.co/guide/en/elasticsearch/reference"
ref-8x: "https://www.elastic.co/guide/en/elasticsearch/reference/8.1"
ref-80: "https://www.elastic.co/guide/en/elasticsearch/reference/8.0"
ref-7x: "https://www.elastic.co/guide/en/elasticsearch/reference/7.17"
ref-70: "https://www.elastic.co/guide/en/elasticsearch/reference/7.0"
ref-60: "https://www.elastic.co/guide/en/elasticsearch/reference/6.0"
ref-64: "https://www.elastic.co/guide/en/elasticsearch/reference/6.4"
xpack-ref: "https://www.elastic.co/guide/en/x-pack/6.2"
logstash-ref: "https://www.elastic.co/guide/en/logstash/current"
kibana-ref: "https://www.elastic.co/guide/en/kibana/current"
kibana-ref-all: "https://www.elastic.co/guide/en/kibana"
beats-ref-root: "https://www.elastic.co/guide/en/beats"
beats-ref: "https://www.elastic.co/guide/en/beats/libbeat/current"
beats-ref-60: "https://www.elastic.co/guide/en/beats/libbeat/6.0"
beats-ref-63: "https://www.elastic.co/guide/en/beats/libbeat/6.3"
beats-devguide: "https://www.elastic.co/guide/en/beats/devguide/current"
auditbeat-ref: "https://www.elastic.co/guide/en/beats/auditbeat/current"
packetbeat-ref: "https://www.elastic.co/guide/en/beats/packetbeat/current"
metricbeat-ref: "https://www.elastic.co/guide/en/beats/metricbeat/current"
filebeat-ref: "https://www.elastic.co/guide/en/beats/filebeat/current"
functionbeat-ref: "https://www.elastic.co/guide/en/beats/functionbeat/current"
winlogbeat-ref: "https://www.elastic.co/guide/en/beats/winlogbeat/current"
heartbeat-ref: "https://www.elastic.co/guide/en/beats/heartbeat/current"
journalbeat-ref: "https://www.elastic.co/guide/en/beats/journalbeat/current"
ingest-guide: "https://www.elastic.co/guide/en/ingest/current"
fleet-guide: "https://www.elastic.co/guide/en/fleet/current"
apm-guide-ref: "https://www.elastic.co/guide/en/apm/guide/current"
apm-guide-7x: "https://www.elastic.co/guide/en/apm/guide/7.17"
apm-app-ref: "https://www.elastic.co/guide/en/kibana/current"
apm-agents-ref: "https://www.elastic.co/guide/en/apm/agent"
apm-android-ref: "https://www.elastic.co/guide/en/apm/agent/android/current"
apm-py-ref: "https://www.elastic.co/guide/en/apm/agent/python/current"
apm-py-ref-3x: "https://www.elastic.co/guide/en/apm/agent/python/3.x"
apm-node-ref-index: "https://www.elastic.co/guide/en/apm/agent/nodejs"
apm-node-ref: "https://www.elastic.co/guide/en/apm/agent/nodejs/current"
apm-node-ref-1x: "https://www.elastic.co/guide/en/apm/agent/nodejs/1.x"
apm-rum-ref: "https://www.elastic.co/guide/en/apm/agent/rum-js/current"
apm-ruby-ref: "https://www.elastic.co/guide/en/apm/agent/ruby/current"
apm-java-ref: "https://www.elastic.co/guide/en/apm/agent/java/current"
apm-go-ref: "https://www.elastic.co/guide/en/apm/agent/go/current"
apm-dotnet-ref: "https://www.elastic.co/guide/en/apm/agent/dotnet/current"
apm-php-ref: "https://www.elastic.co/guide/en/apm/agent/php/current"
apm-ios-ref: "https://www.elastic.co/guide/en/apm/agent/swift/current"
apm-lambda-ref: "https://www.elastic.co/guide/en/apm/lambda/current"
apm-attacher-ref: "https://www.elastic.co/guide/en/apm/attacher/current"
docker-logging-ref: "https://www.elastic.co/guide/en/beats/loggingplugin/current"
esf-ref: "https://www.elastic.co/guide/en/esf/current"
kinesis-firehose-ref: "https://www.elastic.co/guide/en/kinesis/{{kinesis_version}}"
estc-welcome-current: "https://www.elastic.co/guide/en/starting-with-the-elasticsearch-platform-and-its-solutions/current"
estc-welcome: "https://www.elastic.co/guide/en/starting-with-the-elasticsearch-platform-and-its-solutions/current"
estc-welcome-all: "https://www.elastic.co/guide/en/starting-with-the-elasticsearch-platform-and-its-solutions"
hadoop-ref: "https://www.elastic.co/guide/en/elasticsearch/hadoop/current"
stack-ref: "https://www.elastic.co/guide/en/elastic-stack/current"
stack-ref-67: "https://www.elastic.co/guide/en/elastic-stack/6.7"
stack-ref-68: "https://www.elastic.co/guide/en/elastic-stack/6.8"
stack-ref-70: "https://www.elastic.co/guide/en/elastic-stack/7.0"
stack-ref-80: "https://www.elastic.co/guide/en/elastic-stack/8.0"
stack-ov: "https://www.elastic.co/guide/en/elastic-stack-overview/current"
stack-gs: "https://www.elastic.co/guide/en/elastic-stack-get-started/current"
stack-gs-current: "https://www.elastic.co/guide/en/elastic-stack-get-started/current"
javaclient: "https://www.elastic.co/guide/en/elasticsearch/client/java-api/current"
java-api-client: "https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current"
java-rest: "https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current"
jsclient: "https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current"
jsclient-current: "https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current"
es-ruby-client: "https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current"
es-dotnet-client: "https://www.elastic.co/guide/en/elasticsearch/client/net-api/current"
es-php-client: "https://www.elastic.co/guide/en/elasticsearch/client/php-api/current"
es-python-client: "https://www.elastic.co/guide/en/elasticsearch/client/python-api/current"
defguide: "https://www.elastic.co/guide/en/elasticsearch/guide/2.x"
painless: "https://www.elastic.co/guide/en/elasticsearch/painless/current"
plugins: "https://www.elastic.co/guide/en/elasticsearch/plugins/current"
plugins-8x: "https://www.elastic.co/guide/en/elasticsearch/plugins/8.1"
plugins-7x: "https://www.elastic.co/guide/en/elasticsearch/plugins/7.17"
plugins-6x: "https://www.elastic.co/guide/en/elasticsearch/plugins/6.8"
glossary: "https://www.elastic.co/guide/en/elastic-stack-glossary/current"
upgrade_guide: "https://www.elastic.co/products/upgrade_guide"
blog-ref: "https://www.elastic.co/blog/"
curator-ref: "https://www.elastic.co/guide/en/elasticsearch/client/curator/current"
curator-ref-current: "https://www.elastic.co/guide/en/elasticsearch/client/curator/current"
metrics-ref: "https://www.elastic.co/guide/en/metrics/current"
metrics-guide: "https://www.elastic.co/guide/en/metrics/guide/current"
logs-ref: "https://www.elastic.co/guide/en/logs/current"
logs-guide: "https://www.elastic.co/guide/en/logs/guide/current"
uptime-guide: "https://www.elastic.co/guide/en/uptime/current"
observability-guide: "https://www.elastic.co/guide/en/observability/current"
observability-guide-all: "https://www.elastic.co/guide/en/observability"
siem-guide: "https://www.elastic.co/guide/en/siem/guide/current"
security-guide: "https://www.elastic.co/guide/en/security/current"
security-guide-all: "https://www.elastic.co/guide/en/security"
endpoint-guide: "https://www.elastic.co/guide/en/endpoint/current"
sql-odbc: "https://www.elastic.co/guide/en/elasticsearch/sql-odbc/current"
ecs-ref: "https://www.elastic.co/guide/en/ecs/current"
ecs-logging-ref: "https://www.elastic.co/guide/en/ecs-logging/overview/current"
ecs-logging-go-logrus-ref: "https://www.elastic.co/guide/en/ecs-logging/go-logrus/current"
ecs-logging-go-zap-ref: "https://www.elastic.co/guide/en/ecs-logging/go-zap/current"
ecs-logging-go-zerolog-ref: "https://www.elastic.co/guide/en/ecs-logging/go-zap/current"
ecs-logging-java-ref: "https://www.elastic.co/guide/en/ecs-logging/java/current"
ecs-logging-dotnet-ref: "https://www.elastic.co/guide/en/ecs-logging/dotnet/current"
ecs-logging-nodejs-ref: "https://www.elastic.co/guide/en/ecs-logging/nodejs/current"
ecs-logging-php-ref: "https://www.elastic.co/guide/en/ecs-logging/php/current"
ecs-logging-python-ref: "https://www.elastic.co/guide/en/ecs-logging/python/current"
ecs-logging-ruby-ref: "https://www.elastic.co/guide/en/ecs-logging/ruby/current"
ml-docs: "https://www.elastic.co/guide/en/machine-learning/current"
eland-docs: "https://www.elastic.co/guide/en/elasticsearch/client/eland/current"
eql-ref: "https://eql.readthedocs.io/en/latest/query-guide"
extendtrial: "https://www.elastic.co/trialextension"
wikipedia: "https://en.wikipedia.org/wiki"
forum: "https://discuss.elastic.co/"
xpack-forum: "https://discuss.elastic.co/c/50-x-pack"
security-forum: "https://discuss.elastic.co/c/x-pack/shield"
watcher-forum: "https://discuss.elastic.co/c/x-pack/watcher"
monitoring-forum: "https://discuss.elastic.co/c/x-pack/marvel"
graph-forum: "https://discuss.elastic.co/c/x-pack/graph"
apm-forum: "https://discuss.elastic.co/c/apm"
enterprise-search-ref: "https://www.elastic.co/guide/en/enterprise-search/current"
app-search-ref: "https://www.elastic.co/guide/en/app-search/current"
workplace-search-ref: "https://www.elastic.co/guide/en/workplace-search/current"
enterprise-search-node-ref: "https://www.elastic.co/guide/en/enterprise-search-clients/enterprise-search-node/current"
enterprise-search-php-ref: "https://www.elastic.co/guide/en/enterprise-search-clients/php/current"
enterprise-search-python-ref: "https://www.elastic.co/guide/en/enterprise-search-clients/python/current"
enterprise-search-ruby-ref: "https://www.elastic.co/guide/en/enterprise-search-clients/ruby/current"
elastic-maps-service: "https://maps.elastic.co"
integrations-docs: "https://docs.elastic.co/en/integrations"
integrations-devguide: "https://www.elastic.co/guide/en/integrations-developer/current"
time-units: "https://www.elastic.co/guide/en/elasticsearch/reference/current/api-conventions.html#time-units"
byte-units: "https://www.elastic.co/guide/en/elasticsearch/reference/current/api-conventions.html#byte-units"
apm-py-ref-v: "https://www.elastic.co/guide/en/apm/agent/python/current"
apm-node-ref-v: "https://www.elastic.co/guide/en/apm/agent/nodejs/current"
apm-rum-ref-v: "https://www.elastic.co/guide/en/apm/agent/rum-js/current"
apm-ruby-ref-v: "https://www.elastic.co/guide/en/apm/agent/ruby/current"
apm-java-ref-v: "https://www.elastic.co/guide/en/apm/agent/java/current"
apm-go-ref-v: "https://www.elastic.co/guide/en/apm/agent/go/current"
apm-ios-ref-v: "https://www.elastic.co/guide/en/apm/agent/swift/current"
apm-dotnet-ref-v: "https://www.elastic.co/guide/en/apm/agent/dotnet/current"
apm-php-ref-v: "https://www.elastic.co/guide/en/apm/agent/php/current"
ecloud: "Elastic Cloud"
esf: "Elastic Serverless Forwarder"
ess: "Elasticsearch Service"
ece: "Elastic Cloud Enterprise"
eck: "Elastic Cloud on Kubernetes"
serverless-full: "Elastic Cloud Serverless"
serverless-short: "Serverless"
es-serverless: "Elasticsearch Serverless"
es3: "Elasticsearch Serverless"
obs-serverless: "Elastic Observability Serverless"
sec-serverless: "Elastic Security Serverless"
serverless-docs: "https://docs.elastic.co/serverless"
cloud: "https://www.elastic.co/guide/en/cloud/current"
ess-utm-params: "?page=docs&placement=docs-body"
ess-baymax: "?page=docs&placement=docs-body"
ess-trial: "https://cloud.elastic.co/registration?page=docs&placement=docs-body"
ess-product: "https://www.elastic.co/cloud/elasticsearch-service?page=docs&placement=docs-body"
ess-console: "https://cloud.elastic.co?page=docs&placement=docs-body"
ess-console-name: "Elasticsearch Service Console"
ess-deployments: "https://cloud.elastic.co/deployments?page=docs&placement=docs-body"
ece-ref: "https://www.elastic.co/guide/en/cloud-enterprise/current"
eck-ref: "https://www.elastic.co/guide/en/cloud-on-k8s/current"
ess-leadin: "You can run Elasticsearch on your own hardware or use our hosted Elasticsearch Service that is available on AWS, GCP, and Azure. https://cloud.elastic.co/registration{ess-utm-params}[Try the Elasticsearch Service for free]."
ess-leadin-short: "Our hosted Elasticsearch Service is available on AWS, GCP, and Azure, and you can https://cloud.elastic.co/registration{ess-utm-params}[try it for free]."
ess-icon: "image:https://doc-icons.s3.us-east-2.amazonaws.com/logo_cloud.svg[link=\"https://cloud.elastic.co/registration{ess-utm-params}\", title=\"Supported on Elasticsearch Service\"]"
ece-icon: "image:https://doc-icons.s3.us-east-2.amazonaws.com/logo_cloud_ece.svg[link=\"https://cloud.elastic.co/registration{ess-utm-params}\", title=\"Supported on Elastic Cloud Enterprise\"]"
cloud-only: "This feature is designed for indirect use by https://cloud.elastic.co/registration{ess-utm-params}[Elasticsearch Service], https://www.elastic.co/guide/en/cloud-enterprise/{ece-version-link}[Elastic Cloud Enterprise], and https://www.elastic.co/guide/en/cloud-on-k8s/current[Elastic Cloud on Kubernetes]. Direct use is not supported."
ess-setting-change: "image:https://doc-icons.s3.us-east-2.amazonaws.com/logo_cloud.svg[link=\"{ess-trial}\", title=\"Supported on {ess}\"] indicates a change to a supported https://www.elastic.co/guide/en/cloud/current/ec-add-user-settings.html[user setting] for Elasticsearch Service."
ess-skip-section: "If you use Elasticsearch Service, skip this section. Elasticsearch Service handles these changes for you."
api-cloud: "https://www.elastic.co/docs/api/doc/cloud"
api-ece: "https://www.elastic.co/docs/api/doc/cloud-enterprise"
api-kibana-serverless: "https://www.elastic.co/docs/api/doc/serverless"
es-feature-flag: "This feature is in development and not yet available for use. This documentation is provided for informational purposes only."
es-ref-dir: "'{{elasticsearch-root}}/docs/reference'"
apm-app: "APM app"
uptime-app: "Uptime app"
synthetics-app: "Synthetics app"
logs-app: "Logs app"
metrics-app: "Metrics app"
infrastructure-app: "Infrastructure app"
siem-app: "SIEM app"
security-app: "Elastic Security app"
ml-app: "Machine Learning"
dev-tools-app: "Dev Tools"
ingest-manager-app: "Ingest Manager"
stack-manage-app: "Stack Management"
stack-monitor-app: "Stack Monitoring"
alerts-ui: "Alerts and Actions"
rules-ui: "Rules"
rac-ui: "Rules and Connectors"
connectors-ui: "Connectors"
connectors-feature: "Actions and Connectors"
stack-rules-feature: "Stack Rules"
user-experience: "User Experience"
ems: "Elastic Maps Service"
ems-init: "EMS"
hosted-ems: "Elastic Maps Server"
ipm-app: "Index Pattern Management"
ingest-pipelines: "ingest pipelines"
ingest-pipelines-app: "Ingest Pipelines"
ingest-pipelines-cap: "Ingest pipelines"
ls-pipelines: "Logstash pipelines"
ls-pipelines-app: "Logstash Pipelines"
maint-windows: "maintenance windows"
maint-windows-app: "Maintenance Windows"
maint-windows-cap: "Maintenance windows"
custom-roles-app: "Custom Roles"
data-source: "data view"
data-sources: "data views"
data-source-caps: "Data View"
data-sources-caps: "Data Views"
data-source-cap: "Data view"
data-sources-cap: "Data views"
project-settings: "Project settings"
manage-app: "Management"
index-manage-app: "Index Management"
data-views-app: "Data Views"
rules-app: "Rules"
saved-objects-app: "Saved Objects"
tags-app: "Tags"
api-keys-app: "API keys"
transforms-app: "Transforms"
connectors-app: "Connectors"
files-app: "Files"
reports-app: "Reports"
maps-app: "Maps"
alerts-app: "Alerts"
crawler: "Enterprise Search web crawler"
ents: "Enterprise Search"
app-search-crawler: "App Search web crawler"
agent: "Elastic Agent"
agents: "Elastic Agents"
fleet: "Fleet"
fleet-server: "Fleet Server"
integrations-server: "Integrations Server"
ingest-manager: "Ingest Manager"
ingest-management: "ingest management"
package-manager: "Elastic Package Manager"
integrations: "Integrations"
package-registry: "Elastic Package Registry"
artifact-registry: "Elastic Artifact Registry"
aws: "AWS"
stack: "Elastic Stack"
xpack: "X-Pack"
es: "Elasticsearch"
kib: "Kibana"
esms: "Elastic Stack Monitoring Service"
esms-init: "ESMS"
ls: "Logstash"
beats: "Beats"
auditbeat: "Auditbeat"
filebeat: "Filebeat"
heartbeat: "Heartbeat"
metricbeat: "Metricbeat"
packetbeat: "Packetbeat"
winlogbeat: "Winlogbeat"
functionbeat: "Functionbeat"
journalbeat: "Journalbeat"
es-sql: "Elasticsearch SQL"
esql: "ES|QL"
elastic-agent: "Elastic Agent"
k8s: "Kubernetes"
log-driver-long: "Elastic Logging Plugin for Docker"
security: "X-Pack security"
security-features: "security features"
operator-feature: "operator privileges feature"
es-security-features: "Elasticsearch security features"
stack-security-features: "Elastic Stack security features"
endpoint-sec: "Endpoint Security"
endpoint-cloud-sec: "Endpoint and Cloud Security"
elastic-defend: "Elastic Defend"
elastic-sec: "Elastic Security"
elastic-endpoint: "Elastic Endpoint"
swimlane: "Swimlane"
sn: "ServiceNow"
sn-itsm: "ServiceNow ITSM"
sn-itom: "ServiceNow ITOM"
sn-sir: "ServiceNow SecOps"
jira: "Jira"
ibm-r: "IBM Resilient"
webhook: "Webhook"
webhook-cm: "Webhook - Case Management"
opsgenie: "Opsgenie"
bedrock: "Amazon Bedrock"
gemini: "Google Gemini"
hive: "TheHive"
monitoring: "X-Pack monitoring"
monitor-features: "monitoring features"
stack-monitor-features: "Elastic Stack monitoring features"
watcher: "Watcher"
alert-features: "alerting features"
reporting: "X-Pack reporting"
report-features: "reporting features"
graph: "X-Pack graph"
graph-features: "graph analytics features"
searchprofiler: "Search Profiler"
xpackml: "X-Pack machine learning"
ml: "machine learning"
ml-cap: "Machine learning"
ml-init: "ML"
ml-features: "machine learning features"
stack-ml-features: "Elastic Stack machine learning features"
ccr: "cross-cluster replication"
ccr-cap: "Cross-cluster replication"
ccr-init: "CCR"
ccs: "cross-cluster search"
ccs-cap: "Cross-cluster search"
ccs-init: "CCS"
ilm: "index lifecycle management"
ilm-cap: "Index lifecycle management"
ilm-init: "ILM"
dlm: "data lifecycle management"
dlm-cap: "Data lifecycle management"
dlm-init: "DLM"
search-snap: "searchable snapshot"
search-snaps: "searchable snapshots"
search-snaps-cap: "Searchable snapshots"
slm: "snapshot lifecycle management"
slm-cap: "Snapshot lifecycle management"
slm-init: "SLM"
rollup-features: "data rollup features"
ipm: "index pattern management"
ipm-cap: "Index pattern"
rollup: "rollup"
rollup-cap: "Rollup"
rollups: "rollups"
rollups-cap: "Rollups"
rollup-job: "rollup job"
rollup-jobs: "rollup jobs"
rollup-jobs-cap: "Rollup jobs"
dfeed: "datafeed"
dfeeds: "datafeeds"
dfeed-cap: "Datafeed"
dfeeds-cap: "Datafeeds"
ml-jobs: "machine learning jobs"
ml-jobs-cap: "Machine learning jobs"
anomaly-detect: "anomaly detection"
anomaly-detect-cap: "Anomaly detection"
anomaly-job: "anomaly detection job"
anomaly-jobs: "anomaly detection jobs"
anomaly-jobs-cap: "Anomaly detection jobs"
dataframe: "data frame"
dataframes: "data frames"
dataframe-cap: "Data frame"
dataframes-cap: "Data frames"
watcher-transform: "payload transform"
watcher-transforms: "payload transforms"
watcher-transform-cap: "Payload transform"
watcher-transforms-cap: "Payload transforms"
transform: "transform"
transforms: "transforms"
transform-cap: "Transform"
transforms-cap: "Transforms"
dataframe-transform: "transform"
dataframe-transform-cap: "Transform"
dataframe-transforms: "transforms"
dataframe-transforms-cap: "Transforms"
dfanalytics-cap: "Data frame analytics"
dfanalytics: "data frame analytics"
dataframe-analytics-config: "'{dataframe} analytics config'"
dfanalytics-job: "'{dataframe} analytics job'"
dfanalytics-jobs: "'{dataframe} analytics jobs'"
dfanalytics-jobs-cap: "'{dataframe-cap} analytics jobs'"
cdataframe: "continuous data frame"
cdataframes: "continuous data frames"
cdataframe-cap: "Continuous data frame"
cdataframes-cap: "Continuous data frames"
cdataframe-transform: "continuous transform"
cdataframe-transforms: "continuous transforms"
cdataframe-transforms-cap: "Continuous transforms"
ctransform: "continuous transform"
ctransform-cap: "Continuous transform"
ctransforms: "continuous transforms"
ctransforms-cap: "Continuous transforms"
oldetection: "outlier detection"
oldetection-cap: "Outlier detection"
olscore: "outlier score"
olscores: "outlier scores"
fiscore: "feature influence score"
evaluatedf-api: "evaluate {dataframe} analytics API"
evaluatedf-api-cap: "Evaluate {dataframe} analytics API"
binarysc: "binary soft classification"
binarysc-cap: "Binary soft classification"
regression: "regression"
regression-cap: "Regression"
reganalysis: "regression analysis"
reganalysis-cap: "Regression analysis"
depvar: "dependent variable"
feature-var: "feature variable"
feature-vars: "feature variables"
feature-vars-cap: "Feature variables"
classification: "classification"
classification-cap: "Classification"
classanalysis: "classification analysis"
classanalysis-cap: "Classification analysis"
infer-cap: "Inference"
infer: "inference"
lang-ident-cap: "Language identification"
lang-ident: "language identification"
data-viz: "Data Visualizer"
file-data-viz: "File Data Visualizer"
feat-imp: "feature importance"
feat-imp-cap: "Feature importance"
nlp: "natural language processing"
nlp-cap: "Natural language processing"
apm-agent: "APM agent"
apm-go-agent: "Elastic APM Go agent"
apm-go-agents: "Elastic APM Go agents"
apm-ios-agent: "Elastic APM iOS agent"
apm-ios-agents: "Elastic APM iOS agents"
apm-java-agent: "Elastic APM Java agent"
apm-java-agents: "Elastic APM Java agents"
apm-dotnet-agent: "Elastic APM .NET agent"
apm-dotnet-agents: "Elastic APM .NET agents"
apm-node-agent: "Elastic APM Node.js agent"
apm-node-agents: "Elastic APM Node.js agents"
apm-php-agent: "Elastic APM PHP agent"
apm-php-agents: "Elastic APM PHP agents"
apm-py-agent: "Elastic APM Python agent"
apm-py-agents: "Elastic APM Python agents"
apm-ruby-agent: "Elastic APM Ruby agent"
apm-ruby-agents: "Elastic APM Ruby agents"
apm-rum-agent: "Elastic APM Real User Monitoring (RUM) JavaScript agent"
apm-rum-agents: "Elastic APM RUM JavaScript agents"
apm-lambda-ext: "Elastic APM AWS Lambda extension"
project-monitors: "project monitors"
project-monitors-cap: "Project monitors"
private-location: "Private Location"
private-locations: "Private Locations"
pwd: "YOUR_PASSWORD"
esh: "ES-Hadoop"
default-dist: "default distribution"
oss-dist: "OSS-only distribution"
observability: "Observability"
api-request-title: "Request"
api-prereq-title: "Prerequisites"
api-description-title: "Description"
api-path-parms-title: "Path parameters"
api-query-parms-title: "Query parameters"
api-request-body-title: "Request body"
api-response-codes-title: "Response codes"
api-response-body-title: "Response body"
api-example-title: "Example"
api-examples-title: "Examples"
api-definitions-title: "Properties"
multi-arg: "†footnoteref:[multi-arg,This parameter accepts multiple arguments.]"
multi-arg-ref: "†footnoteref:[multi-arg]"
yes-icon: "image:https://doc-icons.s3.us-east-2.amazonaws.com/icon-yes.png[Yes,20,15]"
no-icon: "image:https://doc-icons.s3.us-east-2.amazonaws.com/icon-no.png[No,20,15]"
es-repo: "https://github.com/elastic/elasticsearch/"
es-issue: "https://github.com/elastic/elasticsearch/issues/"
es-pull: "https://github.com/elastic/elasticsearch/pull/"
es-commit: "https://github.com/elastic/elasticsearch/commit/"
kib-repo: "https://github.com/elastic/kibana/"
kib-issue: "https://github.com/elastic/kibana/issues/"
kibana-issue: "'{kib-repo}issues/'"
kib-pull: "https://github.com/elastic/kibana/pull/"
kibana-pull: "'{kib-repo}pull/'"
kib-commit: "https://github.com/elastic/kibana/commit/"
ml-repo: "https://github.com/elastic/ml-cpp/"
ml-issue: "https://github.com/elastic/ml-cpp/issues/"
ml-pull: "https://github.com/elastic/ml-cpp/pull/"
ml-commit: "https://github.com/elastic/ml-cpp/commit/"
apm-repo: "https://github.com/elastic/apm-server/"
apm-issue: "https://github.com/elastic/apm-server/issues/"
apm-pull: "https://github.com/elastic/apm-server/pull/"
kibana-blob: "https://github.com/elastic/kibana/blob/current/"
apm-get-started-ref: "https://www.elastic.co/guide/en/apm/get-started/current"
apm-server-ref: "https://www.elastic.co/guide/en/apm/server/current"
apm-server-ref-v: "https://www.elastic.co/guide/en/apm/server/current"
apm-server-ref-m: "https://www.elastic.co/guide/en/apm/server/master"
apm-server-ref-62: "https://www.elastic.co/guide/en/apm/server/6.2"
apm-server-ref-64: "https://www.elastic.co/guide/en/apm/server/6.4"
apm-server-ref-70: "https://www.elastic.co/guide/en/apm/server/7.0"
apm-overview-ref-v: "https://www.elastic.co/guide/en/apm/get-started/current"
apm-overview-ref-70: "https://www.elastic.co/guide/en/apm/get-started/7.0"
apm-overview-ref-m: "https://www.elastic.co/guide/en/apm/get-started/master"
infra-guide: "https://www.elastic.co/guide/en/infrastructure/guide/current"
a-data-source: "a data view"
icon-bug: "pass:[<span class=\"eui-icon icon-bug\"></span>]"
icon-checkInCircleFilled: "pass:[<span class=\"eui-icon icon-checkInCircleFilled\"></span>]"
icon-warningFilled: "pass:[<span class=\"eui-icon icon-warningFilled\"></span>]"

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
// IMPORTANT: this is not a production ready code & purely for demonstration purposes,

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
// IMPORTANT: this is not a production ready code & purely for demonstration purposes,

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
// IMPORTANT: this is not a production ready code & purely for demonstration purposes,

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
// IMPORTANT: this is not a production ready code & purely for demonstration purposes,

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
// IMPORTANT: this is not a production ready code & purely for demonstration purposes,

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
'use strict'

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@ mapped_pages:
# Basic configuration [basic-config]
This page shows you the possible basic configuration options that the clients offers.
This page explains the basic configuration options for the JavaScript client.
```js
const { Client } = require('@elastic/elasticsearch')
@ -18,34 +18,404 @@ const client = new Client({
})
```
| | |
| --- | --- |
| `node` or `nodes` | The Elasticsearch endpoint to use.<br> It can be a single string or an array of strings:<br><br>```js<br>node: 'http://localhost:9200'<br>```<br><br>Or it can be an object (or an array of objects) that represents the node:<br><br>```js<br>node: {<br> url: new URL('http://localhost:9200'),<br> tls: 'tls options',<br> agent: 'http agent options',<br> id: 'custom node id',<br> headers: { 'custom': 'headers' }<br> roles: {<br> master: true,<br> data: true,<br> ingest: true,<br> ml: false<br> }<br>}<br>```<br> |
| `auth` | Your authentication data. You can use both basic authentication and [ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key).<br> See [Authentication](/reference/connecting.md#authentication) for more details.<br> *Default:* `null`<br><br>Basic authentication:<br><br>```js<br>auth: {<br> username: 'elastic',<br> password: 'changeme'<br>}<br>```<br><br>[ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key) authentication:<br><br>```js<br>auth: {<br> apiKey: 'base64EncodedKey'<br>}<br>```<br><br>Bearer authentication, useful for [service account tokens](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-service-token). Be aware that it does not handle automatic token refresh:<br><br>```js<br>auth: {<br> bearer: 'token'<br>}<br>```<br> |
| `maxRetries` | `number` - Max number of retries for each request.<br>*Default:* `3` |
| `requestTimeout` | `number` - Max request timeout in milliseconds for each request.<br>*Default:* No value |
| `pingTimeout` | `number` - Max ping request timeout in milliseconds for each request.<br>*Default:* `3000` |
| `sniffInterval` | `number, boolean` - Perform a sniff operation every `n` milliseconds. Sniffing might not be the best solution for you, take a look [here](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how) to know more.<br>*Default:* `false` |
| `sniffOnStart` | `boolean` - Perform a sniff once the client is started. Sniffing might not be the best solution for you, take a look [here](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how) to know more.<br>*Default:* `false` |
| `sniffEndpoint` | `string` - Endpoint to ping during a sniff.<br>*Default:* `'_nodes/_all/http'` |
| `sniffOnConnectionFault` | `boolean` - Perform a sniff on connection fault. Sniffing might not be the best solution for you, take a look [here](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how) to know more.<br>*Default:* `false` |
| `resurrectStrategy` | `string` - Configure the node resurrection strategy.<br>*Options:* `'ping'`, `'optimistic'`, `'none'`<br>*Default:* `'ping'` |
| `suggestCompression` | `boolean` - Adds `accept-encoding` header to every request.<br>*Default:* `false` |
| `compression` | `string, boolean` - Enables gzip request body compression.<br>*Options:* `'gzip'`, `false`<br>*Default:* `false` |
| `tls` | `http.SecureContextOptions` - tls [configuraton](https://nodejs.org/api/tls.md).<br>*Default:* `null` |
| `proxy` | `string, URL` - If you are using an http(s) proxy, you can put its url here. The client will automatically handle the connection to it.<br> *Default:* `null`<br><br>```js<br>const client = new Client({<br> node: 'http://localhost:9200',<br> proxy: 'http://localhost:8080'<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> proxy: 'http://user:pwd@localhost:8080'<br>})<br>```<br> |
| `agent` | `http.AgentOptions, function` - http agent [options](https://nodejs.org/api/http.md#http_new_agent_options), or a function that returns an actual http agent instance. If you want to disable the http agent use entirely (and disable the `keep-alive` feature), set the agent to `false`.<br> *Default:* `null`<br><br>```js<br>const client = new Client({<br> node: 'http://localhost:9200',<br> agent: { agent: 'options' }<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> // the function takes as parameter the option<br> // object passed to the Connection constructor<br> agent: (opts) => new CustomAgent()<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> // Disable agent and keep-alive<br> agent: false<br>})<br>```<br> |
| `nodeFilter` | `function` - Filters which node not to use for a request.<br> *Default:*<br><br>```js<br>function defaultNodeFilter (node) {<br> // avoid master only nodes<br> if (node.roles.master === true &&<br> node.roles.data === false &&<br> node.roles.ingest === false) {<br> return false<br> }<br> return true<br>}<br>```<br> |
| `nodeSelector` | `function` - custom selection strategy.<br> *Options:* `'round-robin'`, `'random'`, custom function<br> *Default:* `'round-robin'`<br> *Custom function example:*<br><br>```js<br>function nodeSelector (connections) {<br> const index = calculateIndex()<br> return connections[index]<br>}<br>```<br> |
| `generateRequestId` | `function` - function to generate the request id for every request, it takes two parameters, the request parameters and options.<br> By default it generates an incremental integer for every request.<br> *Custom function example:*<br><br>```js<br>function generateRequestId (params, options) {<br> // your id generation logic<br> // must be syncronous<br> return 'id'<br>}<br>```<br> |
| `name` | `string, symbol` - The name to identify the client instance in the events.<br>*Default:* `elasticsearch-js` |
| `opaqueIdPrefix` | `string` - A string that will be use to prefix any `X-Opaque-Id` header.<br>See [`X-Opaque-Id` support](/reference/observability.md#_x_opaque_id_support) for more details.<br>_Default:* `null` |
| `headers` | `object` - A set of custom headers to send in every request.<br>*Default:* `{}` |
| `context` | `object` - A custom object that you can use for observability in your events.It will be merged with the API level context option.<br>*Default:* `null` |
| `enableMetaHeader` | `boolean` - If true, adds an header named `'x-elastic-client-meta'`, containing some minimal telemetry data,such as the client and platform version.<br>*Default:* `true` |
| `cloud` | `object` - Custom configuration for connecting to [Elastic Cloud](https://cloud.elastic.co). See [Authentication](/reference/connecting.md) for more details.<br> *Default:* `null`<br> *Cloud configuration example:*<br><br>```js<br>const client = new Client({<br> cloud: {<br> id: '<cloud-id>'<br> },<br> auth: {<br> username: 'elastic',<br> password: 'changeme'<br> }<br>})<br>```<br> |
| `disablePrototypePoisoningProtection` | `boolean`, `'proto'`, `'constructor'` - The client can protect you against prototype poisoning attacks. Read [this article](https://web.archive.org/web/20200319091159/https://hueniverse.com/square-brackets-are-the-enemy-ff5b9fd8a3e8?gi=184a27ee2a08) to learn more about this security concern. If needed, you can enable prototype poisoning protection entirely (`false`) or one of the two checks (`'proto'` or `'constructor'`). For performance reasons, it is disabled by default. Read the `secure-json-parse` [documentation](https://github.com/fastify/secure-json-parse) to learn more.<br>*Default:* `true` |
| `caFingerprint` | `string` - If configured, verify that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied fingerprint. Only accepts SHA256 digest fingerprints.<br>*Default:* `null` |
| `maxResponseSize` | `number` - When configured, it verifies that the uncompressed response size is lower than the configured number, if its higher it will abort the request. It cannot be higher than buffer.constants.MAX_STRING_LENGTH<br>*Default:* `null` |
| `maxCompressedResponseSize` | `number` - When configured, it verifies that the compressed response size is lower than the configured number, if its higher it will abort the request. It cannot be higher than buffer.constants.MAX_LENGTH<br>*Default:* `null` |
### `node` or `nodes`
The {{es}} endpoint to use. It can be a single string or an array of strings:
```js
node: 'http://localhost:9200'
```
```js
nodes: ['http://localhost:9200', 'http://localhost:9201']
```
Or it can be an object (or an array of objects) that represents the node:
```js
node: {
url: new URL('http://localhost:9200'),
tls: 'tls options',
agent: 'http agent options',
id: 'custom node id',
headers: { 'custom': 'headers' },
roles: {
master: true,
data: true,
ingest: true,
ml: false
}
}
```
---
### `auth`
Default: `null`
Your authentication data. You can use both basic authentication and [ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key).
See [Authentication](/reference/connecting.md#authentication) for more details.
Basic authentication:
```js
auth: {
username: 'elastic',
password: 'changeme'
}
```
[ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key) authentication:
```js
auth: {
apiKey: 'base64EncodedKey'
}
```
Bearer authentication, useful for [service account tokens](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-service-token). Be aware that it does not handle automatic token refresh:
```js
auth: {
bearer: 'token'
}
```
---
### `maxRetries`
Type: `number`<br>
Default: `3`
Max number of retries for each request.
---
### `requestTimeout`
Type: `number`<br>
Default: `No value`
Max request timeout in milliseconds for each request.
---
### `pingTimeout`
Type: `number`<br>
Default: `3000`
Max ping request timeout in milliseconds for each request.
---
### `sniffInterval`
Type: `number, boolean`<br>
Default: `false`
Perform a sniff operation every `n` milliseconds.
:::{tip}
Sniffing might not be the best solution. Before using the various `sniff` options, review this [blog post](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how).
:::
---
### `sniffOnStart`
Type: `boolean`<br>
Default: `false`
Perform a sniff once the client is started. Be sure to review the sniffing best practices [blog post](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how).
---
### `sniffEndpoint`
Type: `string`<br>
Default: `'_nodes/_all/http'`
Endpoint to ping during a sniff. Be sure to review the sniffing best practices [blog post](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how).
---
### `sniffOnConnectionFault`
Type: `boolean`<br>
Default: `false`
Perform a sniff on connection fault. Be sure to review the sniffing best practices [blog post](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how).
---
### `resurrectStrategy`
Type: `string`<br>
Default: `'ping'`
Configure the node resurrection strategy.<br>
Options: `'ping'`, `'optimistic'`, `'none'`
---
### `suggestCompression`
Type: `boolean`<br>
Default: `false`
Adds an `accept-encoding` header to every request.
---
### `compression`
Type: `string, boolean`<br>
Default: `false`
Enables gzip request body compression.<br>
Options: `'gzip'`, `false`
---
### `tls`
Type: `http.SecureContextOptions`<br>
Default: `null`
The [tls configuraton](https://nodejs.org/api/tls.html).
---
### `proxy`
Type: `string, URL`<br>
Default: `null`
If you are using an http(s) proxy, you can put its url here. The client will automatically handle the connection to it.
```js
const client = new Client({
node: 'http://localhost:9200',
proxy: 'http://localhost:8080'
})
const client = new Client({
node: 'http://localhost:9200',
proxy: 'http://user:pwd@localhost:8080'
})
```
---
### `agent`
Type: `http.AgentOptions, function`<br>
Default: `null`
http agent [options](https://nodejs.org/api/http.html#http_new_agent_options), or a function that returns an actual http agent instance. If you want to disable the http agent use entirely (and disable the `keep-alive` feature), set the agent to `false`.
```js
const client = new Client({
node: 'http://localhost:9200',
agent: { agent: 'options' }
})
const client = new Client({
node: 'http://localhost:9200',
// the function takes as parameter the option
// object passed to the Connection constructor
agent: (opts) => new CustomAgent()
})
const client = new Client({
node: 'http://localhost:9200',
// Disable agent and keep-alive
agent: false
})
```
---
### `nodeFilter`
Type: `function`
Filter that indicates whether a node should be used for a request. Default function definition:
```js
function defaultNodeFilter (node) {
// avoid master only nodes
if (node.roles.master === true &&
node.roles.data === false &&
node.roles.ingest === false) {
return false
}
return true
}
```
---
### `nodeSelector`
Type: `function`<br>
Default: `'round-robin'`
Custom selection strategy.<br>
Options: `'round-robin'`, `'random'`, custom function
Custom function example:
```js
function nodeSelector (connections) {
const index = calculateIndex()
return connections[index]
}
```
---
### `generateRequestId`
Type: `function`<br>
function to generate the request id for every request, it takes two parameters, the request parameters and options. By default, it generates an incremental integer for every request.
Custom function example:
```js
function generateRequestId (params, options) {
// your id generation logic
// must be syncronous
return 'id'
}
```
---
### `name`
Type: `string, symbol`<br>
Default: `elasticsearch-js`
The name to identify the client instance in the events.
---
### `opaqueIdPrefix`
Type: `string`<br>
Default: `null`
A string that will be use to prefix any `X-Opaque-Id` header.
See [`X-Opaque-Id` support](/reference/observability.md#_x_opaque_id_support) for more details.
---
### `headers`
Type: `object`<br>
Default: `{}`
A set of custom headers to send in every request.
---
### `context`
Type: `object`<br>
Default: `null`
A custom object that you can use for observability in your events. It will be merged with the API level context option.
---
### `enableMetaHeader`
Type: `boolean`<br>
Default: `true`
If true, adds an header named `'x-elastic-client-meta'`, containing some minimal telemetry data, such as the client and platform version.
---
### `cloud`
Type: `object`<br>
Default: `null`
Custom configuration for connecting to [Elastic Cloud](https://cloud.elastic.co). See [Authentication](/reference/connecting.md) for more details.
Cloud configuration example:
```js
const client = new Client({
cloud: {
id: '<cloud-id>'
},
auth: {
username: 'elastic',
password: 'changeme'
}
})
```
---
### `disablePrototypePoisoningProtection`
Default: `true`
`boolean`, `'proto'`, `'constructor'` - The client can protect you against prototype poisoning attacks. For more information, refer to [Square Brackets are the Enemy](https://web.archive.org/web/20200319091159/https://hueniverse.com/square-brackets-are-the-enemy-ff5b9fd8a3e8?gi=184a27ee2a08). If needed, you can enable prototype poisoning protection entirely (`false`) or one of the two checks (`'proto'` or `'constructor'`). For performance reasons, it is disabled by default. To learn more, refer to the [`secure-json-parse` documentation](https://github.com/fastify/secure-json-parse).
---
### `caFingerprint`
Type: `string`<br>
Default: `null`
If configured, verify that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied fingerprint. Only accepts SHA256 digest fingerprints.
---
### `maxResponseSize`
Type: `number`<br>
Default: `null`
When configured, `maxResponseSize` verifies that the uncompressed response size is lower than the configured number. If its higher, the request will be canceled. The `maxResponseSize` cannot be higher than the value of `buffer.constants.MAX_STRING_LENGTH`.
---
### `maxCompressedResponseSize`
Type: `number`<br>
Default: `null`
When configured, `maxCompressedResponseSize` verifies that the compressed response size is lower than the configured number. If its higher, the request will be canceled. The `maxCompressedResponseSize` cannot be higher than the value of `buffer.constants.MAX_STRING_LENGTH`.
---
### `redaction`
Type: `object`<br>
Default: A configuration that will replace known sources of sensitive data in `Error` metadata
Options for how to redact potentially sensitive data from metadata attached to `Error` objects
::::{note}
[Read about redaction](/reference/advanced-config.md#redaction) for more details
::::
---
### `serverMode`
Type: `string`<br>
Default: `"stack"`
Setting to `"stack"` sets defaults assuming a traditional (non-serverless) {{es}} instance. Setting to `"serverless"` sets defaults to work more seamlessly with [Elastic Cloud Serverless](https://www.elastic.co/guide/en/serverless/current/intro.html), like enabling compression and disabling features that assume the possibility of multiple {{es}} nodes.

View File

@ -11,15 +11,12 @@ The client comes with an handy collection of helpers to give you a more comforta
The client helpers are experimental, and the API may change in the next minor releases. The helpers will not work in any Node.js version lower than 10.
::::
## Bulk helper [bulk-helper]
Added in `v7.7.0`
Running bulk requests can be complex due to the shape of the API, this helper aims to provide a nicer developer experience around the Bulk API.
### Usage [_usage_3]
```js
@ -67,10 +64,8 @@ To create a new instance of the Bulk helper, access it as shown in the example a
| `wait` | How much time to wait before retries in milliseconds.<br> *Default:* 5000.<br><br>```js<br>const b = client.helpers.bulk({<br> wait: 3000<br>})<br>```<br> |
| `refreshOnCompletion` | If `true`, at the end of the bulk operation it runs a refresh on all indices or on the specified indices.<br> *Default:* false.<br><br>```js<br>const b = client.helpers.bulk({<br> refreshOnCompletion: true<br> // or<br> refreshOnCompletion: 'index-name'<br>})<br>```<br> |
### Supported operations [_supported_operations]
#### Index [_index_2]
```js
@ -84,7 +79,6 @@ client.helpers.bulk({
})
```
#### Create [_create_4]
```js
@ -98,7 +92,6 @@ client.helpers.bulk({
})
```
#### Update [_update_3]
```js
@ -116,7 +109,6 @@ client.helpers.bulk({
})
```
#### Delete [_delete_10]
```js
@ -130,7 +122,6 @@ client.helpers.bulk({
})
```
### Abort a bulk operation [_abort_a_bulk_operation]
If needed, you can abort a bulk operation at any time. The bulk helper returns a [thenable](https://promisesaplus.com/), which has an `abort` method.
@ -139,7 +130,6 @@ If needed, you can abort a bulk operation at any time. The bulk helper returns a
The abort method stops the execution of the bulk operation, but if you are using a concurrency higher than one, the operations that are already running will not be stopped.
::::
```js
const { createReadStream } = require('fs')
const split = require('split2')
@ -164,7 +154,6 @@ const b = client.helpers.bulk({
console.log(await b)
```
### Passing custom options to the Bulk API [_passing_custom_options_to_the_bulk_api]
You can pass any option supported by the link: [Bulk API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk) to the helper, and the helper uses those options in conjunction with the Bulk API call.
@ -181,7 +170,6 @@ const result = await client.helpers.bulk({
})
```
### Usage with an async generator [_usage_with_an_async_generator]
```js
@ -214,7 +202,6 @@ const result = await client.helpers.bulk({
console.log(result)
```
### Modifying a document before operation [_modifying_a_document_before_operation]
Added in `v8.8.2`
@ -241,14 +228,12 @@ const result = await client.helpers.bulk({
console.log(result)
```
## Multi search helper [multi-search-helper]
Added in `v7.8.0`
If you send search request at a high rate, this helper might be useful for you. It uses the multi search API under the hood to batch the requests and improve the overall performances of your application. The `result` exposes a `documents` property as well, which allows you to access directly the hits sources.
### Usage [_usage_4]
```js
@ -278,7 +263,6 @@ To create a new instance of the multi search (msearch) helper, you should access
| `retries` | How many times an operation is retried before to resolve the request. An operation is retried only in case of a 429 error.<br> *Default:* Client max retries.<br><br>```js<br>const m = client.helpers.msearch({<br> retries: 3<br>})<br>```<br> |
| `wait` | How much time to wait before retries in milliseconds.<br> *Default:* 5000.<br><br>```js<br>const m = client.helpers.msearch({<br> wait: 3000<br>})<br>```<br> |
### Stopping the msearch helper [_stopping_the_msearch_helper]
If needed, you can stop an msearch processor at any time. The msearch helper returns a [thenable](https://promisesaplus.com/), which has an `stop` method.
@ -291,7 +275,6 @@ The `stop` method accepts an optional error, that will be dispatched every subse
The stop method stops the execution of the msearch processor, but if you are using a concurrency higher than one, the operations that are already running will not be stopped.
::::
```js
const { Client } = require('@elastic/elasticsearch')
@ -318,7 +301,6 @@ m.search(
setImmediate(() => m.stop())
```
## Search helper [search-helper]
Added in `v7.7.0`
@ -340,7 +322,6 @@ for (const doc of documents) {
}
```
## Scroll search helper [scroll-search-helper]
Added in `v7.7.0`
@ -362,7 +343,6 @@ for await (const result of scrollSearch) {
}
```
### Clear a scroll search [_clear_a_scroll_search]
If needed, you can clear a scroll search by calling `result.clear()`:
@ -375,7 +355,6 @@ for await (const result of scrollSearch) {
}
```
### Quickly getting the documents [_quickly_getting_the_documents]
If you only need the documents from the result of a scroll search, you can access them via `result.documents`:
@ -386,7 +365,6 @@ for await (const result of scrollSearch) {
}
```
## Scroll documents helper [scroll-documents-helper]
Added in `v7.7.0`
@ -408,15 +386,12 @@ for await (const doc of scrollSearch) {
}
```
## ES|QL helper [esql-helper]
ES|QL queries can return their results in [several formats](docs-content://explore-analyze/query-filter/languages/esql-rest.md#esql-rest-format). The default JSON format returned by ES|QL queries contains arrays of values for each row, with column names and types returned separately:
### Usage [_usage_5]
#### `toRecords` [_torecords]
Added in `v8.14.0`
@ -494,7 +469,6 @@ const result = await client.helpers
.toRecords<EventLog>()
```
#### `toArrowReader` [_toarrowreader]
Added in `v8.16.0`
@ -516,7 +490,6 @@ for (const recordBatch of reader) {
}
```
#### `toArrowTable` [_toarrowtable]
Added in `v8.16.0`

View File

@ -7,13 +7,8 @@ mapped_pages:
The client is designed to be easily configured for your needs. In the following section, you can see the possible options that you can use to configure it.
* [Basic configuration](/reference/basic-config.md)
* [Advanced configuration](/reference/advanced-config.md)
* [Timeout best practices](docs-content://troubleshoot/elasticsearch/elasticsearch-client-javascript-api/nodejs.md)
* [Creating a child client](/reference/child.md)
* [Testing](/reference/client-testing.md)
- [Basic configuration](/reference/basic-config.md)
- [Advanced configuration](/reference/advanced-config.md)
- [Timeout best practices](docs-content://troubleshoot/elasticsearch/elasticsearch-client-javascript-api/nodejs.md)
- [Creating a child client](/reference/child.md)
- [Testing](/reference/client-testing.md)

View File

@ -11,7 +11,6 @@ This page contains the information you need to connect and use the Client with {
This document contains code snippets to show you how to connect to various {{es}} providers.
### Elastic Cloud [auth-ec]
If you are using [Elastic Cloud](https://www.elastic.co/cloud), the client offers an easy way to connect to it via the `cloud` option. You must pass the Cloud ID that you can find in the cloud console, then your username and password inside the `auth` option.
@ -20,12 +19,10 @@ If you are using [Elastic Cloud](https://www.elastic.co/cloud), the client offer
When connecting to Elastic Cloud, the client will automatically enable both request and response compression by default, since it yields significant throughput improvements. Moreover, the client will also set the tls option `secureProtocol` to `TLSv1_2_method` unless specified otherwise. You can still override this option by configuring them.
::::
::::{important}
Do not enable sniffing when using Elastic Cloud, since the nodes are behind a load balancer, Elastic Cloud will take care of everything for you. Take a look [here](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how) to know more.
::::
```js
const { Client } = require('@elastic/elasticsearch')
const client = new Client({
@ -39,6 +36,24 @@ const client = new Client({
})
```
## Connecting to an Elastic Cloud Serverless instance [connect-serverless]
The Node.js client is built to support connecting to [Elastic Cloud Serverless](https://www.elastic.co/guide/en/serverless/current/intro.html). By setting the `serverMode` option to `"serverless"`, several default options will be modified to better suit the serverless environment.
```js
const { Client } = require('@elastic/elasticsearch')
const client = new Client({
cloud: {
id: '<cloud-id>'
},
auth: {
username: 'elastic',
password: 'changeme'
},
serverMode: 'serverless'
})
```
## Connecting to a self-managed cluster [connect-self-managed-new]
@ -62,7 +77,6 @@ When you start {{es}} for the first time youll see a distinct block like the
Depending on the circumstances there are two options for verifying the HTTPS connection, either verifying with the CA certificate itself or via the HTTP CA certificate fingerprint.
### TLS configuration [auth-tls]
The generated root CA certificate can be found in the `certs` directory in your {{es}} config location (`$ES_CONF_PATH/certs/http_ca.crt`). If youre running {{es}} in Docker there is [additional documentation for retrieving the CA certificate](docs-content://deploy-manage/deploy/self-managed/install-elasticsearch-with-docker.md).
@ -84,7 +98,6 @@ const client = new Client({
})
```
### CA fingerprint [auth-ca-fingerprint]
You can configure the client to only trust certificates that are signed by a specific CA certificate (CA certificate pinning) by providing a `caFingerprint` option. This will verify that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied value. You must configure a SHA256 digest.
@ -125,14 +138,12 @@ The output of `openssl x509` will look something like this:
SHA256 Fingerprint=A5:2D:D9:35:11:E8:C6:04:5E:21:F1:66:54:B7:7C:9E:E0:F3:4A:EA:26:D9:F4:03:20:B5:31:C4:74:67:62:28
```
## Connecting without security enabled [connect-no-security]
::::{warning}
Running {{es}} without security enabled is not recommended.
::::
If your cluster is configured with [security explicitly disabled](elasticsearch://reference/elasticsearch/configuration-reference/security-settings.md) then you can connect via HTTP:
```js
@ -142,12 +153,10 @@ const client = new Client({
})
```
## Authentication strategies [auth-strategies]
Following you can find all the supported authentication strategies.
### ApiKey authentication [auth-apikey]
You can use the [ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key) authentication by passing the `apiKey` parameter via the `auth` option. The `apiKey` parameter can be either a base64 encoded string or an object with the values that you can obtain from the [create api key endpoint](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key).
@ -156,7 +165,6 @@ You can use the [ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/opera
If you provide both basic authentication credentials and the ApiKey configuration, the ApiKey takes precedence.
::::
```js
const { Client } = require('@elastic/elasticsearch')
const client = new Client({
@ -180,7 +188,6 @@ const client = new Client({
})
```
### Bearer authentication [auth-bearer]
You can provide your credentials by passing the `bearer` token parameter via the `auth` option. Useful for [service account tokens](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-service-token). Be aware that it does not handle automatic token refresh.
@ -195,7 +202,6 @@ const client = new Client({
})
```
### Basic authentication [auth-basic]
You can provide your credentials by passing the `username` and `password` parameters via the `auth` option.
@ -204,7 +210,6 @@ You can provide your credentials by passing the `username` and `password` parame
If you provide both basic authentication credentials and the Api Key configuration, the Api Key will take precedence.
::::
```js
const { Client } = require('@elastic/elasticsearch')
const client = new Client({
@ -225,7 +230,6 @@ const client = new Client({
})
```
## Usage [client-usage]
Using the client is straightforward, it supports all the public APIs of {{es}}, and every method exposes the same signature.
@ -278,8 +282,6 @@ In this case, the result will be:
The body is a boolean value when you use `HEAD` APIs.
::::
### Aborting a request [_aborting_a_request]
If needed, you can abort a running request by using the `AbortController` standard.
@ -288,7 +290,6 @@ If needed, you can abort a running request by using the `AbortController` standa
If you abort a request, the request will fail with a `RequestAbortedError`.
::::
```js
const AbortController = require('node-abort-controller')
const { Client } = require('@elastic/elasticsearch')
@ -308,7 +309,6 @@ const result = await client.search({
}, { signal: abortController.signal })
```
### Request specific options [_request_specific_options]
If needed you can pass request specific options in a second object:
@ -352,7 +352,6 @@ The supported request specific options are:
This section illustrates the best practices for leveraging the {{es}} client in a Function-as-a-Service (FaaS) environment. The most influential optimization is to initialize the client outside of the function, the global scope. This practice does not only improve performance but also enables background functionality as for example [sniffing](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how). The following examples provide a skeleton for the best practices.
### GCP Cloud Functions [_gcp_cloud_functions]
```js
@ -369,7 +368,6 @@ exports.testFunction = async function (req, res) {
}
```
### AWS Lambda [_aws_lambda]
```js
@ -386,7 +384,6 @@ exports.handler = async function (event, context) {
}
```
### Azure Functions [_azure_functions]
```js
@ -406,10 +403,9 @@ module.exports = async function (context, req) {
Resources used to assess these recommendations:
* [GCP Cloud Functions: Tips & Tricks](https://cloud.google.com/functions/docs/bestpractices/tips#use_global_variables_to_reuse_objects_in_future_invocations)
* [Best practices for working with AWS Lambda functions](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.md)
* [Best practices for working with AWS Lambda functions](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html)
* [Azure Functions Python developer guide](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=azurecli-linux%2Capplication-level#global-variables)
* [AWS Lambda: Comparing the effect of global scope](https://docs.aws.amazon.com/lambda/latest/operatorguide/global-scope.md)
* [AWS Lambda: Comparing the effect of global scope](https://docs.aws.amazon.com/lambda/latest/operatorguide/global-scope.html)
## Connecting through a proxy [client-connect-proxy]
@ -421,7 +417,6 @@ If you need to pass through an http(s) proxy for connecting to {{es}}, the clien
In versions 8.0+ of the client, the default `Connection` type is set to `UndiciConnection`, which does not support proxy configurations. To use a proxy, you will need to use the `HttpConnection` class from `@elastic/transport` instead.
::::
```js
import { HttpConnection } from '@elastic/transport'
@ -455,7 +450,6 @@ const client = new Client({
})
```
## Error handling [client-error-handling]
The client exposes a variety of error objects that you can use to enhance your error handling. You can find all the error objects inside the `errors` key in the client.
@ -506,7 +500,6 @@ const client = new Client({
})
```
## Closing a clients connections [close-connections]
If you would like to close all open connections being managed by an instance of the client, use the `close()` function:
@ -518,7 +511,6 @@ const client = new Client({
client.close();
```
## Automatic product check [product-check]
Since v7.14.0, the client performs a required product check before the first call. This pre-flight product check allows the client to establish the version of Elasticsearch that it is communicating with. The product check requires one additional HTTP request to be sent to the server as part of the request pipeline before the main API call is sent. In most cases, this will succeed during the very first API call that the client sends. Once the product check completes, no further product check HTTP requests are sent for subsequent API calls.

View File

@ -45,13 +45,13 @@ const client = new Client({
Your Elasticsearch endpoint can be found on the **My deployment** page of your deployment:
:::{image} ../images/es-endpoint.jpg
:::{image} images/es-endpoint.jpg
:alt: Finding Elasticsearch endpoint
:::
You can generate an API key on the **Management** page under Security.
:::{image} ../images/create-api-key.png
:::{image} images/create-api-key.png
:alt: Create API key
:::

View File

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

View File

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

View File

@ -1,14 +1,11 @@
---
navigation_title: "Elasticsearch JavaScript Client"
navigation_title: "Breaking changes"
---
# Elasticsearch JavaScript Client breaking changes [elasticsearch-javascript-client-breaking-changes]
Before you upgrade, carefully review the Elasticsearch JavaScript Client breaking changes and take the necessary steps to mitigate any issues.
To learn how to upgrade, check out <upgrade docs>.
Breaking changes can impact your Elastic applications, potentially disrupting normal operations. Before you upgrade, carefully review the Elasticsearch JavaScript Client breaking changes and take the necessary steps to mitigate any issues. To learn how to upgrade, check [Upgrade](docs-content://deploy-manage/upgrade.md).
% ## Next version [elasticsearch-javascript-client-versionnext-breaking-changes]
% **Release date:** Month day, year
% ::::{dropdown} Title of breaking change
% Description of the breaking change.
@ -18,7 +15,6 @@ To learn how to upgrade, check out <upgrade docs>.
% ::::
% ## 9.0.0 [elasticsearch-javascript-client-900-breaking-changes]
% **Release date:** March 25, 2025
% ::::{dropdown} Title of breaking change
% Description of the breaking change.

View File

@ -1,14 +1,13 @@
---
navigation_title: "Elasticsearch JavaScript Client"
navigation_title: "Deprecations"
---
# Elasticsearch JavaScript Client deprecations [elasticsearch-javascript-client-deprecations]
Review the deprecated functionality for your Elasticsearch JavaScript Client version. While deprecations have no immediate impact, we strongly encourage you update your implementation after you upgrade.
Over time, certain Elastic functionality becomes outdated and is replaced or removed. To help with the transition, Elastic deprecates functionality for a period before removal, giving you time to update your applications.
To learn how to upgrade, check out <uprade docs>.
Review the deprecated functionality for Elasticsearch JavaScript Client. While deprecations have no immediate impact, we strongly encourage you update your implementation after you upgrade. To learn how to upgrade, check out [Upgrade](docs-content://deploy-manage/upgrade.md).
% ## Next version
% **Release date:** Month day, year
% ::::{dropdown} Deprecation title
% Description of the deprecation.
@ -18,7 +17,6 @@ To learn how to upgrade, check out <uprade docs>.
% ::::
% ## 9.0.0 [elasticsearch-javascript-client-900-deprecations]
% **Release date:** March 25, 2025
% ::::{dropdown} Deprecation title
% Description of the deprecation.

View File

@ -1,26 +1,26 @@
---
navigation_title: "Elasticsearch JavaScript Client"
mapped_pages:
- https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/changelog-client.html
---
# Elasticsearch JavaScript Client release notes [elasticsearch-javascript-client-release-notes]
Review the changes, fixes, and more in each version of Elasticsearch JavaScript Client.
Review the changes, fixes, and more in each version of Elasticsearch JavaScript Client.
To check for security updates, go to [Security announcements for the Elastic stack](https://discuss.elastic.co/c/announcements/security-announcements/31).
% Release notes include only features, enhancements, and fixes. Add breaking changes, deprecations, and known issues to the applicable release notes sections.
% Release notes include only features, enhancements, and fixes. Add breaking changes, deprecations, and known issues to the applicable release notes sections.
% ## version.next [elasticsearch-javascript-client-next-release-notes]
% **Release date:** Month day, year
% ### Features and enhancements [elasticsearch-javascript-client-next-features-enhancements]
% *
% *
% ### Fixes [elasticsearch-javascript-client-next-fixes]
% *
% *
## 9.0.0 [elasticsearch-javascript-client-900-release-notes]
**Release date:** March 25, 2025
### Features and enhancements [elasticsearch-javascript-client-900-features-enhancements]

View File

@ -1,5 +1,5 @@
---
navigation_title: "Elasticsearch JavaScript Client"
navigation_title: "Known issues"
---

18
index.d.ts vendored
View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
import Client from './lib/client'

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
'use strict'

View File

@ -1,6 +1,6 @@
{
"name": "@elastic/elasticsearch",
"version": "9.0.0-alpha.3",
"version": "9.0.0-alpha.5",
"versionCanary": "9.0.0-canary.0",
"description": "The official Elasticsearch client for Node.js",
"main": "./index.js",
@ -22,6 +22,7 @@
"lint": "ts-standard src",
"lint:fix": "ts-standard --fix src",
"license-checker": "license-checker --production --onlyAllow='MIT;Apache-2.0;Apache1.1;ISC;BSD-3-Clause;BSD-2-Clause;0BSD'",
"license-header": "./scripts/check-spdx",
"prebuild": "npm run clean-build && npm run lint",
"build": "tsc && rm lib/package.json && mv lib/src/* lib/ && rm -rf lib/src",
"clean-build": "rimraf ./lib && mkdir lib",
@ -56,11 +57,11 @@
"node": ">=18"
},
"devDependencies": {
"@elastic/request-converter": "8.17.0",
"@elastic/request-converter": "9.0.0",
"@sinonjs/fake-timers": "14.0.0",
"@types/debug": "4.1.12",
"@types/ms": "0.7.34",
"@types/node": "22.13.5",
"@types/node": "22.13.14",
"@types/sinonjs__fake-timers": "8.1.5",
"@types/split2": "4.2.3",
"@types/stoppable": "1.1.3",
@ -77,13 +78,13 @@
"ora": "5.4.1",
"proxy": "1.0.2",
"rimraf": "3.0.2",
"semver": "7.6.3",
"semver": "7.7.1",
"split2": "4.2.0",
"stoppable": "1.1.0",
"tap": "21.0.2",
"tap": "21.1.0",
"ts-node": "10.9.2",
"ts-standard": "12.0.2",
"typescript": "5.7.3",
"typescript": "5.8.2",
"workq": "3.0.0",
"xmlbuilder2": "3.1.1",
"zx": "7.2.3"

27
scripts/check-spdx Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Copyright Elasticsearch B.V. and contributors
# SPDX-License-Identifier: Apache-2.0
correct='/*
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/'
the_exit=0
check_file() {
if $(diff <(head -n4 "$1") <(echo "$correct") &>/dev/null); then
echo "Correct: $1"
else
echo "Incorrect: $1"
the_exit=1
fi
}
echo "SPDX license header check"
for file in $(git ls-files | grep -E '\.(ts|js|mjs)$'); do
check_file "$file"
done
exit "$the_exit"

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
'use strict'

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
const { join } = require('path')

View File

@ -1,143 +0,0 @@
/*
* 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'
const { join } = require('path')
const { readdirSync, writeFileSync, readFileSync } = require('fs')
const minimist = require('minimist')
const ora = require('ora')
const rimraf = require('rimraf')
const standard = require('standard')
const downloadArtifacts = require('./download-artifacts')
const {
generate,
genFactory,
generateDocs,
generateRequestTypes
} = require('./utils')
start(minimist(process.argv.slice(2), {
string: ['version', 'hash']
}))
function start (opts) {
if (opts.version == null) {
console.error('Missing version parameter')
process.exit(1)
}
const packageFolder = join(__dirname, '..', 'api')
const apiOutputFolder = join(packageFolder, 'api')
const mainOutputFile = join(packageFolder, 'index.js')
const docOutputFile = join(__dirname, '..', 'docs', 'reference.asciidoc')
const typeDefFile = join(__dirname, '..', 'index.d.ts')
const requestParamsOutputFile = join(packageFolder, 'requestParams.d.ts')
let log
downloadArtifacts({ version: opts.version, hash: opts.hash })
.then(onArtifactsDownloaded)
.catch(err => {
console.log(err)
process.exit(1)
})
function onArtifactsDownloaded () {
log = ora('Generating APIs').start()
log.text = 'Cleaning API folder...'
rimraf.sync(join(apiOutputFolder, '*.js'))
const allSpec = readdirSync(downloadArtifacts.locations.specFolder)
.filter(file => file !== '_common.json')
.filter(file => !file.includes('deprecated'))
.sort()
.map(file => require(join(downloadArtifacts.locations.specFolder, file)))
const namespaces = namespacify(readdirSync(downloadArtifacts.locations.specFolder))
for (const namespace in namespaces) {
if (namespace === '_common') continue
const code = generate(namespace, namespaces[namespace], downloadArtifacts.locations.specFolder, opts.version)
const filePath = join(apiOutputFolder, `${namespace}.js`)
writeFileSync(filePath, code, { encoding: 'utf8' })
}
writeFileSync(
requestParamsOutputFile,
generateRequestTypes(opts.version, allSpec),
{ encoding: 'utf8' }
)
const { fn: factory, types } = genFactory(apiOutputFolder, downloadArtifacts.locations.specFolder, namespaces)
writeFileSync(
mainOutputFile,
factory,
{ encoding: 'utf8' }
)
const oldTypeDefString = readFileSync(typeDefFile, 'utf8')
const start = oldTypeDefString.indexOf('/* GENERATED */')
const end = oldTypeDefString.indexOf('/* /GENERATED */')
const newTypeDefString = oldTypeDefString.slice(0, start + 15) + '\n' + types + '\n ' + oldTypeDefString.slice(end)
writeFileSync(
typeDefFile,
newTypeDefString,
{ encoding: 'utf8' }
)
lintFiles(log, () => {
log.text = 'Generating documentation'
writeFileSync(
docOutputFile,
generateDocs(require(join(downloadArtifacts.locations.specFolder, '_common.json')), allSpec),
{ encoding: 'utf8' }
)
log.succeed('Done!')
})
}
function lintFiles (log, cb) {
log.text = 'Linting...'
const files = [join(packageFolder, '*.js'), join(apiOutputFolder, '*.js')]
standard.lintFiles(files, { fix: true }, err => {
if (err) {
return log.fail(err.message)
}
cb()
})
}
function namespacify (apis) {
return apis
.map(api => api.slice(0, -5))
.filter(api => api !== '_common')
.filter(api => !api.includes('deprecated'))
.reduce((acc, val) => {
if (val.includes('.')) {
val = val.split('.')
acc[val[0]] = acc[val[0]] || []
acc[val[0]].push(val[1])
} else {
acc[val] = []
}
return acc
}, {})
}
}

View File

@ -1,8 +0,0 @@
#!/bin/bash
exec docker run \
--rm \
-e ELASTICSEARCH_URL="http://elasticsearch:9200" \
-p 5601:5601 \
--network=elastic \
docker.elastic.co/kibana/kibana:7.0.0-beta1

View File

@ -1,3 +1,8 @@
/*
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
'use strict'
/**
@ -130,9 +135,9 @@ release(
'dry-run',
// help text
'help',
'help'
],
alias: { help: 'h' },
alias: { help: 'h' }
})
)
.catch(err => {

View File

@ -1,139 +0,0 @@
/*
* 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'
const { accessSync, mkdirSync } = require('fs')
const { join } = require('path')
const Git = require('simple-git')
const esRepo = 'https://github.com/elastic/elasticsearch.git'
const esFolder = join(__dirname, '..', '..', 'elasticsearch')
const apiFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'api')
const xPackFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resources', 'rest-api-spec', 'api')
function cloneAndCheckout (opts, callback) {
const { log, tag, branch } = opts
withTag(tag, callback)
/**
* Sets the elasticsearch repository to the given tag.
* If the repository is not present in `esFolder` it will
* clone the repository and the checkout the tag.
* If the repository is already present but it cannot checkout to
* the given tag, it will perform a pull and then try again.
* @param {string} tag
* @param {function} callback
*/
function withTag (tag, callback) {
let fresh = false
let retry = 0
if (!pathExist(esFolder)) {
if (!createFolder(esFolder)) {
log.fail('Failed folder creation')
return
}
fresh = true
}
const git = Git(esFolder)
if (fresh) {
clone(checkout)
} else if (opts.branch) {
checkout(true)
} else {
checkout()
}
function checkout (alsoPull = false) {
if (branch) {
log.text = `Checking out branch '${branch}'`
} else {
log.text = `Checking out tag '${tag}'`
}
git.checkout(branch || tag, err => {
if (err) {
if (retry++ > 0) {
callback(new Error(`Cannot checkout tag '${tag}'`), { apiFolder, xPackFolder })
return
}
return pull(checkout)
}
if (alsoPull) {
return pull(checkout)
}
callback(null, { apiFolder, xPackFolder })
})
}
function pull (cb) {
log.text = 'Pulling elasticsearch repository...'
git.pull(err => {
if (err) {
callback(err, { apiFolder, xPackFolder })
return
}
cb()
})
}
function clone (cb) {
log.text = 'Cloning elasticsearch repository...'
git.clone(esRepo, esFolder, err => {
if (err) {
callback(err, { apiFolder, xPackFolder })
return
}
cb()
})
}
}
/**
* Checks if the given path exists
* @param {string} path
* @returns {boolean} true if exists, false if not
*/
function pathExist (path) {
try {
accessSync(path)
return true
} catch (err) {
return false
}
}
/**
* Creates the given folder
* @param {string} name
* @returns {boolean} true on success, false on failure
*/
function createFolder (name) {
try {
mkdirSync(name)
return true
} catch (err) {
return false
}
}
}
module.exports = cloneAndCheckout

View File

@ -1,553 +0,0 @@
/*
* 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.
*/
/* eslint camelcase: 0 */
'use strict'
const { join } = require('path')
const dedent = require('dedent')
const allowedMethods = {
noBody: ['GET', 'HEAD', 'DELETE'],
body: ['POST', 'PUT', 'DELETE']
}
// if a parameter is depracted in a minor release
// we should be able to support it until the next major
const deprecatedParameters = require('./patch.json')
// list of apis that does not need any kind of validation
// because of how the url is built or the `type` handling in ES7
const noPathValidation = [
'create',
'exists',
'explain',
'get',
'get_source',
'index',
'indices.get_alias',
'indices.exists_alias',
'indices.get_field_mapping',
'indices.get_mapping',
'indices.get_settings',
'indices.put_mapping',
'indices.stats',
'delete',
'nodes.info',
'nodes.stats',
'nodes.usage',
'tasks.cancel',
'termvectors',
'update'
]
function generateNamespace (namespace, nested, specFolder, version) {
const common = require(join(specFolder, '_common.json'))
let code = dedent`
/*
* 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 */
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
`
if (nested.length > 0) {
let getters = ''
for (const n of nested) {
if (n.includes('_')) {
const nameSnaked = n
.replace(/\.([a-z])/g, k => k[1].toUpperCase())
.replace(/_([a-z])/g, k => k[1].toUpperCase())
getters += `${n}: { get () { return this.${nameSnaked} } },\n`
}
}
const api = generateMultiApi(version, namespace, nested, common, specFolder)
if (getters.length > 0) {
getters = `Object.defineProperties(${api.namespace}Api.prototype, {\n${getters}})`
}
code += `
const acceptedQuerystring = ${JSON.stringify(api.acceptedQuerystring)}
const snakeCase = ${JSON.stringify(api.snakeCase)}
function ${api.namespace}Api (transport, ConfigurationError) {
this.transport = transport
this[kConfigurationError] = ConfigurationError
}
${api.code}
${getters}
module.exports = ${api.namespace}Api
`
} else {
const spec = require(join(specFolder, `${namespace}.json`))
const api = generateSingleApi(version, spec, common)
code += `
const acceptedQuerystring = ${JSON.stringify(api.acceptedQuerystring)}
const snakeCase = ${JSON.stringify(api.snakeCase)}
${api.code}
module.exports = ${api.name}Api
`
}
return code
}
function generateMultiApi (version, namespace, nested, common, specFolder) {
const namespaceSnaked = namespace
.replace(/\.([a-z])/g, k => k[1].toUpperCase())
.replace(/_([a-z])/g, k => k[1].toUpperCase())
let code = ''
const snakeCase = {}
const acceptedQuerystring = []
for (const n of nested) {
const nameSnaked = n
.replace(/\.([a-z])/g, k => k[1].toUpperCase())
.replace(/_([a-z])/g, k => k[1].toUpperCase())
const spec = require(join(specFolder, `${namespace}.${n}.json`))
const api = generateSingleApi(version, spec, common)
code += `${Uppercase(namespaceSnaked)}Api.prototype.${nameSnaked} = ${api.code}\n\n`
Object.assign(snakeCase, api.snakeCase)
for (const q of api.acceptedQuerystring) {
if (!acceptedQuerystring.includes(q)) {
acceptedQuerystring.push(q)
}
}
}
return { code, snakeCase, acceptedQuerystring, namespace: Uppercase(namespaceSnaked) }
}
function generateSingleApi (version, spec, common) {
const release = version.charAt(0)
const api = Object.keys(spec)[0]
const name = api
.replace(/\.([a-z])/g, k => k[1].toUpperCase())
.replace(/_([a-z])/g, k => k[1].toUpperCase())
const { paths } = spec[api].url
const { params } = spec[api]
const acceptedQuerystring = []
const required = []
const methods = paths.reduce((acc, val) => {
for (const method of val.methods) {
if (!acc.includes(method)) acc.push(method)
}
return acc
}, [])
const parts = paths.reduce((acc, val) => {
if (!val.parts) return acc
for (const part of Object.keys(val.parts)) {
if (!acc.includes(part)) acc.push(part)
}
return acc
}, [])
// get the required parts from the url
// if the url has at least one static path,
// then there are not required parts of the url
let allParts = []
for (const path of paths) {
if (path.parts) {
allParts.push(Object.keys(path.parts))
} else {
allParts = []
break
}
}
if (allParts.length > 0) {
intersect(...allParts).forEach(r => required.push(r))
}
for (const key in params) {
if (params[key].required) {
required.push(key)
}
acceptedQuerystring.push(key)
if (deprecatedParameters[release] && deprecatedParameters[release][key]) {
acceptedQuerystring.push(deprecatedParameters[release][key])
}
}
for (const key in spec[api]) {
const k = spec[api][key]
if (k && k.required) {
required.push(key)
}
}
if (common && common.params) {
for (const key in common.params) {
acceptedQuerystring.push(key)
}
}
const code = `
function ${name}Api (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)
${genRequiredChecks()}
${genUrlValidation(paths, api)}
let { ${genQueryDenylist(false)}, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
let path = ''
${buildPath()}
// build request object
const request = {
method,
path,
${genBody(api, methods, spec[api].body, spec)}
querystring
}
return this.transport.request(request, options, callback)
}
`.trim() // always call trim to avoid newlines
return {
name,
code,
acceptedQuerystring: acceptedQuerystring,
snakeCase: genSnakeCaseMap(),
documentation: generateDocumentation(spec[api], api)
}
function genRequiredChecks () {
const code = required
.map(_genRequiredCheck)
.concat(_noBody())
.filter(Boolean)
if (code.length) {
code.unshift('// check required parameters')
}
return code.join('\n ')
function _genRequiredCheck (param) {
const camelCased = param[0] === '_'
? '_' + param.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase())
: param.replace(/_([a-z])/g, k => k[1].toUpperCase())
if (param === camelCased) {
const check = `
if (params['${param}'] == null) {
const err = new this[kConfigurationError]('Missing required parameter: ${param}')
return handleError(err, callback)
}
`
return check.trim()
} else {
const check = `
if (params['${param}'] == null && params['${camelCased}'] == null) {
const err = new this[kConfigurationError]('Missing required parameter: ${param} or ${camelCased}')
return handleError(err, callback)
}
`
return check.trim()
}
}
function _noBody () {
const check = `
if (params.body != null) {
const err = new this[kConfigurationError]('This API does not require a body')
return handleError(err, callback)
}
`
return spec[api].body === null ? check.trim() : ''
}
}
function genSnakeCaseMap () {
const toCamelCase = str => {
return str[0] === '_'
? '_' + str.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase())
: str.replace(/_([a-z])/g, k => k[1].toUpperCase())
}
return acceptedQuerystring.reduce((acc, val, index) => {
if (toCamelCase(val) !== val) {
acc[toCamelCase(val)] = val
}
return acc
}, {})
}
function genQueryDenylist (addQuotes = true) {
const toCamelCase = str => {
return str[0] === '_'
? '_' + str.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase())
: str.replace(/_([a-z])/g, k => k[1].toUpperCase())
}
const denylist = ['method', 'body']
parts.forEach(p => {
const camelStr = toCamelCase(p)
if (camelStr !== p) denylist.push(`${camelStr}`)
denylist.push(`${p}`)
})
return addQuotes ? denylist.map(q => `'${q}'`) : denylist
}
function buildPath () {
const toCamelCase = str => {
return str[0] === '_'
? '_' + str.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase())
: str.replace(/_([a-z])/g, k => k[1].toUpperCase())
}
const genAccessKey = str => {
const camelStr = toCamelCase(str)
return camelStr === str
? str
: `${str} || ${camelStr}`
}
const genCheck = path => {
return path
.split('/')
.filter(Boolean)
.map(p => p.startsWith('{') ? `(${genAccessKey(p.slice(1, -1))}) != null` : false)
.filter(Boolean)
.join(' && ')
}
const genPath = path => {
path = path
.split('/')
.filter(Boolean)
.map(p => p.startsWith('{') ? `encodeURIComponent(${genAccessKey(p.slice(1, -1))})` : `'${p}'`)
.join(' + \'/\' + ')
return path.length > 0 ? ('\'/\' + ' + path) : '\'/\''
}
let hasStaticPath = false
let sortedPaths = paths
// some legacy API have mutliple statis paths
// this filter removes them
.filter(p => {
if (p.path.includes('{')) return true
if (hasStaticPath === false && p.deprecated == null) {
hasStaticPath = true
return true
}
return false
})
// sort by number of parameters (desc)
.sort((a, b) => Object.keys(b.parts || {}).length - Object.keys(a.parts || {}).length)
const allDeprecated = paths.filter(path => path.deprecated != null)
if (allDeprecated.length === paths.length) sortedPaths = [paths[0]]
let code = ''
for (let i = 0; i < sortedPaths.length; i++) {
const { path, methods } = sortedPaths[i]
if (sortedPaths.length === 1) {
code += `if (method == null) method = ${generatePickMethod(methods)}
path = ${genPath(path)}
`
} else if (i === 0) {
code += `if (${genCheck(path)}) {
if (method == null) method = ${generatePickMethod(methods)}
path = ${genPath(path)}
}
`
} else if (i === sortedPaths.length - 1) {
code += ` else {
if (method == null) method = ${generatePickMethod(methods)}
path = ${genPath(path)}
}
`
} else {
code += ` else if (${genCheck(path)}) {
if (method == null) method = ${generatePickMethod(methods)}
path = ${genPath(path)}
}
`
}
}
return code
}
}
function generatePickMethod (methods) {
if (methods.length === 1) {
return `'${methods[0]}'`
}
const bodyMethod = getBodyMethod(methods)
const noBodyMethod = getNoBodyMethod(methods)
if (bodyMethod && noBodyMethod) {
return `body == null ? '${noBodyMethod}' : '${bodyMethod}'`
} else if (bodyMethod) {
return `'${bodyMethod}'`
} else {
return `'${noBodyMethod}'`
}
}
function genBody (api, methods, body, spec) {
const bodyMethod = getBodyMethod(methods)
const { content_type } = spec[api].headers
if (content_type && content_type.includes('application/x-ndjson')) {
return 'bulkBody: body,'
}
if (body === null && bodyMethod) {
return 'body: \'\','
} else if (bodyMethod) {
return 'body: body || \'\','
} else {
return 'body: null,'
}
}
function getBodyMethod (methods) {
const m = methods.filter(m => ~allowedMethods.body.indexOf(m))
if (m.length) return m[0]
return null
}
function getNoBodyMethod (methods) {
const m = methods.filter(m => ~allowedMethods.noBody.indexOf(m))
if (m.length) return m[0]
return null
}
function genUrlValidation (paths, api) {
// this api does not need url validation
if (!needsPathValidation(api)) return ''
// gets only the dynamic components of the url in an array
// then we reverse it. A parameters always require what is
// at its right in the array.
const chunks = paths
.sort((a, b) => Object.keys(a.parts || {}).length > Object.keys(b.parts || {}).length ? -1 : 1)
.slice(0, 1)
.reduce((acc, val) => val.path, '')
// .reduce((a, b) => a.path.split('/').length > b.path.split('/').length ? a.path : b.path)
.split('/')
.filter(s => s.startsWith('{'))
.map(s => s.slice(1, -1))
.reverse()
let code = ''
const len = chunks.length
chunks.forEach((chunk, index) => {
if (index === len - 1) return
const params = []
let camelCased = chunk[0] === '_'
? '_' + chunk.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase())
: chunk.replace(/_([a-z])/g, k => k[1].toUpperCase())
if (chunk === camelCased) {
code += `${index ? '} else ' : ''}if (params['${chunk}'] != null && (`
} else {
code += `${index ? '} else ' : ''}if ((params['${chunk}'] != null || params['${camelCased}'] != null) && (`
}
for (let i = index + 1; i < len; i++) {
params.push(chunks[i])
// url parts can be declared in camelCase fashion
camelCased = chunks[i][0] === '_'
? '_' + chunks[i].slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase())
: chunks[i].replace(/_([a-z])/g, k => k[1].toUpperCase())
if (chunks[i] === camelCased) {
code += `params['${chunks[i]}'] == null${i === len - 1 ? '' : ' || '}`
} else {
code += `(params['${chunks[i]}'] == null && params['${camelCased}'] == null)${i === len - 1 ? '' : ' || '}`
}
}
code += `)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: ${params.join(', ')}')
return handleError(err, callback)
`
})
if (chunks.length > 1) {
code += '\n}'
}
if (code.length) {
code = '// check required url components\n' + code
}
return code.trim()
}
function generateDocumentation ({ documentation }, op) {
// we use `replace(/\u00A0/g, ' ')` to remove no breaking spaces
// because some parts of the description fields are using it
if (documentation == null) return ''
let doc = '/**\n'
doc += ` * Perform a ${op} request\n`
if (documentation.description) {
doc += ` * ${documentation.description.replace(/\u00A0/g, ' ')}\n`
}
if (documentation.url) {
doc += ` * ${documentation.url}\n`
}
doc += ' */'
return doc
}
function needsPathValidation (api) {
return noPathValidation.indexOf(api) === -1
}
function intersect (first, ...rest) {
return rest.reduce((accum, current) => {
return accum.filter(x => current.indexOf(x) !== -1)
}, first)
}
function Uppercase (str) {
return str[0].toUpperCase() + str.slice(1)
}
module.exports = generateNamespace

View File

@ -1,318 +0,0 @@
/*
* 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'
const { readdirSync } = require('fs')
const { join } = require('path')
const dedent = require('dedent')
const codeExamples = readdirSync(join(__dirname, '..', '..', 'docs', 'examples'))
.map(file => file.slice(0, -9))
.filter(api => api !== 'index')
function generateDocs (common, spec) {
let doc = dedent`
[[api-reference]]
////////
===========================================================================================================================
|| ||
|| ||
|| ||
|| ██████╗ ███████╗ █████╗ ██████╗ ███╗ ███╗███████╗ ||
|| ██╔══██╗██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝ ||
|| ██████╔╝█████╗ ███████║██║ ██║██╔████╔██║█████╗ ||
|| ██╔══██╗██╔══╝ ██╔══██║██║ ██║██║╚██╔╝██║██╔══╝ ||
|| ██║ ██║███████╗██║ ██║██████╔╝██║ ╚═╝ ██║███████╗ ||
|| ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚══════╝ ||
|| ||
|| ||
|| This file is autogenerated, DO NOT send pull requests that changes this file directly. ||
|| You should update the script that does the generation, which can be found in '/scripts/utils/generateDocs.js'. ||
|| ||
|| You can run the script with the following command: ||
|| node scripts/generate --branch <branch_name> ||
|| or ||
|| node scripts/generate --tag <tag_name> ||
|| ||
|| ||
|| ||
===========================================================================================================================
////////
== API Reference
This document contains the entire list of the Elasticsearch API supported by the client, both OSS and commercial. The client is entirely licensed under Apache 2.0.
Elasticsearch exposes an HTTP layer to communicate with, and the client is a library that will help you do this. Because of this reason, you will see HTTP related parameters, such as ${'`'}body${'`'} or ${'`'}headers${'`'}.
Every API can accept two objects, the first contains all the parameters that will be sent to Elasticsearch, while the second includes the request specific parameters, such as timeouts, headers, and so on.
In the first object, every parameter but the body will be sent via querystring or url parameter, depending on the API, and every unrecognized parameter will be sent as querystring.
[source,js]
----
// promise API
const result = await client.search({
index: 'my-index',
from: 20,
size: 10,
body: { foo: 'bar' }
}, {
ignore: [404],
maxRetries: 3
})
// callback API
client.search({
index: 'my-index',
from: 20,
size: 10,
body: { foo: 'bar' }
}, {
ignore: [404],
maxRetries: 3
}, (err, result) => {
if (err) console.log(err)
})
----
In this document, you will find the reference of every parameter accepted by the querystring or the url. If you also need to send the body, you can find the documentation of its format in the reference link that is present along with every endpoint.
\n\n`
doc += commonParameters(common)
spec.forEach(s => {
doc += '\n' + generateApiDoc(s)
})
return doc
}
function commonParameters (spec) {
let doc = dedent`
[discrete]
=== Common parameters
Parameters that are accepted by all API endpoints.
link:{ref}/common-options.html[Documentation]
[cols=2*]
|===\n`
Object.keys(spec.params).forEach(key => {
const name = isSnakeCased(key) && key !== camelify(key)
? '`' + key + '` or `' + camelify(key) + '`'
: '`' + key + '`'
doc += dedent`
|${name}
|${'`' + spec.params[key].type + '`'} - ${spec.params[key].description}`
if (spec.params[key].default) {
doc += ` +
_Default:_ ${'`' + spec.params[key].default + '`'}`
}
doc += '\n\n'
})
doc += dedent`
|===
`
return doc
}
function generateApiDoc (spec) {
const name = Object.keys(spec)[0]
const documentationUrl = spec[name].documentation && spec[name].documentation.url
? fixLink(name, spec[name].documentation.url)
: ''
const params = []
// url params
const urlParts = spec[name].url.paths.reduce((acc, path) => {
if (!path.parts) return acc
for (const part in path.parts) {
if (acc[part] != null) continue
acc[part] = path.parts[part]
}
return acc
}, {})
if (urlParts) {
Object.keys(urlParts).forEach(param => {
params.push({
name: param,
type: getType(urlParts[param].type, urlParts[param].options),
description: urlParts[param].description,
default: urlParts[param].default,
deprecated: !!urlParts[param].deprecated
})
})
}
// query params
const urlParams = spec[name].params
if (urlParams) {
Object.keys(urlParams).forEach(param => {
const duplicate = params.find(ele => ele.name === param)
if (duplicate) return
params.push({
name: param,
type: getType(urlParams[param].type, urlParams[param].options),
description: urlParams[param].description,
default: urlParams[param].default,
deprecated: !!urlParams[param].deprecated
})
})
}
// body params
const body = spec[name].body
if (body) {
params.push({
name: 'body',
type: 'object',
description: body.description,
default: body.default,
deprecated: !!body.deprecated
})
}
const codeParameters = params
.reduce((acc, val) => {
const code = `${val.name}: ${val.type},`
acc += acc === ''
? code
: '\n ' + code
return acc
}, '')
// remove last comma
.slice(0, -1)
const stability = spec[name].stability === 'stable'
? ''
: `*Stability:* ${spec[name].stability}`
let doc = dedent`
[discrete]
=== ${camelify(name)}
${stability}
[source,ts]
----
client.${camelify(name)}(${codeParameters.length > 0 ? `{\n ${codeParameters}\n}` : ''})
----\n`
if (documentationUrl) {
doc += `link:${documentationUrl}[Documentation] +\n`
}
if (codeExamples.includes(name)) {
doc += `{jsclient}/${name.replace(/\./g, '_')}_examples.html[Code Example] +\n`
}
if (params.length !== 0) {
doc += dedent`[cols=2*]
|===\n`
doc += params.reduce((acc, val) => {
const name = isSnakeCased(val.name) && val.name !== camelify(val.name)
? '`' + val.name + '` or `' + camelify(val.name) + '`'
: '`' + val.name + '`'
acc += dedent`
|${name}
|${'`' + val.type.replace(/\|/g, '\\|') + '`'} - ${val.description}`
if (val.default) {
acc += ` +\n_Default:_ ${'`' + val.default + '`'}`
}
if (val.deprecated) {
acc += ' +\n\nWARNING: This parameter has been deprecated.'
}
return acc + '\n\n'
}, '')
doc += dedent`
|===
`
}
doc += '\n'
return doc
}
const LINK_OVERRIDES = {
'license.delete': '{ref}/delete-license.html',
'license.get': '{ref}/get-license.html',
'license.get_basic_status': '{ref}/get-basic-status.html',
'license.get_trial_status': '{ref}/get-trial-status.html',
'license.post': '{ref}/update-license.html',
'license.post_start_basic': '{ref}/start-basic.html',
'license.post_start_trial': '{ref}/start-trial.html',
'migration.deprecations': '{ref}/migration-api-deprecation.html',
'monitoring.bulk': '{ref}/monitor-elasticsearch-cluster.html',
'ingest.delete_pipeline': '{ref}/delete-pipeline-api.html',
'ingest.get_pipeline': '{ref}/get-pipeline-api.html',
'ingest.put_pipeline': '{ref}/put-pipeline-api.html',
'ingest.simulate': '{ref}/simulate-pipeline-api.html',
'ingest.processor_grok': '{ref}/grok-processor.html#grok-processor-rest-get'
}
// Fixes bad urls in the JSON spec
function fixLink (name, str) {
/* In 6.x some API start with `xpack.` when in master they do not. We
* can safely ignore that for link generation. */
name = name.replace(/^xpack\./, '')
const override = LINK_OVERRIDES[name]
if (override) return override
if (!str) return ''
/* Replace references to the guide with the attribute {ref} because
* the json files in the Elasticsearch repo are a bit of a mess. */
str = str.replace(/^.+guide\/en\/elasticsearch\/reference\/[^/]+\/([^./]*\.html(?:#.+)?)$/, '{ref}/$1')
str = str.replace(/frozen\.html/, 'freeze-index-api.html')
str = str.replace(/ml-file-structure\.html/, 'ml-find-file-structure.html')
str = str.replace(/security-api-get-user-privileges\.html/, 'security-api-get-privileges.html')
return str
}
function getType (type, options) {
switch (type) {
case 'list':
return 'string | string[]'
case 'date':
case 'time':
case 'timeout':
return 'string'
case 'enum':
return options.map(k => `'${k}'`).join(' | ')
case 'int':
case 'double':
case 'long':
return 'number'
default:
return type
}
}
function camelify (str) {
return str[0] === '_'
? '_' + str.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase())
: str.replace(/_([a-z])/g, k => k[1].toUpperCase())
}
function isSnakeCased (str) {
return !!~str.indexOf('_')
}
module.exports = generateDocs

View File

@ -1,299 +0,0 @@
/*
* 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.
*/
/* eslint-disable no-template-curly-in-string */
/* eslint camelcase: 0 */
'use strict'
const { readdirSync } = require('fs')
const { join } = require('path')
const dedent = require('dedent')
const deepmerge = require('deepmerge')
function genFactory (folder, specFolder, namespaces) {
// get all the API files
// const apiFiles = readdirSync(folder)
const apiFiles = readdirSync(specFolder)
.filter(file => file !== '_common.json')
.filter(file => !file.includes('deprecated'))
.sort()
const types = apiFiles
.map(file => {
const name = file
.slice(0, -5)
.replace(/\.([a-z])/g, k => k[1].toUpperCase())
.replace(/_([a-z])/g, k => k[1].toUpperCase())
return file
.slice(0, -5) // remove `.json` extension
.split('.')
.reverse()
.reduce((acc, val) => {
const spec = readSpec(specFolder, file.slice(0, -5))
const isHead = isHeadMethod(spec, file.slice(0, -5))
const body = hasBody(spec, file.slice(0, -5))
const methods = acc === null ? buildMethodDefinition({ kibana: false }, val, name, body, isHead, spec) : null
const obj = {}
if (methods) {
for (const m of methods) {
obj[m.key] = m.val
}
} else {
obj[val] = acc
if (isSnakeCased(val)) {
obj[camelify(val)] = acc
}
}
return obj
}, null)
})
.reduce((acc, val) => deepmerge(acc, val), {})
const kibanaTypes = apiFiles
.map(file => {
const name = file
.slice(0, -5)
.replace(/\.([a-z])/g, k => k[1].toUpperCase())
.replace(/_([a-z])/g, k => k[1].toUpperCase())
return file
.slice(0, -5) // remove `.json` extension
.split('.')
.reverse()
.reduce((acc, val) => {
const spec = readSpec(specFolder, file.slice(0, -5))
const isHead = isHeadMethod(spec, file.slice(0, -5))
const body = hasBody(spec, file.slice(0, -5))
const methods = acc === null ? buildMethodDefinition({ kibana: true }, val, name, body, isHead, spec) : null
const obj = {}
if (methods) {
for (const m of methods) {
obj[m.key] = m.val
}
} else {
obj[camelify(val)] = acc
}
return obj
}, null)
})
.reduce((acc, val) => deepmerge(acc, val), {})
// serialize the type object
const typesStr = Object.keys(types)
.map(key => {
const line = ` ${key}: ${JSON.stringify(types[key], null, 4)}`
if (line.slice(-1) === '}') {
return line.slice(0, -1) + ' }'
}
return line
})
.join('\n')
// remove useless quotes and commas
.replace(/"/g, '')
.replace(/,$/gm, '')
const kibanaTypesStr = Object.keys(kibanaTypes)
.map(key => {
const line = ` ${key}: ${JSON.stringify(kibanaTypes[key], null, 4)}`
if (line.slice(-1) === '}') {
return line.slice(0, -1) + ' }'
}
return line
})
.join('\n')
// remove useless quotes and commas
.replace(/"/g, '')
.replace(/,$/gm, '')
let apisStr = ''
const getters = []
for (const namespace in namespaces) {
if (namespaces[namespace].length > 0) {
getters.push(`${camelify(namespace)}: {
get () {
if (this[k${toPascalCase(camelify(namespace))}] === null) {
this[k${toPascalCase(camelify(namespace))}] = new ${toPascalCase(camelify(namespace))}Api(this.transport, this[kConfigurationError])
}
return this[k${toPascalCase(camelify(namespace))}]
}
},\n`)
if (namespace.includes('_')) {
getters.push(`${namespace}: { get () { return this.${camelify(namespace)} } },\n`)
}
} else {
apisStr += `ESAPI.prototype.${camelify(namespace)} = ${camelify(namespace)}Api\n`
if (namespace.includes('_')) {
getters.push(`${namespace}: { get () { return this.${camelify(namespace)} } },\n`)
}
}
}
apisStr += '\nObject.defineProperties(ESAPI.prototype, {\n'
for (const getter of getters) {
apisStr += getter
}
apisStr += '})'
let modules = ''
let symbols = ''
let symbolsInstance = ''
for (const namespace in namespaces) {
if (namespaces[namespace].length > 0) {
modules += `const ${toPascalCase(camelify(namespace))}Api = require('./api/${namespace}')\n`
symbols += `const k${toPascalCase(camelify(namespace))} = Symbol('${toPascalCase(camelify(namespace))}')\n`
symbolsInstance += `this[k${toPascalCase(camelify(namespace))}] = null\n`
} else {
modules += `const ${camelify(namespace)}Api = require('./api/${namespace}')\n`
}
}
const fn = dedent`
/*
* 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'
${modules}
const { kConfigurationError } = require('./utils')
${symbols}
function ESAPI (opts) {
this[kConfigurationError] = opts.ConfigurationError
${symbolsInstance}
}
${apisStr}
module.exports = ESAPI
`
// new line at the end of file
return { fn: fn + '\n', types: typesStr, kibanaTypes: kibanaTypesStr }
}
// from snake_case to camelCase
function camelify (str) {
return str.replace(/_([a-z])/g, k => k[1].toUpperCase())
}
function isSnakeCased (str) {
return !!~str.indexOf('_')
}
function toPascalCase (str) {
return str[0].toUpperCase() + str.slice(1)
}
function buildMethodDefinition (opts, api, name, hasBody, isHead, spec) {
const Name = toPascalCase(name)
const { content_type } = spec[Object.keys(spec)[0]].headers
const bodyType = content_type && content_type.includes('application/x-ndjson') ? 'RequestNDBody' : 'RequestBody'
const responseType = isHead ? 'boolean' : 'Record<string, any>'
const defaultBodyType = content_type && content_type.includes('application/x-ndjson') ? 'Record<string, any>[]' : 'Record<string, any>'
if (opts.kibana) {
if (hasBody) {
return [
{ key: `${camelify(api)}<TResponse = ${responseType}, TRequestBody extends ${bodyType} = ${defaultBodyType}, TContext = Context>(params?: RequestParams.${Name}<TRequestBody>, options?: TransportRequestOptions)`, val: 'TransportRequestPromise<ApiResponse<TResponse, TContext>>' }
]
} else {
return [
{ key: `${camelify(api)}<TResponse = ${responseType}, TContext = Context>(params?: RequestParams.${Name}, options?: TransportRequestOptions)`, val: 'TransportRequestPromise<ApiResponse<TResponse, TContext>>' }
]
}
}
if (hasBody) {
let methods = [
{ key: `${api}<TResponse = ${responseType}, TRequestBody extends ${bodyType} = ${defaultBodyType}, TContext = Context>(params?: RequestParams.${Name}<TRequestBody>, options?: TransportRequestOptions)`, val: 'TransportRequestPromise<ApiResponse<TResponse, TContext>>' },
{ key: `${api}<TResponse = ${responseType}, TRequestBody extends ${bodyType} = ${defaultBodyType}, TContext = Context>(callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' },
{ key: `${api}<TResponse = ${responseType}, TRequestBody extends ${bodyType} = ${defaultBodyType}, TContext = Context>(params: RequestParams.${Name}<TRequestBody>, callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' },
{ key: `${api}<TResponse = ${responseType}, TRequestBody extends ${bodyType} = ${defaultBodyType}, TContext = Context>(params: RequestParams.${Name}<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' }
]
if (isSnakeCased(api)) {
methods = methods.concat([
{ key: `${camelify(api)}<TResponse = ${responseType}, TRequestBody extends ${bodyType} = ${defaultBodyType}, TContext = Context>(params?: RequestParams.${Name}<TRequestBody>, options?: TransportRequestOptions)`, val: 'TransportRequestPromise<ApiResponse<TResponse, TContext>>' },
{ key: `${camelify(api)}<TResponse = ${responseType}, TRequestBody extends ${bodyType} = ${defaultBodyType}, TContext = Context>(callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' },
{ key: `${camelify(api)}<TResponse = ${responseType}, TRequestBody extends ${bodyType} = ${defaultBodyType}, TContext = Context>(params: RequestParams.${Name}<TRequestBody>, callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' },
{ key: `${camelify(api)}<TResponse = ${responseType}, TRequestBody extends ${bodyType} = ${defaultBodyType}, TContext = Context>(params: RequestParams.${Name}<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' }
])
}
return methods
} else {
let methods = [
{ key: `${api}<TResponse = ${responseType}, TContext = Context>(params?: RequestParams.${Name}, options?: TransportRequestOptions)`, val: 'TransportRequestPromise<ApiResponse<TResponse, TContext>>' },
{ key: `${api}<TResponse = ${responseType}, TContext = Context>(callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' },
{ key: `${api}<TResponse = ${responseType}, TContext = Context>(params: RequestParams.${Name}, callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' },
{ key: `${api}<TResponse = ${responseType}, TContext = Context>(params: RequestParams.${Name}, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' }
]
if (isSnakeCased(api)) {
methods = methods.concat([
{ key: `${camelify(api)}<TResponse = ${responseType}, TContext = Context>(params?: RequestParams.${Name}, options?: TransportRequestOptions)`, val: 'TransportRequestPromise<ApiResponse<TResponse, TContext>>' },
{ key: `${camelify(api)}<TResponse = ${responseType}, TContext = Context>(callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' },
{ key: `${camelify(api)}<TResponse = ${responseType}, TContext = Context>(params: RequestParams.${Name}, callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' },
{ key: `${camelify(api)}<TResponse = ${responseType}, TContext = Context>(params: RequestParams.${Name}, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>)`, val: 'TransportRequestCallback' }
])
}
return methods
}
}
function hasBody (spec, api) {
return !!spec[api].body
}
function isHeadMethod (spec, api) {
const { paths } = spec[api].url
const methods = []
for (const path of paths) {
for (const method of path.methods) {
if (!methods.includes(method)) {
methods.push(method)
}
}
}
return methods.length === 1 && methods[0] === 'HEAD'
}
function readSpec (specFolder, file) {
try {
return require(join(specFolder, file))
} catch (err) {
throw new Error(`Cannot read spec file ${file}`)
}
}
module.exports = genFactory

View File

@ -1,191 +0,0 @@
/*
* 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.
*/
/* eslint camelcase: 0 */
'use strict'
const deprecatedParameters = require('./patch.json')
function generate (version, api) {
const release = version.charAt(0)
let types = `/*
* 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.
*/
import { RequestBody, RequestNDBody } from '../lib/Transport'
export interface Generic {
method?: string;
filter_path?: string | string[];
pretty?: boolean;
human?: boolean;
error_trace?: boolean;
source?: string;
}
`
api.forEach(generateRequestType)
return types
function generateRequestType (spec) {
const api = Object.keys(spec)[0]
const name = api
.replace(/\.([a-z])/g, k => k[1].toUpperCase())
.replace(/_([a-z])/g, k => k[1].toUpperCase())
const { paths = {} } = spec[api].url
const { body, params = {} } = spec[api]
// get the required parts from the url
// if the url has at least one static path,
// then there are not required parts of the url
let allParts = []
let requiredParts = []
for (const path of paths) {
if (path.parts) {
allParts.push(Object.keys(path.parts))
} else {
allParts = []
break
}
}
if (allParts.length > 0) {
requiredParts = intersect(...allParts)
}
const parts = paths.reduce((acc, path) => {
if (!path.parts) return acc
for (const part in path.parts) {
if (acc[part] != null) continue
acc[part] = { key: part, value: path.parts[part], required: requiredParts.includes(part) }
}
return acc
}, {})
const deprecatedParametersToAdd = []
const paramsArr = Object.keys(params)
.filter(k => !Object.keys(parts).includes(k))
.map(k => {
if (deprecatedParameters[release] && deprecatedParameters[release][k]) {
deprecatedParametersToAdd.push({
key: deprecatedParameters[release][k],
value: params[k],
required: params[k].required
})
}
return { key: k, value: params[k], required: params[k].required }
})
const partsArr = Object.keys(parts).map(k => parts[k])
deprecatedParametersToAdd.forEach(k => partsArr.push(k))
const genLine = e => {
const optional = e.required ? '' : '?'
return `${e.key}${optional}: ${getType(e.value.type, e.value.options)};`
}
const { content_type } = spec[api].headers
const bodyGeneric = content_type && content_type.includes('application/x-ndjson') ? 'RequestNDBody' : 'RequestBody'
const code = `
export interface ${toPascalCase(name)}${body ? `<T = ${bodyGeneric}>` : ''} extends Generic {
${partsArr.map(genLine).join('\n ')}
${paramsArr.map(genLine).join('\n ')}
${body ? `body${body.required ? '' : '?'}: T;` : ''}
}
`
types += '\n'
// remove empty lines
types += code.replace(/^\s*\n/gm, '')
}
function getType (type, options) {
switch (type) {
case 'list':
return 'string | string[]'
case 'date':
case 'time':
case 'timeout':
return 'string'
case 'enum': {
// the following code changes 'true' | 'false' to boolean
let foundTrue = false
let foundFalse = false
options = options
.map(k => {
if (k === 'true') {
foundTrue = true
return true
} else if (k === 'false') {
foundFalse = true
return false
} else {
return `'${k}'`
}
})
.filter(k => {
if (foundTrue && foundFalse && (k === true || k === false)) {
return false
}
return true
})
if (foundTrue && foundFalse) {
options.push('boolean')
}
return options.join(' | ')
}
case 'int':
case 'double':
case 'long':
return 'number'
case 'boolean|long':
return 'boolean | number'
default:
return type
}
}
}
function intersect (first, ...rest) {
return rest.reduce((accum, current) => {
return accum.filter(x => current.indexOf(x) !== -1)
}, first)
}
function toPascalCase (str) {
return str[0].toUpperCase() + str.slice(1)
}
module.exports = generate

View File

@ -1,34 +0,0 @@
/*
* 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'
const generate = require('./generateApis')
const cloneAndCheckout = require('./clone-es')
const genFactory = require('./generateMain')
const generateDocs = require('./generateDocs')
const generateRequestTypes = require('./generateRequestTypes')
module.exports = {
generate,
cloneAndCheckout,
genFactory,
generateDocs,
generateRequestTypes
}

View File

@ -1,14 +0,0 @@
{
"6": {
"_source_includes": "_source_include",
"_source_excludes": "_source_exclude"
},
"7": {
"_source_includes": "_source_include",
"_source_excludes": "_source_exclude"
},
"8": {
"_source_includes": "_source_include",
"_source_excludes": "_source_exclude"
}
}

View File

@ -1,21 +0,0 @@
#!/bin/bash
TEST_ES_SERVER=${TEST_ES_SERVER:-"http://localhost:9200"}
attempt_counter=0
max_attempts=5
url="${TEST_ES_SERVER}/_cluster/health?wait_for_status=green&timeout=50s"
echo "Waiting for Elasticsearch..."
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' --max-time 55 "$url")" != "200" ]]; do
if [ ${attempt_counter} -eq ${max_attempts} ];then
echo "\nCouldn't connect to Elasticsearch"
exit 1
fi
printf '.'
attempt_counter=$(($attempt_counter+1))
sleep 5
done
echo "\nReady"

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
/* eslint-disable import/export */
@ -35,12 +21,133 @@ import {
TransportResult
} from '@elastic/transport'
import * as T from '../types'
interface That { transport: Transport }
interface That {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class AsyncSearch {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) {
this.transport = transport
this.acceptedParams = {
'async_search.delete': {
path: [
'id'
],
body: [],
query: []
},
'async_search.get': {
path: [
'id'
],
body: [],
query: [
'keep_alive',
'typed_keys',
'wait_for_completion_timeout'
]
},
'async_search.status': {
path: [
'id'
],
body: [],
query: [
'keep_alive'
]
},
'async_search.submit': {
path: [
'index'
],
body: [
'aggregations',
'aggs',
'collapse',
'explain',
'ext',
'from',
'highlight',
'track_total_hits',
'indices_boost',
'docvalue_fields',
'knn',
'min_score',
'post_filter',
'profile',
'query',
'rescore',
'script_fields',
'search_after',
'size',
'slice',
'sort',
'_source',
'fields',
'suggest',
'terminate_after',
'timeout',
'track_scores',
'version',
'seq_no_primary_term',
'stored_fields',
'pit',
'runtime_mappings',
'stats'
],
query: [
'wait_for_completion_timeout',
'keep_alive',
'keep_on_completion',
'allow_no_indices',
'allow_partial_search_results',
'analyzer',
'analyze_wildcard',
'batched_reduce_size',
'ccs_minimize_roundtrips',
'default_operator',
'df',
'docvalue_fields',
'expand_wildcards',
'explain',
'ignore_throttled',
'ignore_unavailable',
'lenient',
'max_concurrent_shard_requests',
'preference',
'request_cache',
'routing',
'search_type',
'stats',
'stored_fields',
'suggest_field',
'suggest_mode',
'suggest_size',
'suggest_text',
'terminate_after',
'timeout',
'track_total_hits',
'track_scores',
'typed_keys',
'rest_total_hits_as_int',
'version',
'_source',
'_source_excludes',
'_source_includes',
'seq_no_primary_term',
'q',
'size',
'from',
'sort'
]
}
}
}
/**
@ -51,7 +158,10 @@ export default class AsyncSearch {
async delete (this: That, params: T.AsyncSearchDeleteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchDeleteResponse, unknown>>
async delete (this: That, params: T.AsyncSearchDeleteRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchDeleteResponse>
async delete (this: That, params: T.AsyncSearchDeleteRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['id']
const {
path: acceptedPath
} = this.acceptedParams['async_search.delete']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -93,7 +203,10 @@ export default class AsyncSearch {
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchGetResponse<TDocument, TAggregations>, unknown>>
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchGetResponse<TDocument, TAggregations>>
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['id']
const {
path: acceptedPath
} = this.acceptedParams['async_search.get']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -135,7 +248,10 @@ export default class AsyncSearch {
async status (this: That, params: T.AsyncSearchStatusRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchStatusResponse, unknown>>
async status (this: That, params: T.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchStatusResponse>
async status (this: That, params: T.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['id']
const {
path: acceptedPath
} = this.acceptedParams['async_search.status']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -177,8 +293,12 @@ export default class AsyncSearch {
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchSubmitResponse<TDocument, TAggregations>, unknown>>
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchSubmitResponse<TDocument, TAggregations>>
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const acceptedBody: string[] = ['aggregations', 'aggs', 'collapse', 'explain', 'ext', 'from', 'highlight', 'track_total_hits', 'indices_boost', 'docvalue_fields', 'knn', 'min_score', 'post_filter', 'profile', 'query', 'rescore', 'script_fields', 'search_after', 'size', 'slice', 'sort', '_source', 'fields', 'suggest', 'terminate_after', 'timeout', 'track_scores', 'version', 'seq_no_primary_term', 'stored_fields', 'pit', 'runtime_mappings', 'stats']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['async_search.submit']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -205,8 +325,14 @@ export default class AsyncSearch {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
/* eslint-disable import/export */
@ -35,12 +21,59 @@ import {
TransportResult
} from '@elastic/transport'
import * as T from '../types'
interface That { transport: Transport }
interface That {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class Autoscaling {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) {
this.transport = transport
this.acceptedParams = {
'autoscaling.delete_autoscaling_policy': {
path: [
'name'
],
body: [],
query: [
'master_timeout',
'timeout'
]
},
'autoscaling.get_autoscaling_capacity': {
path: [],
body: [],
query: [
'master_timeout'
]
},
'autoscaling.get_autoscaling_policy': {
path: [
'name'
],
body: [],
query: [
'master_timeout'
]
},
'autoscaling.put_autoscaling_policy': {
path: [
'name'
],
body: [
'policy'
],
query: [
'master_timeout',
'timeout'
]
}
}
}
/**
@ -51,7 +84,10 @@ export default class Autoscaling {
async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingDeleteAutoscalingPolicyResponse, unknown>>
async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<T.AutoscalingDeleteAutoscalingPolicyResponse>
async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['autoscaling.delete_autoscaling_policy']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -93,7 +129,10 @@ export default class Autoscaling {
async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingGetAutoscalingCapacityResponse, unknown>>
async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptions): Promise<T.AutoscalingGetAutoscalingCapacityResponse>
async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['autoscaling.get_autoscaling_capacity']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -133,7 +172,10 @@ export default class Autoscaling {
async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingGetAutoscalingPolicyResponse, unknown>>
async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<T.AutoscalingGetAutoscalingPolicyResponse>
async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['autoscaling.get_autoscaling_policy']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -175,8 +217,12 @@ export default class Autoscaling {
async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingPutAutoscalingPolicyResponse, unknown>>
async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<T.AutoscalingPutAutoscalingPolicyResponse>
async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const acceptedBody: string[] = ['policy']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['autoscaling.put_autoscaling_policy']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -188,8 +234,14 @@ export default class Autoscaling {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
/* eslint-disable import/export */
@ -35,7 +21,18 @@ import {
TransportResult
} from '@elastic/transport'
import * as T from '../types'
interface That { transport: Transport }
interface That {
transport: Transport
}
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
capabilities: {
path: [],
body: [],
query: []
}
}
/**
* Checks if the specified combination of method, API, parameters, and arbitrary capabilities are supported
@ -45,7 +42,10 @@ export default async function CapabilitiesApi (this: That, params?: T.TODO, opti
export default async function CapabilitiesApi (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
export default async function CapabilitiesApi (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO>
export default async function CapabilitiesApi (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = acceptedParams.capabilities
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
/* eslint-disable import/export */
@ -35,12 +21,336 @@ import {
TransportResult
} from '@elastic/transport'
import * as T from '../types'
interface That { transport: Transport }
interface That {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
export default class Cat {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) {
this.transport = transport
this.acceptedParams = {
'cat.aliases': {
path: [
'name'
],
body: [],
query: [
'h',
's',
'expand_wildcards',
'master_timeout'
]
},
'cat.allocation': {
path: [
'node_id'
],
body: [],
query: [
'bytes',
'h',
's',
'local',
'master_timeout'
]
},
'cat.component_templates': {
path: [
'name'
],
body: [],
query: [
'h',
's',
'local',
'master_timeout'
]
},
'cat.count': {
path: [
'index'
],
body: [],
query: [
'h',
's'
]
},
'cat.fielddata': {
path: [
'fields'
],
body: [],
query: [
'bytes',
'fields',
'h',
's'
]
},
'cat.health': {
path: [],
body: [],
query: [
'time',
'ts',
'h',
's'
]
},
'cat.help': {
path: [],
body: [],
query: []
},
'cat.indices': {
path: [
'index'
],
body: [],
query: [
'bytes',
'expand_wildcards',
'health',
'include_unloaded_segments',
'pri',
'time',
'master_timeout',
'h',
's'
]
},
'cat.master': {
path: [],
body: [],
query: [
'h',
's',
'local',
'master_timeout'
]
},
'cat.ml_data_frame_analytics': {
path: [
'id'
],
body: [],
query: [
'allow_no_match',
'bytes',
'h',
's',
'time'
]
},
'cat.ml_datafeeds': {
path: [
'datafeed_id'
],
body: [],
query: [
'allow_no_match',
'h',
's',
'time'
]
},
'cat.ml_jobs': {
path: [
'job_id'
],
body: [],
query: [
'allow_no_match',
'bytes',
'h',
's',
'time'
]
},
'cat.ml_trained_models': {
path: [
'model_id'
],
body: [],
query: [
'allow_no_match',
'bytes',
'h',
's',
'from',
'size',
'time'
]
},
'cat.nodeattrs': {
path: [],
body: [],
query: [
'h',
's',
'local',
'master_timeout'
]
},
'cat.nodes': {
path: [],
body: [],
query: [
'bytes',
'full_id',
'include_unloaded_segments',
'h',
's',
'master_timeout',
'time'
]
},
'cat.pending_tasks': {
path: [],
body: [],
query: [
'h',
's',
'local',
'master_timeout',
'time'
]
},
'cat.plugins': {
path: [],
body: [],
query: [
'h',
's',
'include_bootstrap',
'local',
'master_timeout'
]
},
'cat.recovery': {
path: [
'index'
],
body: [],
query: [
'active_only',
'bytes',
'detailed',
'index',
'h',
's',
'time'
]
},
'cat.repositories': {
path: [],
body: [],
query: [
'h',
's',
'local',
'master_timeout'
]
},
'cat.segments': {
path: [
'index'
],
body: [],
query: [
'bytes',
'h',
's',
'local',
'master_timeout'
]
},
'cat.shards': {
path: [
'index'
],
body: [],
query: [
'bytes',
'h',
's',
'master_timeout',
'time'
]
},
'cat.snapshots': {
path: [
'repository'
],
body: [],
query: [
'ignore_unavailable',
'h',
's',
'master_timeout',
'time'
]
},
'cat.tasks': {
path: [],
body: [],
query: [
'actions',
'detailed',
'nodes',
'parent_task_id',
'h',
's',
'time',
'timeout',
'wait_for_completion'
]
},
'cat.templates': {
path: [
'name'
],
body: [],
query: [
'h',
's',
'local',
'master_timeout'
]
},
'cat.thread_pool': {
path: [
'thread_pool_patterns'
],
body: [],
query: [
'h',
's',
'time',
'local',
'master_timeout'
]
},
'cat.transforms': {
path: [
'transform_id'
],
body: [],
query: [
'allow_no_match',
'from',
'h',
's',
'time',
'size'
]
}
}
}
/**
@ -51,7 +361,10 @@ export default class Cat {
async aliases (this: That, params?: T.CatAliasesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatAliasesResponse, unknown>>
async aliases (this: That, params?: T.CatAliasesRequest, options?: TransportRequestOptions): Promise<T.CatAliasesResponse>
async aliases (this: That, params?: T.CatAliasesRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['cat.aliases']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -101,7 +414,10 @@ export default class Cat {
async allocation (this: That, params?: T.CatAllocationRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatAllocationResponse, unknown>>
async allocation (this: That, params?: T.CatAllocationRequest, options?: TransportRequestOptions): Promise<T.CatAllocationResponse>
async allocation (this: That, params?: T.CatAllocationRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['node_id']
const {
path: acceptedPath
} = this.acceptedParams['cat.allocation']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -151,7 +467,10 @@ export default class Cat {
async componentTemplates (this: That, params?: T.CatComponentTemplatesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatComponentTemplatesResponse, unknown>>
async componentTemplates (this: That, params?: T.CatComponentTemplatesRequest, options?: TransportRequestOptions): Promise<T.CatComponentTemplatesResponse>
async componentTemplates (this: That, params?: T.CatComponentTemplatesRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['cat.component_templates']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -201,7 +520,10 @@ export default class Cat {
async count (this: That, params?: T.CatCountRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatCountResponse, unknown>>
async count (this: That, params?: T.CatCountRequest, options?: TransportRequestOptions): Promise<T.CatCountResponse>
async count (this: That, params?: T.CatCountRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const {
path: acceptedPath
} = this.acceptedParams['cat.count']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -251,7 +573,10 @@ export default class Cat {
async fielddata (this: That, params?: T.CatFielddataRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatFielddataResponse, unknown>>
async fielddata (this: That, params?: T.CatFielddataRequest, options?: TransportRequestOptions): Promise<T.CatFielddataResponse>
async fielddata (this: That, params?: T.CatFielddataRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['fields']
const {
path: acceptedPath
} = this.acceptedParams['cat.fielddata']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -301,7 +626,10 @@ export default class Cat {
async health (this: That, params?: T.CatHealthRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatHealthResponse, unknown>>
async health (this: That, params?: T.CatHealthRequest, options?: TransportRequestOptions): Promise<T.CatHealthResponse>
async health (this: That, params?: T.CatHealthRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cat.health']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -341,7 +669,10 @@ export default class Cat {
async help (this: That, params?: T.CatHelpRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatHelpResponse, unknown>>
async help (this: That, params?: T.CatHelpRequest, options?: TransportRequestOptions): Promise<T.CatHelpResponse>
async help (this: That, params?: T.CatHelpRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cat.help']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -381,7 +712,10 @@ export default class Cat {
async indices (this: That, params?: T.CatIndicesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatIndicesResponse, unknown>>
async indices (this: That, params?: T.CatIndicesRequest, options?: TransportRequestOptions): Promise<T.CatIndicesResponse>
async indices (this: That, params?: T.CatIndicesRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const {
path: acceptedPath
} = this.acceptedParams['cat.indices']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -431,7 +765,10 @@ export default class Cat {
async master (this: That, params?: T.CatMasterRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatMasterResponse, unknown>>
async master (this: That, params?: T.CatMasterRequest, options?: TransportRequestOptions): Promise<T.CatMasterResponse>
async master (this: That, params?: T.CatMasterRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cat.master']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -471,7 +808,10 @@ export default class Cat {
async mlDataFrameAnalytics (this: That, params?: T.CatMlDataFrameAnalyticsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatMlDataFrameAnalyticsResponse, unknown>>
async mlDataFrameAnalytics (this: That, params?: T.CatMlDataFrameAnalyticsRequest, options?: TransportRequestOptions): Promise<T.CatMlDataFrameAnalyticsResponse>
async mlDataFrameAnalytics (this: That, params?: T.CatMlDataFrameAnalyticsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['id']
const {
path: acceptedPath
} = this.acceptedParams['cat.ml_data_frame_analytics']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -521,7 +861,10 @@ export default class Cat {
async mlDatafeeds (this: That, params?: T.CatMlDatafeedsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatMlDatafeedsResponse, unknown>>
async mlDatafeeds (this: That, params?: T.CatMlDatafeedsRequest, options?: TransportRequestOptions): Promise<T.CatMlDatafeedsResponse>
async mlDatafeeds (this: That, params?: T.CatMlDatafeedsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['datafeed_id']
const {
path: acceptedPath
} = this.acceptedParams['cat.ml_datafeeds']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -571,7 +914,10 @@ export default class Cat {
async mlJobs (this: That, params?: T.CatMlJobsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatMlJobsResponse, unknown>>
async mlJobs (this: That, params?: T.CatMlJobsRequest, options?: TransportRequestOptions): Promise<T.CatMlJobsResponse>
async mlJobs (this: That, params?: T.CatMlJobsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['job_id']
const {
path: acceptedPath
} = this.acceptedParams['cat.ml_jobs']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -621,7 +967,10 @@ export default class Cat {
async mlTrainedModels (this: That, params?: T.CatMlTrainedModelsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatMlTrainedModelsResponse, unknown>>
async mlTrainedModels (this: That, params?: T.CatMlTrainedModelsRequest, options?: TransportRequestOptions): Promise<T.CatMlTrainedModelsResponse>
async mlTrainedModels (this: That, params?: T.CatMlTrainedModelsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['model_id']
const {
path: acceptedPath
} = this.acceptedParams['cat.ml_trained_models']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -671,7 +1020,10 @@ export default class Cat {
async nodeattrs (this: That, params?: T.CatNodeattrsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatNodeattrsResponse, unknown>>
async nodeattrs (this: That, params?: T.CatNodeattrsRequest, options?: TransportRequestOptions): Promise<T.CatNodeattrsResponse>
async nodeattrs (this: That, params?: T.CatNodeattrsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cat.nodeattrs']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -711,7 +1063,10 @@ export default class Cat {
async nodes (this: That, params?: T.CatNodesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatNodesResponse, unknown>>
async nodes (this: That, params?: T.CatNodesRequest, options?: TransportRequestOptions): Promise<T.CatNodesResponse>
async nodes (this: That, params?: T.CatNodesRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cat.nodes']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -751,7 +1106,10 @@ export default class Cat {
async pendingTasks (this: That, params?: T.CatPendingTasksRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatPendingTasksResponse, unknown>>
async pendingTasks (this: That, params?: T.CatPendingTasksRequest, options?: TransportRequestOptions): Promise<T.CatPendingTasksResponse>
async pendingTasks (this: That, params?: T.CatPendingTasksRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cat.pending_tasks']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -791,7 +1149,10 @@ export default class Cat {
async plugins (this: That, params?: T.CatPluginsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatPluginsResponse, unknown>>
async plugins (this: That, params?: T.CatPluginsRequest, options?: TransportRequestOptions): Promise<T.CatPluginsResponse>
async plugins (this: That, params?: T.CatPluginsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cat.plugins']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -831,7 +1192,10 @@ export default class Cat {
async recovery (this: That, params?: T.CatRecoveryRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatRecoveryResponse, unknown>>
async recovery (this: That, params?: T.CatRecoveryRequest, options?: TransportRequestOptions): Promise<T.CatRecoveryResponse>
async recovery (this: That, params?: T.CatRecoveryRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const {
path: acceptedPath
} = this.acceptedParams['cat.recovery']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -881,7 +1245,10 @@ export default class Cat {
async repositories (this: That, params?: T.CatRepositoriesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatRepositoriesResponse, unknown>>
async repositories (this: That, params?: T.CatRepositoriesRequest, options?: TransportRequestOptions): Promise<T.CatRepositoriesResponse>
async repositories (this: That, params?: T.CatRepositoriesRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cat.repositories']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -921,7 +1288,10 @@ export default class Cat {
async segments (this: That, params?: T.CatSegmentsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatSegmentsResponse, unknown>>
async segments (this: That, params?: T.CatSegmentsRequest, options?: TransportRequestOptions): Promise<T.CatSegmentsResponse>
async segments (this: That, params?: T.CatSegmentsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const {
path: acceptedPath
} = this.acceptedParams['cat.segments']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -971,7 +1341,10 @@ export default class Cat {
async shards (this: That, params?: T.CatShardsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatShardsResponse, unknown>>
async shards (this: That, params?: T.CatShardsRequest, options?: TransportRequestOptions): Promise<T.CatShardsResponse>
async shards (this: That, params?: T.CatShardsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const {
path: acceptedPath
} = this.acceptedParams['cat.shards']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -1021,7 +1394,10 @@ export default class Cat {
async snapshots (this: That, params?: T.CatSnapshotsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatSnapshotsResponse, unknown>>
async snapshots (this: That, params?: T.CatSnapshotsRequest, options?: TransportRequestOptions): Promise<T.CatSnapshotsResponse>
async snapshots (this: That, params?: T.CatSnapshotsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['repository']
const {
path: acceptedPath
} = this.acceptedParams['cat.snapshots']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -1071,7 +1447,10 @@ export default class Cat {
async tasks (this: That, params?: T.CatTasksRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatTasksResponse, unknown>>
async tasks (this: That, params?: T.CatTasksRequest, options?: TransportRequestOptions): Promise<T.CatTasksResponse>
async tasks (this: That, params?: T.CatTasksRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cat.tasks']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -1111,7 +1490,10 @@ export default class Cat {
async templates (this: That, params?: T.CatTemplatesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatTemplatesResponse, unknown>>
async templates (this: That, params?: T.CatTemplatesRequest, options?: TransportRequestOptions): Promise<T.CatTemplatesResponse>
async templates (this: That, params?: T.CatTemplatesRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['cat.templates']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -1161,7 +1543,10 @@ export default class Cat {
async threadPool (this: That, params?: T.CatThreadPoolRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatThreadPoolResponse, unknown>>
async threadPool (this: That, params?: T.CatThreadPoolRequest, options?: TransportRequestOptions): Promise<T.CatThreadPoolResponse>
async threadPool (this: That, params?: T.CatThreadPoolRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['thread_pool_patterns']
const {
path: acceptedPath
} = this.acceptedParams['cat.thread_pool']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -1211,7 +1596,10 @@ export default class Cat {
async transforms (this: That, params?: T.CatTransformsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatTransformsResponse, unknown>>
async transforms (this: That, params?: T.CatTransformsRequest, options?: TransportRequestOptions): Promise<T.CatTransformsResponse>
async transforms (this: That, params?: T.CatTransformsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['transform_id']
const {
path: acceptedPath
} = this.acceptedParams['cat.transforms']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
/* eslint-disable import/export */
@ -35,12 +21,185 @@ import {
TransportResult
} from '@elastic/transport'
import * as T from '../types'
interface That { transport: Transport }
interface That {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class Ccr {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) {
this.transport = transport
this.acceptedParams = {
'ccr.delete_auto_follow_pattern': {
path: [
'name'
],
body: [],
query: [
'master_timeout'
]
},
'ccr.follow': {
path: [
'index'
],
body: [
'data_stream_name',
'leader_index',
'max_outstanding_read_requests',
'max_outstanding_write_requests',
'max_read_request_operation_count',
'max_read_request_size',
'max_retry_delay',
'max_write_buffer_count',
'max_write_buffer_size',
'max_write_request_operation_count',
'max_write_request_size',
'read_poll_timeout',
'remote_cluster',
'settings'
],
query: [
'master_timeout',
'wait_for_active_shards'
]
},
'ccr.follow_info': {
path: [
'index'
],
body: [],
query: [
'master_timeout'
]
},
'ccr.follow_stats': {
path: [
'index'
],
body: [],
query: [
'timeout'
]
},
'ccr.forget_follower': {
path: [
'index'
],
body: [
'follower_cluster',
'follower_index',
'follower_index_uuid',
'leader_remote_cluster'
],
query: [
'timeout'
]
},
'ccr.get_auto_follow_pattern': {
path: [
'name'
],
body: [],
query: [
'master_timeout'
]
},
'ccr.pause_auto_follow_pattern': {
path: [
'name'
],
body: [],
query: [
'master_timeout'
]
},
'ccr.pause_follow': {
path: [
'index'
],
body: [],
query: [
'master_timeout'
]
},
'ccr.put_auto_follow_pattern': {
path: [
'name'
],
body: [
'remote_cluster',
'follow_index_pattern',
'leader_index_patterns',
'leader_index_exclusion_patterns',
'max_outstanding_read_requests',
'settings',
'max_outstanding_write_requests',
'read_poll_timeout',
'max_read_request_operation_count',
'max_read_request_size',
'max_retry_delay',
'max_write_buffer_count',
'max_write_buffer_size',
'max_write_request_operation_count',
'max_write_request_size'
],
query: [
'master_timeout'
]
},
'ccr.resume_auto_follow_pattern': {
path: [
'name'
],
body: [],
query: [
'master_timeout'
]
},
'ccr.resume_follow': {
path: [
'index'
],
body: [
'max_outstanding_read_requests',
'max_outstanding_write_requests',
'max_read_request_operation_count',
'max_read_request_size',
'max_retry_delay',
'max_write_buffer_count',
'max_write_buffer_size',
'max_write_request_operation_count',
'max_write_request_size',
'read_poll_timeout'
],
query: [
'master_timeout'
]
},
'ccr.stats': {
path: [],
body: [],
query: [
'master_timeout',
'timeout'
]
},
'ccr.unfollow': {
path: [
'index'
],
body: [],
query: [
'master_timeout'
]
}
}
}
/**
@ -51,7 +210,10 @@ export default class Ccr {
async deleteAutoFollowPattern (this: That, params: T.CcrDeleteAutoFollowPatternRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrDeleteAutoFollowPatternResponse, unknown>>
async deleteAutoFollowPattern (this: That, params: T.CcrDeleteAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<T.CcrDeleteAutoFollowPatternResponse>
async deleteAutoFollowPattern (this: That, params: T.CcrDeleteAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['ccr.delete_auto_follow_pattern']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -93,8 +255,12 @@ export default class Ccr {
async follow (this: That, params: T.CcrFollowRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrFollowResponse, unknown>>
async follow (this: That, params: T.CcrFollowRequest, options?: TransportRequestOptions): Promise<T.CcrFollowResponse>
async follow (this: That, params: T.CcrFollowRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const acceptedBody: string[] = ['data_stream_name', 'leader_index', 'max_outstanding_read_requests', 'max_outstanding_write_requests', 'max_read_request_operation_count', 'max_read_request_size', 'max_retry_delay', 'max_write_buffer_count', 'max_write_buffer_size', 'max_write_request_operation_count', 'max_write_request_size', 'read_poll_timeout', 'remote_cluster', 'settings']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['ccr.follow']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -116,8 +282,14 @@ export default class Ccr {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}
@ -140,7 +312,10 @@ export default class Ccr {
async followInfo (this: That, params: T.CcrFollowInfoRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrFollowInfoResponse, unknown>>
async followInfo (this: That, params: T.CcrFollowInfoRequest, options?: TransportRequestOptions): Promise<T.CcrFollowInfoResponse>
async followInfo (this: That, params: T.CcrFollowInfoRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const {
path: acceptedPath
} = this.acceptedParams['ccr.follow_info']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -182,7 +357,10 @@ export default class Ccr {
async followStats (this: That, params: T.CcrFollowStatsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrFollowStatsResponse, unknown>>
async followStats (this: That, params: T.CcrFollowStatsRequest, options?: TransportRequestOptions): Promise<T.CcrFollowStatsResponse>
async followStats (this: That, params: T.CcrFollowStatsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const {
path: acceptedPath
} = this.acceptedParams['ccr.follow_stats']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -224,8 +402,12 @@ export default class Ccr {
async forgetFollower (this: That, params: T.CcrForgetFollowerRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrForgetFollowerResponse, unknown>>
async forgetFollower (this: That, params: T.CcrForgetFollowerRequest, options?: TransportRequestOptions): Promise<T.CcrForgetFollowerResponse>
async forgetFollower (this: That, params: T.CcrForgetFollowerRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const acceptedBody: string[] = ['follower_cluster', 'follower_index', 'follower_index_uuid', 'leader_remote_cluster']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['ccr.forget_follower']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -247,8 +429,14 @@ export default class Ccr {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}
@ -271,7 +459,10 @@ export default class Ccr {
async getAutoFollowPattern (this: That, params?: T.CcrGetAutoFollowPatternRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrGetAutoFollowPatternResponse, unknown>>
async getAutoFollowPattern (this: That, params?: T.CcrGetAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<T.CcrGetAutoFollowPatternResponse>
async getAutoFollowPattern (this: That, params?: T.CcrGetAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['ccr.get_auto_follow_pattern']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -321,7 +512,10 @@ export default class Ccr {
async pauseAutoFollowPattern (this: That, params: T.CcrPauseAutoFollowPatternRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrPauseAutoFollowPatternResponse, unknown>>
async pauseAutoFollowPattern (this: That, params: T.CcrPauseAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<T.CcrPauseAutoFollowPatternResponse>
async pauseAutoFollowPattern (this: That, params: T.CcrPauseAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['ccr.pause_auto_follow_pattern']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -363,7 +557,10 @@ export default class Ccr {
async pauseFollow (this: That, params: T.CcrPauseFollowRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrPauseFollowResponse, unknown>>
async pauseFollow (this: That, params: T.CcrPauseFollowRequest, options?: TransportRequestOptions): Promise<T.CcrPauseFollowResponse>
async pauseFollow (this: That, params: T.CcrPauseFollowRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const {
path: acceptedPath
} = this.acceptedParams['ccr.pause_follow']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -405,8 +602,12 @@ export default class Ccr {
async putAutoFollowPattern (this: That, params: T.CcrPutAutoFollowPatternRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrPutAutoFollowPatternResponse, unknown>>
async putAutoFollowPattern (this: That, params: T.CcrPutAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<T.CcrPutAutoFollowPatternResponse>
async putAutoFollowPattern (this: That, params: T.CcrPutAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const acceptedBody: string[] = ['remote_cluster', 'follow_index_pattern', 'leader_index_patterns', 'leader_index_exclusion_patterns', 'max_outstanding_read_requests', 'settings', 'max_outstanding_write_requests', 'read_poll_timeout', 'max_read_request_operation_count', 'max_read_request_size', 'max_retry_delay', 'max_write_buffer_count', 'max_write_buffer_size', 'max_write_request_operation_count', 'max_write_request_size']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['ccr.put_auto_follow_pattern']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -428,8 +629,14 @@ export default class Ccr {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}
@ -452,7 +659,10 @@ export default class Ccr {
async resumeAutoFollowPattern (this: That, params: T.CcrResumeAutoFollowPatternRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrResumeAutoFollowPatternResponse, unknown>>
async resumeAutoFollowPattern (this: That, params: T.CcrResumeAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<T.CcrResumeAutoFollowPatternResponse>
async resumeAutoFollowPattern (this: That, params: T.CcrResumeAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['ccr.resume_auto_follow_pattern']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -494,8 +704,12 @@ export default class Ccr {
async resumeFollow (this: That, params: T.CcrResumeFollowRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrResumeFollowResponse, unknown>>
async resumeFollow (this: That, params: T.CcrResumeFollowRequest, options?: TransportRequestOptions): Promise<T.CcrResumeFollowResponse>
async resumeFollow (this: That, params: T.CcrResumeFollowRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const acceptedBody: string[] = ['max_outstanding_read_requests', 'max_outstanding_write_requests', 'max_read_request_operation_count', 'max_read_request_size', 'max_retry_delay', 'max_write_buffer_count', 'max_write_buffer_size', 'max_write_request_operation_count', 'max_write_request_size', 'read_poll_timeout']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['ccr.resume_follow']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -517,8 +731,14 @@ export default class Ccr {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}
@ -541,7 +761,10 @@ export default class Ccr {
async stats (this: That, params?: T.CcrStatsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrStatsResponse, unknown>>
async stats (this: That, params?: T.CcrStatsRequest, options?: TransportRequestOptions): Promise<T.CcrStatsResponse>
async stats (this: That, params?: T.CcrStatsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['ccr.stats']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -581,7 +804,10 @@ export default class Ccr {
async unfollow (this: That, params: T.CcrUnfollowRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrUnfollowResponse, unknown>>
async unfollow (this: That, params: T.CcrUnfollowRequest, options?: TransportRequestOptions): Promise<T.CcrUnfollowResponse>
async unfollow (this: That, params: T.CcrUnfollowRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const {
path: acceptedPath
} = this.acceptedParams['ccr.unfollow']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
/* eslint-disable import/export */
@ -35,7 +21,22 @@ import {
TransportResult
} from '@elastic/transport'
import * as T from '../types'
interface That { transport: Transport }
interface That {
transport: Transport
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
clear_scroll: {
path: [],
body: [
'scroll_id'
],
query: []
}
}
/**
* Clear a scrolling search. Clear the search context and results for a scrolling search.
@ -45,8 +46,12 @@ export default async function ClearScrollApi (this: That, params?: T.ClearScroll
export default async function ClearScrollApi (this: That, params?: T.ClearScrollRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClearScrollResponse, unknown>>
export default async function ClearScrollApi (this: That, params?: T.ClearScrollRequest, options?: TransportRequestOptions): Promise<T.ClearScrollResponse>
export default async function ClearScrollApi (this: That, params?: T.ClearScrollRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const acceptedBody: string[] = ['scroll_id']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = acceptedParams.clear_scroll
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -69,8 +74,14 @@ export default async function ClearScrollApi (this: That, params?: T.ClearScroll
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
/* eslint-disable import/export */
@ -35,7 +21,22 @@ import {
TransportResult
} from '@elastic/transport'
import * as T from '../types'
interface That { transport: Transport }
interface That {
transport: Transport
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
close_point_in_time: {
path: [],
body: [
'id'
],
query: []
}
}
/**
* Close a point in time. A point in time must be opened explicitly before being used in search requests. The `keep_alive` parameter tells Elasticsearch how long it should persist. A point in time is automatically closed when the `keep_alive` period has elapsed. However, keeping points in time has a cost; close them as soon as they are no longer required for search requests.
@ -45,8 +46,12 @@ export default async function ClosePointInTimeApi (this: That, params: T.ClosePo
export default async function ClosePointInTimeApi (this: That, params: T.ClosePointInTimeRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClosePointInTimeResponse, unknown>>
export default async function ClosePointInTimeApi (this: That, params: T.ClosePointInTimeRequest, options?: TransportRequestOptions): Promise<T.ClosePointInTimeResponse>
export default async function ClosePointInTimeApi (this: That, params: T.ClosePointInTimeRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const acceptedBody: string[] = ['id']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = acceptedParams.close_point_in_time
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -68,8 +73,14 @@ export default async function ClosePointInTimeApi (this: That, params: T.ClosePo
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}

View File

@ -1,20 +1,6 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Copyright Elasticsearch B.V. and contributors
* SPDX-License-Identifier: Apache-2.0
*/
/* eslint-disable import/export */
@ -35,12 +21,202 @@ import {
TransportResult
} from '@elastic/transport'
import * as T from '../types'
interface That { transport: Transport }
interface That {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class Cluster {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) {
this.transport = transport
this.acceptedParams = {
'cluster.allocation_explain': {
path: [],
body: [
'current_node',
'index',
'primary',
'shard'
],
query: [
'include_disk_info',
'include_yes_decisions',
'master_timeout'
]
},
'cluster.delete_component_template': {
path: [
'name'
],
body: [],
query: [
'master_timeout',
'timeout'
]
},
'cluster.delete_voting_config_exclusions': {
path: [],
body: [],
query: [
'master_timeout',
'wait_for_removal'
]
},
'cluster.exists_component_template': {
path: [
'name'
],
body: [],
query: [
'master_timeout',
'local'
]
},
'cluster.get_component_template': {
path: [
'name'
],
body: [],
query: [
'flat_settings',
'include_defaults',
'local',
'master_timeout'
]
},
'cluster.get_settings': {
path: [],
body: [],
query: [
'flat_settings',
'include_defaults',
'master_timeout',
'timeout'
]
},
'cluster.health': {
path: [
'index'
],
body: [],
query: [
'expand_wildcards',
'level',
'local',
'master_timeout',
'timeout',
'wait_for_active_shards',
'wait_for_events',
'wait_for_nodes',
'wait_for_no_initializing_shards',
'wait_for_no_relocating_shards',
'wait_for_status'
]
},
'cluster.info': {
path: [
'target'
],
body: [],
query: []
},
'cluster.pending_tasks': {
path: [],
body: [],
query: [
'local',
'master_timeout'
]
},
'cluster.post_voting_config_exclusions': {
path: [],
body: [],
query: [
'node_names',
'node_ids',
'master_timeout',
'timeout'
]
},
'cluster.put_component_template': {
path: [
'name'
],
body: [
'template',
'version',
'_meta',
'deprecated'
],
query: [
'create',
'master_timeout'
]
},
'cluster.put_settings': {
path: [],
body: [
'persistent',
'transient'
],
query: [
'flat_settings',
'master_timeout',
'timeout'
]
},
'cluster.remote_info': {
path: [],
body: [],
query: []
},
'cluster.reroute': {
path: [],
body: [
'commands'
],
query: [
'dry_run',
'explain',
'metric',
'retry_failed',
'master_timeout',
'timeout'
]
},
'cluster.state': {
path: [
'metric',
'index'
],
body: [],
query: [
'allow_no_indices',
'expand_wildcards',
'flat_settings',
'ignore_unavailable',
'local',
'master_timeout',
'wait_for_metadata_version',
'wait_for_timeout'
]
},
'cluster.stats': {
path: [
'node_id'
],
body: [],
query: [
'include_remotes',
'timeout'
]
}
}
}
/**
@ -51,8 +227,12 @@ export default class Cluster {
async allocationExplain (this: That, params?: T.ClusterAllocationExplainRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterAllocationExplainResponse, unknown>>
async allocationExplain (this: That, params?: T.ClusterAllocationExplainRequest, options?: TransportRequestOptions): Promise<T.ClusterAllocationExplainResponse>
async allocationExplain (this: That, params?: T.ClusterAllocationExplainRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const acceptedBody: string[] = ['current_node', 'index', 'primary', 'shard']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['cluster.allocation_explain']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -75,8 +255,14 @@ export default class Cluster {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}
@ -96,7 +282,10 @@ export default class Cluster {
async deleteComponentTemplate (this: That, params: T.ClusterDeleteComponentTemplateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterDeleteComponentTemplateResponse, unknown>>
async deleteComponentTemplate (this: That, params: T.ClusterDeleteComponentTemplateRequest, options?: TransportRequestOptions): Promise<T.ClusterDeleteComponentTemplateResponse>
async deleteComponentTemplate (this: That, params: T.ClusterDeleteComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['cluster.delete_component_template']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -138,7 +327,10 @@ export default class Cluster {
async deleteVotingConfigExclusions (this: That, params?: T.ClusterDeleteVotingConfigExclusionsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterDeleteVotingConfigExclusionsResponse, unknown>>
async deleteVotingConfigExclusions (this: That, params?: T.ClusterDeleteVotingConfigExclusionsRequest, options?: TransportRequestOptions): Promise<T.ClusterDeleteVotingConfigExclusionsResponse>
async deleteVotingConfigExclusions (this: That, params?: T.ClusterDeleteVotingConfigExclusionsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cluster.delete_voting_config_exclusions']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -178,7 +370,10 @@ export default class Cluster {
async existsComponentTemplate (this: That, params: T.ClusterExistsComponentTemplateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterExistsComponentTemplateResponse, unknown>>
async existsComponentTemplate (this: That, params: T.ClusterExistsComponentTemplateRequest, options?: TransportRequestOptions): Promise<T.ClusterExistsComponentTemplateResponse>
async existsComponentTemplate (this: That, params: T.ClusterExistsComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['cluster.exists_component_template']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -220,7 +415,10 @@ export default class Cluster {
async getComponentTemplate (this: That, params?: T.ClusterGetComponentTemplateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterGetComponentTemplateResponse, unknown>>
async getComponentTemplate (this: That, params?: T.ClusterGetComponentTemplateRequest, options?: TransportRequestOptions): Promise<T.ClusterGetComponentTemplateResponse>
async getComponentTemplate (this: That, params?: T.ClusterGetComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['cluster.get_component_template']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -270,7 +468,10 @@ export default class Cluster {
async getSettings (this: That, params?: T.ClusterGetSettingsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterGetSettingsResponse, unknown>>
async getSettings (this: That, params?: T.ClusterGetSettingsRequest, options?: TransportRequestOptions): Promise<T.ClusterGetSettingsResponse>
async getSettings (this: That, params?: T.ClusterGetSettingsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cluster.get_settings']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -310,7 +511,10 @@ export default class Cluster {
async health (this: That, params?: T.ClusterHealthRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterHealthResponse, unknown>>
async health (this: That, params?: T.ClusterHealthRequest, options?: TransportRequestOptions): Promise<T.ClusterHealthResponse>
async health (this: That, params?: T.ClusterHealthRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const {
path: acceptedPath
} = this.acceptedParams['cluster.health']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -360,7 +564,10 @@ export default class Cluster {
async info (this: That, params: T.ClusterInfoRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterInfoResponse, unknown>>
async info (this: That, params: T.ClusterInfoRequest, options?: TransportRequestOptions): Promise<T.ClusterInfoResponse>
async info (this: That, params: T.ClusterInfoRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['target']
const {
path: acceptedPath
} = this.acceptedParams['cluster.info']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -402,7 +609,10 @@ export default class Cluster {
async pendingTasks (this: That, params?: T.ClusterPendingTasksRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterPendingTasksResponse, unknown>>
async pendingTasks (this: That, params?: T.ClusterPendingTasksRequest, options?: TransportRequestOptions): Promise<T.ClusterPendingTasksResponse>
async pendingTasks (this: That, params?: T.ClusterPendingTasksRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cluster.pending_tasks']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -442,7 +652,10 @@ export default class Cluster {
async postVotingConfigExclusions (this: That, params?: T.ClusterPostVotingConfigExclusionsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterPostVotingConfigExclusionsResponse, unknown>>
async postVotingConfigExclusions (this: That, params?: T.ClusterPostVotingConfigExclusionsRequest, options?: TransportRequestOptions): Promise<T.ClusterPostVotingConfigExclusionsResponse>
async postVotingConfigExclusions (this: That, params?: T.ClusterPostVotingConfigExclusionsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cluster.post_voting_config_exclusions']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -482,8 +695,12 @@ export default class Cluster {
async putComponentTemplate (this: That, params: T.ClusterPutComponentTemplateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterPutComponentTemplateResponse, unknown>>
async putComponentTemplate (this: That, params: T.ClusterPutComponentTemplateRequest, options?: TransportRequestOptions): Promise<T.ClusterPutComponentTemplateResponse>
async putComponentTemplate (this: That, params: T.ClusterPutComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const acceptedBody: string[] = ['template', 'version', '_meta', 'deprecated']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['cluster.put_component_template']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -505,8 +722,14 @@ export default class Cluster {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}
@ -529,8 +752,12 @@ export default class Cluster {
async putSettings (this: That, params?: T.ClusterPutSettingsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterPutSettingsResponse, unknown>>
async putSettings (this: That, params?: T.ClusterPutSettingsRequest, options?: TransportRequestOptions): Promise<T.ClusterPutSettingsResponse>
async putSettings (this: That, params?: T.ClusterPutSettingsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const acceptedBody: string[] = ['persistent', 'transient']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['cluster.put_settings']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -553,8 +780,14 @@ export default class Cluster {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}
@ -574,7 +807,10 @@ export default class Cluster {
async remoteInfo (this: That, params?: T.ClusterRemoteInfoRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterRemoteInfoResponse, unknown>>
async remoteInfo (this: That, params?: T.ClusterRemoteInfoRequest, options?: TransportRequestOptions): Promise<T.ClusterRemoteInfoResponse>
async remoteInfo (this: That, params?: T.ClusterRemoteInfoRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['cluster.remote_info']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -614,8 +850,12 @@ export default class Cluster {
async reroute (this: That, params?: T.ClusterRerouteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterRerouteResponse, unknown>>
async reroute (this: That, params?: T.ClusterRerouteRequest, options?: TransportRequestOptions): Promise<T.ClusterRerouteResponse>
async reroute (this: That, params?: T.ClusterRerouteRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const acceptedBody: string[] = ['commands']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['cluster.reroute']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -638,8 +878,14 @@ export default class Cluster {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}
@ -659,7 +905,10 @@ export default class Cluster {
async state (this: That, params?: T.ClusterStateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterStateResponse, unknown>>
async state (this: That, params?: T.ClusterStateRequest, options?: TransportRequestOptions): Promise<T.ClusterStateResponse>
async state (this: That, params?: T.ClusterStateRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['metric', 'index']
const {
path: acceptedPath
} = this.acceptedParams['cluster.state']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
@ -713,7 +962,10 @@ export default class Cluster {
async stats (this: That, params?: T.ClusterStatsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterStatsResponse, unknown>>
async stats (this: That, params?: T.ClusterStatsRequest, options?: TransportRequestOptions): Promise<T.ClusterStatsResponse>
async stats (this: That, params?: T.ClusterStatsRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['node_id']
const {
path: acceptedPath
} = this.acceptedParams['cluster.stats']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

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