Compare commits

..

41 Commits

Author SHA1 Message Date
394dc8d9a5 Auto-generated API code (#2578) 2025-01-21 13:06:24 -06:00
d542c069e8 Auto-generated code for 8.15 (#2570) 2025-01-13 10:08:26 -06:00
11f12b48e1 Auto-generated code for 8.15 (#2552) 2025-01-07 13:22:18 -06:00
3196bf6d1c Auto-generated code for 8.15 (#2539) 2024-12-10 11:28:20 -06:00
6bbc0dacdd [Backport 8.15] Checkout correct branch of generator (#2536)
(cherry picked from commit ed3cace127)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-12-10 11:17:43 -06:00
e93b7495c0 [Backport 8.15] Codegen for 8.x clients should use the 8.x generator branch (#2520)
(cherry picked from commit 15b9ee2f06)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-12-05 10:39:43 -06:00
c69fbac3ab Auto-generated code for 8.15 (#2501) 2024-12-02 12:07:32 -06:00
7d4ae5e3dd Bump to 8.15.3 (#2488) 2024-11-21 10:32:36 -06:00
529598b43f Backport #2487 (#2494) 2024-11-21 10:23:23 -06:00
ec61d1afb1 Auto-generated code for 8.15 (#2472) 2024-11-18 11:24:26 -06:00
05e140ca16 [Backport 8.15] Address feedback and add clarity (#2450)
Co-authored-by: Marci W <333176+marciw@users.noreply.github.com>
2024-11-12 11:06:23 -06:00
b050185399 Prep 8.15.2 for release (#2443) 2024-11-11 10:16:18 -06:00
ce6db97a71 Auto-generated code for 8.15 (#2440) 2024-11-11 09:46:27 -06:00
5d4bd654a3 Auto-generated code for 8.15 (#2424) 2024-11-04 16:10:58 -06:00
43175e1a2b [Backport 8.15] Skip flaky test (#2428)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-11-04 09:59:29 -06:00
fc80b3247d Auto-generated code for 8.15 (#2411) 2024-10-28 11:21:16 -05:00
e47b135e8d Backport #2400 to 8.15 (#2403) 2024-10-24 11:49:42 -05:00
4afa601051 Auto-generated code for 8.15 (#2385) 2024-10-21 10:59:54 -05:00
c6544c2979 [Backport 8.15] Add doc about timeout best practices (#2382)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-10-18 11:26:00 -05:00
fb1a42cadc Prep 8.15.1 (#2378) 2024-10-15 11:38:06 -05:00
e3863d7b77 Auto-generated code for 8.15 (#2373) 2024-10-14 11:19:18 -05:00
424cc94458 Auto-generated code for 8.15 (#2370) 2024-09-30 13:37:38 -05:00
7aca5cf652 [Backport 8.15] Upgrade transport to 8.8.1 (#2367)
(cherry picked from commit aad41df231)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-09-26 16:42:34 -05:00
a8927727b1 Auto-generated code for 8.15 (#2363) 2024-09-24 10:04:11 -05:00
15a450eba4 Update 8.15 auto-merge action to match main (#2361) 2024-09-03 13:08:33 -05:00
8f028a522a Auto-generated code for 8.15 (#2359) 2024-09-03 09:36:52 -05:00
411f379006 Auto-generated code for 8.15 (#2350) 2024-08-26 13:57:17 -05:00
242b4227ee Auto-generated code for 8.15 (#2342) 2024-08-19 10:52:15 -05:00
78332da539 [Backport 8.15] Add support for auto-merge (#2339)
* Add support for auto-merge

* Fix bad request-converter version

* Switch back to pull_request

pull_request_target is the wrong trigger for this action

(cherry picked from commit 4b8969cc78)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-08-14 10:16:43 -05:00
62b2d78b15 [Backport 8.15] Generate documentation example snippets (#2334)
* Update docs example generation script

* Add docs examples generation to codegen job

(cherry picked from commit 77e2f613f2)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-08-12 13:22:07 -05:00
599d7e6e07 [Backport 8.15] Update changelog for 8.15 (#2333)
(cherry picked from commit 69b243171b)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-08-12 13:08:24 -05:00
6116909a9b [Backport 8.15] Try running auto-approve after other jobs (#2330)
(cherry picked from commit 37b8a33209)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-08-12 12:36:46 -05:00
f609271107 Auto-generated code for 8.15 (#2322) 2024-08-06 11:31:05 -05:00
b4eb8e5441 [Backport 8.15] Added/updated snippets for docs (#2319)
(cherry picked from commit f737290d10)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-07-29 17:10:42 -05:00
ccf9fcbd93 Auto-generated code for 8.15 (#2316) 2024-07-29 10:20:07 -05:00
0c6f323745 Auto-generated code for 8.15 (#2313) 2024-07-24 16:38:15 -05:00
04a9eb462d [DOCS] Comment out broken link breaking docs build (#2311) 2024-07-15 17:55:35 +02:00
05eaa9fc61 Auto-generated code for 8.15 (#2309) 2024-07-09 16:54:55 -05:00
30c6793383 Auto-generated code for 8.15 (#2308) 2024-07-08 13:35:53 -05:00
6df75b6a92 [Backport 8.15] Documentation for OpenTelemetry support (#2302)
* Documentation for OpenTelemetry support

* Update docs/observability.asciidoc

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>

* Fix docs typo

* Fix bad link references in asciidoc changelog

* Drop link to 8.15 changelog

For now. Link just doesn't work yet.

---------

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
(cherry picked from commit 94bf5b2aa7)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-07-02 11:36:42 -05:00
383206ef19 [Backport 8.15] Upgrade transport to 8.7.0 (#2301)
(cherry picked from commit f34bb6aa28)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-07-01 13:30:57 -05:00
183 changed files with 30994 additions and 36576 deletions

View File

@ -11,6 +11,6 @@ RUN apt-get clean -y && \
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY package.json . COPY package.json .
RUN npm install RUN npm install --production=false
COPY . . COPY . .

View File

@ -24,7 +24,7 @@ USER ${BUILDER_UID}:${BUILDER_GID}
# install dependencies # install dependencies
COPY package.json . COPY package.json .
RUN npm install RUN npm install --production=false
# copy project files # copy project files
COPY . . COPY . .

View File

@ -6,7 +6,7 @@ steps:
env: env:
NODE_VERSION: "{{ matrix.nodejs }}" NODE_VERSION: "{{ matrix.nodejs }}"
TEST_SUITE: "{{ matrix.suite }}" TEST_SUITE: "{{ matrix.suite }}"
STACK_VERSION: 8.16.0 STACK_VERSION: 8.15.0
matrix: matrix:
setup: setup:
suite: suite:
@ -25,7 +25,7 @@ steps:
provider: "gcp" provider: "gcp"
image: family/core-ubuntu-2204 image: family/core-ubuntu-2204
plugins: plugins:
- junit-annotate#v2.6.0: - junit-annotate#v2.4.1:
artifacts: "junit-output/junit-*.xml" artifacts: "junit-output/junit-*.xml"
job-uuid-file-pattern: "junit-(.*).xml" job-uuid-file-pattern: "junit-(.*).xml"
fail-build-on-error: true fail-build-on-error: true

50
.github/ISSUE_TEMPLATE/bug.md vendored Normal file
View File

@ -0,0 +1,50 @@
---
name: 🐛 Bug report
about: Create a report to help us improve
labels: ["Category: Bug"]
---
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
**Please read this entire template before posting any issue. If you ignore these instructions
and post an issue here that does not follow the instructions, your issue might be closed,
locked, and assigned the `Category: Not an issue` label.**
## 🐛 Bug Report
A clear and concise description of what the bug is.
## To Reproduce
Steps to reproduce the behavior:
Paste your code here:
```js
```
<!--
In some cases, it might be challenging to reproduce the bug in a few lines of code.
You can fork the following repository, which contains all the configuration needed
to spin up a three nodes Elasticsearch cluster with security enabled.
The repository also contains a preconfigured client instance that you can use to reproduce the issue.
https://github.com/delvedor/es-reproduce-issue
--->
## Expected behavior
A clear and concise description of what you expected to happen.
Paste the results here:
```js
```
## Your Environment
- *node version*: 6,8,10
- `@elastic/elasticsearch` *version*: >=7.0.0
- *os*: Mac, Windows, Linux
- *any other relevant information*

View File

@ -1,66 +0,0 @@
---
name: 🐛 Bug report
description: Create a report to help us improve
labels: ["Category: Bug"]
body:
- type: markdown
attributes:
value: |
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
**Please read this entire template before posting any issue. If you ignore these instructions
and post an issue here that does not follow the instructions, your issue might be closed,
locked, and assigned the `Category: Not an issue` label.**
- type: textarea
id: bug-report
attributes:
label: 🐛 Bug report
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: To reproduce
description: Steps to reproduce the behavior
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: input
id: node-js-version
attributes:
label: Node.js version
placeholder: 18.x, 20.x, etc.
validations:
required: true
- type: input
id: client-version
attributes:
label: "@elastic/elasticsearch version"
placeholder: 7.17.0, 8.14.1, etc.
validations:
required: true
- type: input
id: os
attributes:
label: Operating system
placeholder: Ubuntu 22.04, macOS, etc.
validations:
required: true
- type: input
id: env-info
attributes:
label: Any other relevant environment information

23
.github/ISSUE_TEMPLATE/feature.md vendored Normal file
View File

@ -0,0 +1,23 @@
---
name: 🚀 Feature Proposal
about: Submit a proposal for a new feature
labels: ["Category: Feature"]
---
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
**Please read this entire template before posting any issue. If you ignore these instructions
and post an issue here that does not follow the instructions, your issue might be closed,
locked, and assigned the `Category: Not an issue` label.**
## 🚀 Feature Proposal
A clear and concise description of what the feature is.
## Motivation
Please outline the motivation for the proposal.
## Example
Please provide an example for how this feature would be used.

View File

@ -1,33 +0,0 @@
---
name: 🚀 Feature Proposal
description: Submit a proposal for a new feature
labels: ["Category: Feature"]
body:
- type: markdown
attributes:
value: |
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
**Please read this entire template before posting any issue. If you ignore these instructions
and post an issue here that does not follow the instructions, your issue might be closed,
locked, and assigned the `Category: Not an issue` label.**
- type: textarea
id: feature-proposal
attributes:
label: 🚀 Feature Proposal
description: A clear and concise description of what the feature is.
validations:
required: true
- type: textarea
id: motivation
attributes:
label: Motivation
description: Please outline the motivation for the proposal.
- type: textarea
id: example
attributes:
label: Example
description: Please provide an example for how this feature would be used.

11
.github/ISSUE_TEMPLATE/question.md vendored Normal file
View File

@ -0,0 +1,11 @@
---
name: 💬 Questions / Help
about: If you have questions, please check our Gitter or Help repo
labels: ["Category: Question"]
---
## 💬 Questions and Help
### Please note that this issue tracker is not a help forum and this issue may be closed.
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.

View File

@ -1,21 +0,0 @@
---
name: 💬 Questions / Help
description: If you have questions, please check our community forum or support
labels: ["Category: Question"]
body:
- type: markdown
attributes:
value: |
### Please note that this issue tracker is not a help forum and this issue may be closed.
Please check our [community forum](https://discuss.elastic.co/) or [contact Elastic support](https://www.elastic.co/support) if your issue is not specifically related to the documented functionality of this client library.
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
- type: textarea
id: question
attributes:
label: Question
description: Your question or comment
validations:
required: true

6
.github/ISSUE_TEMPLATE/security.md vendored Normal file
View File

@ -0,0 +1,6 @@
---
name: 👮 Security Issue
about: Responsible Disclosure
---
If you want to report a security issue, please take a look at [elastic/security](https://www.elastic.co/community/security).

View File

@ -1,8 +0,0 @@
---
name: 👮 Security Issue
description: Responsible disclosure
body:
- type: markdown
attributes:
value: |
If you want to report a security issue, please take a look at [elastic/security](https://www.elastic.co/community/security).

6
.github/make.sh vendored
View File

@ -37,7 +37,7 @@ product="elastic/elasticsearch-js"
output_folder=".buildkite/output" output_folder=".buildkite/output"
codegen_folder=".buildkite/output" codegen_folder=".buildkite/output"
OUTPUT_DIR="$repo/${output_folder}" OUTPUT_DIR="$repo/${output_folder}"
NODE_JS_VERSION=22 NODE_JS_VERSION=18
WORKFLOW=${WORKFLOW-staging} WORKFLOW=${WORKFLOW-staging}
mkdir -p "$OUTPUT_DIR" mkdir -p "$OUTPUT_DIR"
@ -65,7 +65,7 @@ codegen)
if [ -v "$VERSION" ] || [[ -z "$VERSION" ]]; then if [ -v "$VERSION" ] || [[ -z "$VERSION" ]]; then
# fall back to branch name or `main` if no VERSION is set # fall back to branch name or `main` if no VERSION is set
branch_name=$(git rev-parse --abbrev-ref HEAD) branch_name=$(git rev-parse --abbrev-ref HEAD)
if [[ "$branch_name" =~ ^[0-9]+\.([0-9]+|x) ]]; then if [[ "$branch_name" =~ ^[0-9]+\.[0-9]+ ]]; then
echo -e "\033[36;1mTARGET: codegen -> No VERSION argument found, using branch name: \`$branch_name\`\033[0m" echo -e "\033[36;1mTARGET: codegen -> No VERSION argument found, using branch name: \`$branch_name\`\033[0m"
VERSION="$branch_name" VERSION="$branch_name"
else else
@ -121,9 +121,9 @@ bumpmatrix)
echo -e "\t $0 bump \$VERSION" echo -e "\t $0 bump \$VERSION"
echo -e "\t $0 codegen \$VERSION" echo -e "\t $0 codegen \$VERSION"
exit 1 exit 1
;;
esac esac
# ------------------------------------------------------- # # ------------------------------------------------------- #
# Build Container # Build Container
# ------------------------------------------------------- # # ------------------------------------------------------- #

26
.github/stale.yml vendored Normal file
View File

@ -0,0 +1,26 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 15
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- "discussion"
- "feature request"
- "bug"
- "todo"
- "good first issue"
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: |
We understand that this might be important for you, but this issue has been automatically marked as stale because it has not had recent activity either from our end or yours.
It will be closed if no further activity occurs, please write a comment if you would like to keep this going.
Note: in the past months we have built a new client, that has just landed in master. If you want to open an issue or a pr for the legacy client, you should do that in https://github.com/elastic/elasticsearch-js-legacy
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

18
.github/workflows/auto-merge.yml vendored Normal file
View File

@ -0,0 +1,18 @@
name: Automerge
on:
pull_request_review:
types:
- submitted
jobs:
automerge:
runs-on: ubuntu-latest
if: github.event.review.state == 'approved'
steps:
- uses: reitermarkus/automerge@v2
with:
token: ${{ secrets.GH_TOKEN }}
merge-method: squash
pull-request-author-associations: OWNER
review-author-associations: OWNER,CONTRIBUTOR

View File

@ -1,19 +0,0 @@
name: docs-build
on:
push:
branches:
- main
pull_request_target: ~
merge_group: ~
jobs:
docs-preview:
uses: elastic/docs-builder/.github/workflows/preview-build.yml@main
with:
path-pattern: docs/**
permissions:
deployments: write
id-token: write
contents: read
pull-requests: read

View File

@ -1,14 +0,0 @@
name: docs-cleanup
on:
pull_request_target:
types:
- closed
jobs:
docs-preview:
uses: elastic/docs-builder/.github/workflows/preview-cleanup.yml@main
permissions:
contents: none
id-token: write
deployments: write

View File

@ -11,10 +11,8 @@ jobs:
outputs: outputs:
src-only: "${{ steps.changes.outputs.src-only }}" src-only: "${{ steps.changes.outputs.src-only }}"
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - uses: actions/checkout@v4
with: - uses: dorny/paths-filter/@v2.11.1
persist-credentials: false
- uses: dorny/paths-filter/@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes id: changes
with: with:
filters: | filters: |
@ -32,16 +30,14 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
node-version: [18.x, 20.x, 22.x, 23.x] node-version: [18.x, 20.x, 22.x]
os: [ubuntu-latest, windows-latest, macOS-latest] os: [ubuntu-latest, windows-latest, macOS-latest]
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
@ -57,21 +53,15 @@ jobs:
run: | run: |
npm run test:unit npm run test:unit
- name: ECMAScript module test
run: |
npm run test:esm
license: license:
name: License check name: License check
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js - name: Use Node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4 uses: actions/setup-node@v4
with: with:
node-version: 22.x node-version: 22.x
@ -83,38 +73,12 @@ jobs:
run: | run: |
npm run license-checker npm run license-checker
test-bun: auto-approve:
name: Test Bun name: Auto-approve
runs-on: ${{ matrix.os }} needs: [test, license]
needs: paths-filter runs-on: ubuntu-latest
# only run if code relevant to unit tests was changed permissions:
if: needs.paths-filter.outputs.src-only == 'true' pull-requests: write
if: github.actor == 'elasticmachine'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - uses: hmarr/auto-approve-action@v4
with:
persist-credentials: false
- name: Use Bun
uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2
- name: Install
run: |
bun install
- name: Lint
run: |
bun run lint
- name: Unit test
run: |
bun run test:unit-bun
- name: ECMAScript module test
run: |
bun run test:esm

View File

@ -9,52 +9,29 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write contents: read
id-token: write id-token: write
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - uses: actions/checkout@v4
with: with:
persist-credentials: false
ref: ${{ github.event.inputs.branch }} ref: ${{ github.event.inputs.branch }}
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4 - uses: actions/setup-node@v3
with: with:
node-version: "22.x" node-version: "20.x"
registry-url: "https://registry.npmjs.org" registry-url: "https://registry.npmjs.org"
- run: npm install -g npm - run: npm install -g npm
- run: npm install - run: npm install
- run: npm test - run: npm test
- name: npm publish - run: npm publish --provenance --access public
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: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish version on GitHub - run: |
run: |
version=$(jq -r .version package.json) version=$(jq -r .version package.json)
tag_meta=$(echo "$version" | cut -s -d '-' -f2)
if [[ -z "$tag_meta" ]]; then
gh release create \ gh release create \
-n "[Changelog](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/$BRANCH_NAME/changelog-client.html)" -n "[Changelog](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/$BRANCH_NAME/changelog-client.html)" \
--target "$BRANCH_NAME" \ --target "$BRANCH_NAME" \
--title "v$version" \ -t "v$version" \
"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: env:
BRANCH_NAME: ${{ github.event.inputs.branch }} BRANCH_NAME: ${{ github.event.inputs.branch }}
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}

43
.github/workflows/serverless-patch.sh vendored Executable file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -exuo pipefail
merge_commit_sha=$(jq -r '.pull_request.merge_commit_sha' "$GITHUB_EVENT_PATH")
pull_request_id=$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH")
pr_shortcode="elastic/elasticsearch-js#$pull_request_id"
# generate patch file
cd "$GITHUB_WORKSPACE/stack"
git format-patch -1 --stdout "$merge_commit_sha" > /tmp/patch.diff
# set committer info
git config --global user.email "elasticmachine@users.noreply.github.com"
git config --global user.name "Elastic Machine"
# apply patch file
cd "$GITHUB_WORKSPACE/serverless"
git am -C1 --reject /tmp/patch.diff || git am --quit
# generate PR body comment
comment="Patch applied from $pr_shortcode"
# enumerate rejected patches in PR comment
has_rejects='false'
for f in ./**/*.rej; do
has_rejects='true'
comment="$comment
## Rejected patch \`$f\` must be resolved:
\`\`\`diff
$(cat "$f")
\`\`\`
"
done
# delete .rej files
rm -fv ./**/*.rej
# send data to output parameters
echo "$comment" > /tmp/pr_body
echo "PR_DRAFT=$has_rejects" >> "$GITHUB_OUTPUT"

51
.github/workflows/serverless-patch.yml vendored Normal file
View File

@ -0,0 +1,51 @@
---
name: Apply PR changes to serverless
on:
pull_request_target:
types:
- closed
- labeled
jobs:
apply-patch:
name: Apply patch
runs-on: ubuntu-latest
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
github.event.pull_request.merged
&& (
(
github.event.action == 'closed'
&& contains(github.event.pull_request.labels.*.name, 'apply-to-serverless')
)
||
(
github.event.action == 'labeled'
&& github.event.label.name == 'apply-to-serverless'
)
)
steps:
- uses: actions/checkout@v4
with:
repository: elastic/elasticsearch-js
ref: main
path: stack
fetch-depth: 0
- uses: actions/checkout@v4
with:
repository: elastic/elasticsearch-serverless-js
ref: main
path: serverless
- name: Apply patch from stack to serverless
id: apply-patch
run: $GITHUB_WORKSPACE/stack/.github/workflows/serverless-patch.sh
- uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GH_TOKEN }}
path: serverless
title: 'Apply patch from elastic/elasticsearch-js#${{ github.event.pull_request.number }}'
commit-message: 'Apply patch from elastic/elasticsearch-js#${{ github.event.pull_request.number }}'
body-path: /tmp/pr_body
draft: '${{ steps.apply-patch.outputs.PR_DRAFT }}'
add-paths: ':!*.rej'

View File

@ -1,21 +1,21 @@
--- ---
name: "Close stale issues and PRs" name: 'Close stale issues and PRs'
on: on:
schedule: schedule:
- cron: "30 1 * * *" - cron: '30 1 * * *'
jobs: jobs:
stale: stale:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9 - uses: actions/stale@v8
with: with:
stale-issue-label: stale stale-issue-label: stale
stale-pr-label: stale stale-pr-label: stale
days-before-stale: 90 days-before-stale: 90
days-before-close: 14 days-before-close: 14
exempt-issue-labels: "good first issue,tracking" exempt-issue-labels: 'good first issue'
close-issue-label: closed-stale close-issue-label: closed-stale
close-pr-label: closed-stale close-pr-label: closed-stale
stale-issue-message: "This issue is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days." stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days.'
stale-pr-message: "This pull request is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days." stale-pr-message: 'This pull request is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days.'

View File

@ -28,9 +28,6 @@ spec:
spec: spec:
repository: elastic/elasticsearch-js repository: elastic/elasticsearch-js
pipeline_file: .buildkite/pipeline.yml pipeline_file: .buildkite/pipeline.yml
env:
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
SLACK_NOTIFICATIONS_CHANNEL: "#devtools-notify-javascript"
teams: teams:
devtools-team: devtools-team:
access_level: MANAGE_BUILD_AND_READ access_level: MANAGE_BUILD_AND_READ
@ -45,12 +42,6 @@ spec:
main: main:
branch: "main" branch: "main"
cronline: "@daily" cronline: "@daily"
8_x: 8_14:
branch: "8.x" branch: "8.14"
cronline: "@daily"
8_17:
branch: "8.17"
cronline: "@daily"
8_18:
branch: "8.18"
cronline: "@daily" cronline: "@daily"

View File

@ -13,6 +13,7 @@ const client = new Client({
cloud: { id: '<cloud-id>' }, cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }, auth: { apiKey: 'base64EncodedKey' },
maxRetries: 5, maxRetries: 5,
requestTimeout: 60000,
sniffOnStart: true sniffOnStart: true
}) })
---- ----
@ -81,7 +82,7 @@ _Default:_ `3`
|`requestTimeout` |`requestTimeout`
|`number` - Max request timeout in milliseconds for each request. + |`number` - Max request timeout in milliseconds for each request. +
_Default:_ No value _Default:_ `30000`
|`pingTimeout` |`pingTimeout`
|`number` - Max ping request timeout in milliseconds for each request. + |`number` - Max ping request timeout in milliseconds for each request. +
@ -251,8 +252,8 @@ const client = new Client({
---- ----
|`disablePrototypePoisoningProtection` |`disablePrototypePoisoningProtection`
|`boolean`, `'proto'`, `'constructor'` - The client can protect you against prototype poisoning attacks. Read https://web.archive.org/web/20200319091159/https://hueniverse.com/square-brackets-are-the-enemy-ff5b9fd8a3e8?gi=184a27ee2a08[this article] 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` https://github.com/fastify/secure-json-parse[documentation] to learn more. + |`boolean`, `'proto'`, `'constructor'` - By the default the client will protect you against prototype poisoning attacks. Read https://web.archive.org/web/20200319091159/https://hueniverse.com/square-brackets-are-the-enemy-ff5b9fd8a3e8?gi=184a27ee2a08[this article] to learn more. If needed you can disable prototype poisoning protection entirely or one of the two checks. Read the `secure-json-parse` https://github.com/fastify/secure-json-parse[documentation] to learn more. +
_Default:_ `true` _Default:_ `false`
|`caFingerprint` |`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. + |`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. +

View File

@ -1,129 +1,6 @@
[[changelog-client]] [[changelog-client]]
== Release notes == Release notes
[discrete]
=== 9.0.0
[discrete]
==== Breaking changes
[discrete]
===== Drop support for deprecated `body` parameter
In 8.0, the top-level `body` parameter that was available on all API functions <<remove-body-key,was deprecated>>. In 9.0 this property is completely removed.
[discrete]
===== Remove the default 30-second timeout on all requests sent to Elasticsearch
Setting HTTP timeouts on Elasticsearch requests goes against Elastic's recommendations. See <<timeout-best-practices>> for more information.
[discrete]
=== 8.17.1
[discrete]
==== Fixes
[discrete]
===== Improved support for Elasticsearch `v8.17`
Updated TypeScript types based on fixes and improvements to the Elasticsearch specification.
[discrete]
===== Report correct transport connection type in telemetry
The client's telemetry reporting mechanism was incorrectly reporting all traffic as using `HttpConnection` when the default is `UndiciConnection`. https://github.com/elastic/elasticsearch-js/issues/2324[#2324]
[discrete]
=== 8.17.0
[discrete]
==== Features
[discrete]
===== Support for Elasticsearch `v8.17`
You can find all the API changes
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/release-notes-8.17.0.html[here].
[discrete]
=== 8.16.4
[discrete]
==== Fixes
[discrete]
===== Improved support for Elasticsearch `v8.16`
Updated TypeScript types based on fixes and improvements to the Elasticsearch specification.
[discrete]
===== Report correct transport connection type in telemetry
The client's telemetry reporting mechanism was incorrectly reporting all traffic as using `HttpConnection` when the default is `UndiciConnection`. https://github.com/elastic/elasticsearch-js/issues/2324[#2324]
[discrete]
=== 8.16.3
[discrete]
==== Fixes
[discrete]
===== Improved support for Elasticsearch `v8.16`
Updated TypeScript types based on fixes and improvements to the Elasticsearch specification.
[discrete]
=== 8.16.2
[discrete]
==== Fixes
[discrete]
===== Improved support for Elasticsearch `v8.16`
Updated TypeScript types based on fixes and improvements to the Elasticsearch specification.
[discrete]
===== Drop testing artifacts from npm package
Tap, the unit testing tool used by this project, was recently upgraded and started writing to a `.tap` directory. Since tests are run prior to an `npm publish` in CI, this directory was being included in the published package and bloating its size.
[discrete]
=== 8.16.1
[discrete]
==== Fixes
[discrete]
===== Fix ECMAScript imports
Fixed package configuration to correctly support native ECMAScript `import` syntax.
[discrete]
=== 8.16.0
[discrete]
==== Features
[discrete]
===== Support for Elasticsearch `v8.16`
You can find all the API changes
https://www.elastic.co/guide/en/elasticsearch/reference/8.16/release-notes-8.16.0.html[here].
[discrete]
===== Support Apache Arrow in ES|QL helper
The ES|QL helper can now return results as an Apache Arrow `Table` or `RecordBatchReader`, which enables high-performance calculations on ES|QL results, even if the response data is larger than the system's available memory. See <<esql-helper>> for more information.
[discrete]
==== Fixes
[discrete]
===== Pass prototype poisoning options to serializer correctly
The client's `disablePrototypePoisoningProtection` option was set to `true` by default, but when it was set to any other value it was ignored, making it impossible to enable prototype poisoning protection without providing a custom serializer implementation.
[discrete] [discrete]
=== 8.15.3 === 8.15.3
@ -716,7 +593,6 @@ ac.abort()
---- ----
[discrete] [discrete]
[[remove-body-key]]
===== Remove the body key from the request ===== Remove the body key from the request
*Breaking: Yes* | *Migration effort: Small* *Breaking: Yes* | *Migration effort: Small*

View File

@ -28,6 +28,7 @@ const client = new Client({
}) })
const child = client.child({ const child = client.child({
headers: { 'x-foo': 'bar' }, headers: { 'x-foo': 'bar' },
requestTimeout: 1000
}) })
client.info().then(console.log, console.log) client.info().then(console.log, console.log)

View File

@ -349,7 +349,7 @@ In this case, the result will be:
body: object | boolean body: object | boolean
statusCode: number statusCode: number
headers: object headers: object
warnings: string[], warnings: [string],
meta: object meta: object
} }
---- ----
@ -410,23 +410,19 @@ The supported request specific options are:
[cols=2*] [cols=2*]
|=== |===
|`ignore` |`ignore`
|`number[]` - HTTP status codes which should not be considered errors for this request. + |`[number]` - HTTP status codes which should not be considered errors for this request. +
_Default:_ `null` _Default:_ `null`
|`requestTimeout` |`requestTimeout`
|`number | string | null` - Max request timeout for the request in milliseconds. This overrides the client default, which is to not time out at all. See https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html#_http_client_configuration[Elasticsearch best practices for HTML clients] for more info. + |`number` - Max request timeout for the request in milliseconds, it overrides the client default. +
_Default:_ No timeout _Default:_ `30000`
|`retryOnTimeout`
|`boolean` - Retry requests that have timed out.
_Default:_ `false`
|`maxRetries` |`maxRetries`
|`number` - Max number of retries for the request, it overrides the client default. + |`number` - Max number of retries for the request, it overrides the client default. +
_Default:_ `3` _Default:_ `3`
|`compression` |`compression`
|`string | boolean` - Enables body compression for the request. + |`string, boolean` - Enables body compression for the request. +
_Options:_ `false`, `'gzip'` + _Options:_ `false`, `'gzip'` +
_Default:_ `false` _Default:_ `false`
@ -450,10 +446,6 @@ _Default:_ `null`
|`any` - Custom object per request. _(you can use it to pass data to the clients events)_ + |`any` - Custom object per request. _(you can use it to pass data to the clients events)_ +
_Default:_ `null` _Default:_ `null`
|`opaqueId`
|`string` - Set the `X-Opaque-Id` HTTP header. See {ref}/api-conventions.html#x-opaque-id
_Default:_ `null`
|`maxResponseSize` |`maxResponseSize`
|`number` - When configured, it verifies that the uncompressed response size is lower than the configured number, if it's higher it will abort the request. It cannot be higher than buffer.constants.MAX_STRING_LENTGH + |`number` - When configured, it verifies that the uncompressed response size is lower than the configured number, if it's higher it will abort the request. It cannot be higher than buffer.constants.MAX_STRING_LENTGH +
_Default:_ `null` _Default:_ `null`
@ -466,17 +458,6 @@ _Default:_ `null`
|`AbortSignal` - The AbortSignal instance to allow request abortion. + |`AbortSignal` - The AbortSignal instance to allow request abortion. +
_Default:_ `null` _Default:_ `null`
|`meta`
|`boolean` - Rather than returning the body, return an object containing `body`, `statusCode`, `headers` and `meta` keys +
_Default_: `false`
|`redaction`
|`object` - Options for redacting potentially sensitive data from error metadata. See <<redaction>>.
|`retryBackoff`
|`(min: number, max: number, attempt: number) => number;` - A function that calculates how long to sleep, in seconds, before the next request retry +
_Default:_ A built-in function that uses exponential backoff with jitter.
|=== |===
[discrete] [discrete]

View File

@ -1,11 +0,0 @@
// 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.getDataStream({
name: "my-data-stream",
filter_path: "data_streams.indices.index_name",
});
console.log(response);
----

View File

@ -1,15 +0,0 @@
// 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.putSettings({
index: ".reindexed-v9-ml-anomalies-custom-example",
settings: {
index: {
number_of_replicas: "<original_number_of_replicas>",
},
},
});
console.log(response);
----

View File

@ -1,11 +0,0 @@
// 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.addBlock({
index: ".ml-anomalies-custom-example",
block: "read_only",
});
console.log(response);
----

View File

@ -1,19 +0,0 @@
// 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.queryRole({
query: {
bool: {
must_not: {
term: {
"metadata._reserved": true,
},
},
},
},
sort: ["name"],
});
console.log(response);
----

View File

@ -1,11 +0,0 @@
// 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.addBlock({
index: ".ml-anomalies-custom-example",
block: "write",
});
console.log(response);
----

View File

@ -1,23 +0,0 @@
// 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: "test-index",
mappings: {
properties: {
source_field: {
type: "text",
fields: {
infer_field: {
type: "semantic_text",
inference_id: ".elser-2-elasticsearch",
},
},
},
},
},
});
console.log(response);
----

View File

@ -1,28 +0,0 @@
// 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.search({
index: "my-index-*",
query: {
bool: {
must: [
{
match: {
"user.id": "kimchy",
},
},
],
must_not: [
{
terms: {
_index: ["my-index-01"],
},
},
],
},
},
});
console.log(response);
----

View File

@ -1,31 +0,0 @@
// 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.ilm.putLifecycle({
name: "my_policy",
policy: {
phases: {
hot: {
actions: {
rollover: {
max_primary_shard_size: "50gb",
},
searchable_snapshot: {
snapshot_repository: "backing_repo",
replicate_for: "14d",
},
},
},
delete: {
min_age: "28d",
actions: {
delete: {},
},
},
},
},
});
console.log(response);
----

View File

@ -6,7 +6,6 @@
const response = await client.indices.resolveCluster({ const response = await client.indices.resolveCluster({
name: "not-present,clust*:my-index*,oldcluster:*", name: "not-present,clust*:my-index*,oldcluster:*",
ignore_unavailable: "false", ignore_unavailable: "false",
timeout: "5s",
}); });
console.log(response); console.log(response);
---- ----

View File

@ -1,23 +0,0 @@
// 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: "my-index",
settings: {
index: {
number_of_shards: 3,
"blocks.write": true,
},
},
mappings: {
properties: {
field1: {
type: "text",
},
},
},
});
console.log(response);
----

View File

@ -9,13 +9,10 @@ const response = await client.search({
retriever: { retriever: {
rescorer: { rescorer: {
rescore: { rescore: {
window_size: 50,
query: { query: {
window_size: 50,
rescore_query: { rescore_query: {
script_score: { script_score: {
query: {
match_all: {},
},
script: { script: {
source: source:
"cosineSimilarity(params.queryVector, 'product-vector_final_stage') + 1.0", "cosineSimilarity(params.queryVector, 'product-vector_final_stage') + 1.0",

View File

@ -0,0 +1,23 @@
// 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.bulk({
index: "test-index",
operations: [
{
update: {
_id: "1",
},
},
{
doc: {
infer_field: "updated inference field",
source_field: "updated source field",
},
},
],
});
console.log(response);
----

View File

@ -1,19 +0,0 @@
// 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.search({
index: ".ml-anomalies-custom-example",
size: 0,
aggs: {
job_ids: {
terms: {
field: "job_id",
size: 100,
},
},
},
});
console.log(response);
----

View File

@ -1,61 +0,0 @@
// 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.search({
index: "retrievers_example",
retriever: {
linear: {
retrievers: [
{
retriever: {
standard: {
query: {
function_score: {
query: {
term: {
topic: "ai",
},
},
functions: [
{
script_score: {
script: {
source: "doc['timestamp'].value.millis",
},
},
},
],
boost_mode: "replace",
},
},
sort: {
timestamp: {
order: "asc",
},
},
},
},
weight: 2,
normalizer: "minmax",
},
{
retriever: {
knn: {
field: "vector",
query_vector: [0.23, 0.67, 0.89],
k: 3,
num_candidates: 5,
},
},
weight: 1.5,
},
],
rank_window_size: 10,
},
},
_source: false,
});
console.log(response);
----

View File

@ -6,11 +6,15 @@
const response = await client.update({ const response = await client.update({
index: "test", index: "test",
id: 1, id: 1,
doc: { script: {
product_price: 100, source: "ctx._source.counter += params.count",
lang: "painless",
params: {
count: 4,
},
}, },
upsert: { upsert: {
product_price: 50, counter: 1,
}, },
}); });
console.log(response); console.log(response);

View File

@ -1,17 +0,0 @@
// 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.inference.put({
task_type: "sparse_embedding",
inference_id: "elser-model-eis",
inference_config: {
service: "elastic",
service_settings: {
model_name: "elser",
},
},
});
console.log(response);
----

View File

@ -1,12 +0,0 @@
// 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.cluster.putSettings({
persistent: {
"migrate.data_stream_reindex_max_request_per_second": 10000,
},
});
console.log(response);
----

View File

@ -1,10 +0,0 @@
// 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.getSettings({
index: ".reindexed-v9-ml-anomalies-custom-example",
});
console.log(response);
----

View File

@ -1,23 +0,0 @@
// 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.search({
index: "test-index",
query: {
match: {
my_semantic_field: "Which country is Paris in?",
},
},
highlight: {
fields: {
my_semantic_field: {
number_of_fragments: 2,
order: "score",
},
},
},
});
console.log(response);
----

View File

@ -1,16 +0,0 @@
// 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.reindex({
wait_for_completion: "false",
source: {
index: ".ml-anomalies-custom-example",
},
dest: {
index: ".reindexed-v9-ml-anomalies-custom-example",
},
});
console.log(response);
----

View File

@ -1,15 +0,0 @@
// 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.putSettings({
index: ".reindexed-v9-ml-anomalies-custom-example",
settings: {
index: {
number_of_replicas: 0,
},
},
});
console.log(response);
----

View File

@ -1,12 +0,0 @@
// 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.query({
query:
'\nFROM library\n| EVAL year = DATE_EXTRACT("year", release_date)\n| WHERE page_count > ? AND match(author, ?, {"minimum_should_match": ?})\n| LIMIT 5\n',
params: [300, "Frank Herbert", 2],
});
console.log(response);
----

View File

@ -3,8 +3,8 @@
[source, js] [source, js]
---- ----
const response = await client.migration.deprecations({ const response = await client.security.queryRole({
index: ".ml-anomalies-*", sort: ["name"],
}); });
console.log(response); console.log(response);
---- ----

View File

@ -1,10 +0,0 @@
// 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.getAlias({
index: ".ml-anomalies-custom-example",
});
console.log(response);
----

View File

@ -7,14 +7,14 @@ const response = await client.indices.create({
index: "test-index", index: "test-index",
mappings: { mappings: {
properties: { properties: {
source_field: {
type: "text",
copy_to: "infer_field",
},
infer_field: { infer_field: {
type: "semantic_text", type: "semantic_text",
inference_id: ".elser-2-elasticsearch", inference_id: ".elser-2-elasticsearch",
}, },
source_field: {
type: "text",
copy_to: "infer_field",
},
}, },
}, },
}); });

View File

@ -30,13 +30,6 @@ const response = await client.search({
], ],
}, },
}, },
highlight: {
fields: {
semantic_text: {
number_of_fragments: 2,
},
},
},
}); });
console.log(response); console.log(response);
---- ----

View File

@ -1,12 +0,0 @@
// 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.cat.indices({
index: ".ml-anomalies-custom-example",
v: "true",
h: "index,store.size",
});
console.log(response);
----

View File

@ -1,12 +0,0 @@
// 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.get({
index: ".migrated-ds-my-data-stream-2025.01.23-000001",
human: "true",
filter_path: "*.settings.index.version.created_string",
});
console.log(response);
----

View File

@ -5,9 +5,6 @@
---- ----
const response = await client.indices.create({ const response = await client.indices.create({
index: "retrievers_example_nested", index: "retrievers_example_nested",
settings: {
number_of_shards: 1,
},
mappings: { mappings: {
properties: { properties: {
nested_field: { nested_field: {
@ -21,9 +18,6 @@ const response = await client.indices.create({
dims: 3, dims: 3,
similarity: "l2_norm", similarity: "l2_norm",
index: true, index: true,
index_options: {
type: "flat",
},
}, },
}, },
}, },

View File

@ -1,11 +0,0 @@
// 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.query({
query:
'\nFROM library\n| WHERE match(author, "Frank Herbert", {"minimum_should_match": 2, "operator": "AND"})\n| LIMIT 5\n',
});
console.log(response);
----

View File

@ -6,13 +6,13 @@
const response = await client.indices.create({ const response = await client.indices.create({
index: "test-index", index: "test-index",
query: { query: {
match: { semantic: {
my_field: "Which country is Paris in?", field: "my_semantic_field",
}, },
}, },
highlight: { highlight: {
fields: { fields: {
my_field: { my_semantic_field: {
type: "semantic", type: "semantic",
number_of_fragments: 2, number_of_fragments: 2,
order: "score", order: "score",

View File

@ -1,11 +0,0 @@
// 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.cluster.state({
metric: "metadata",
filter_path: "metadata.indices.*.system",
});
console.log(response);
----

View File

@ -1,44 +0,0 @@
// 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.search({
index: "retrievers_example",
retriever: {
linear: {
retrievers: [
{
retriever: {
standard: {
query: {
query_string: {
query: "(information retrieval) OR (artificial intelligence)",
default_field: "text",
},
},
},
},
weight: 2,
normalizer: "minmax",
},
{
retriever: {
knn: {
field: "vector",
query_vector: [0.23, 0.67, 0.89],
k: 3,
num_candidates: 5,
},
},
weight: 1.5,
normalizer: "minmax",
},
],
rank_window_size: 10,
},
},
_source: false,
});
console.log(response);
----

View File

@ -1,17 +0,0 @@
// 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.inference.put({
task_type: "chat_completion",
inference_id: "chat-completion-endpoint",
inference_config: {
service: "elastic",
service_settings: {
model_id: "model-1",
},
},
});
console.log(response);
----

View File

@ -1,57 +0,0 @@
// 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.updateAliases({
actions: [
{
add: {
index: ".reindexed-v9-ml-anomalies-custom-example",
alias: ".ml-anomalies-example1",
filter: {
term: {
job_id: {
value: "example1",
},
},
},
is_hidden: true,
},
},
{
add: {
index: ".reindexed-v9-ml-anomalies-custom-example",
alias: ".ml-anomalies-example2",
filter: {
term: {
job_id: {
value: "example2",
},
},
},
is_hidden: true,
},
},
{
remove: {
index: ".ml-anomalies-custom-example",
aliases: ".ml-anomalies-*",
},
},
{
remove_index: {
index: ".ml-anomalies-custom-example",
},
},
{
add: {
index: ".reindexed-v9-ml-anomalies-custom-example",
alias: ".ml-anomalies-custom-example",
is_hidden: true,
},
},
],
});
console.log(response);
----

View File

@ -5,9 +5,6 @@
---- ----
const response = await client.indices.create({ const response = await client.indices.create({
index: "retrievers_example", index: "retrievers_example",
settings: {
number_of_shards: 1,
},
mappings: { mappings: {
properties: { properties: {
vector: { vector: {
@ -15,9 +12,6 @@ const response = await client.indices.create({
dims: 3, dims: 3,
similarity: "l2_norm", similarity: "l2_norm",
index: true, index: true,
index_options: {
type: "flat",
},
}, },
text: { text: {
type: "text", type: "text",
@ -28,9 +22,6 @@ const response = await client.indices.create({
topic: { topic: {
type: "keyword", type: "keyword",
}, },
timestamp: {
type: "date",
},
}, },
}, },
}); });
@ -44,7 +35,6 @@ const response1 = await client.index({
text: "Large language models are revolutionizing information retrieval by boosting search precision, deepening contextual understanding, and reshaping user experiences in data-rich environments.", text: "Large language models are revolutionizing information retrieval by boosting search precision, deepening contextual understanding, and reshaping user experiences in data-rich environments.",
year: 2024, year: 2024,
topic: ["llm", "ai", "information_retrieval"], topic: ["llm", "ai", "information_retrieval"],
timestamp: "2021-01-01T12:10:30",
}, },
}); });
console.log(response1); console.log(response1);
@ -57,7 +47,6 @@ const response2 = await client.index({
text: "Artificial intelligence is transforming medicine, from advancing diagnostics and tailoring treatment plans to empowering predictive patient care for improved health outcomes.", text: "Artificial intelligence is transforming medicine, from advancing diagnostics and tailoring treatment plans to empowering predictive patient care for improved health outcomes.",
year: 2023, year: 2023,
topic: ["ai", "medicine"], topic: ["ai", "medicine"],
timestamp: "2022-01-01T12:10:30",
}, },
}); });
console.log(response2); console.log(response2);
@ -70,7 +59,6 @@ const response3 = await client.index({
text: "AI is redefining security by enabling advanced threat detection, proactive risk analysis, and dynamic defenses against increasingly sophisticated cyber threats.", text: "AI is redefining security by enabling advanced threat detection, proactive risk analysis, and dynamic defenses against increasingly sophisticated cyber threats.",
year: 2024, year: 2024,
topic: ["ai", "security"], topic: ["ai", "security"],
timestamp: "2023-01-01T12:10:30",
}, },
}); });
console.log(response3); console.log(response3);
@ -83,7 +71,6 @@ const response4 = await client.index({
text: "Elastic introduces Elastic AI Assistant, the open, generative AI sidekick powered by ESRE to democratize cybersecurity and enable users of every skill level.", text: "Elastic introduces Elastic AI Assistant, the open, generative AI sidekick powered by ESRE to democratize cybersecurity and enable users of every skill level.",
year: 2023, year: 2023,
topic: ["ai", "elastic", "assistant"], topic: ["ai", "elastic", "assistant"],
timestamp: "2024-01-01T12:10:30",
}, },
}); });
console.log(response4); console.log(response4);
@ -96,7 +83,6 @@ const response5 = await client.index({
text: "Learn how to spin up a deployment of our hosted Elasticsearch Service and use Elastic Observability to gain deeper insight into the behavior of your applications and systems.", text: "Learn how to spin up a deployment of our hosted Elasticsearch Service and use Elastic Observability to gain deeper insight into the behavior of your applications and systems.",
year: 2024, year: 2024,
topic: ["documentation", "observability", "elastic"], topic: ["documentation", "observability", "elastic"],
timestamp: "2025-01-01T12:10:30",
}, },
}); });
console.log(response5); console.log(response5);

View File

@ -4,7 +4,7 @@
With the {jsclient}/api-reference.html#_bulk[`bulk` API], you can perform multiple index/delete operations in a With the {jsclient}/api-reference.html#_bulk[`bulk` API], you can perform multiple index/delete operations in a
single API call. The `bulk` API significantly increases indexing speed. single API call. The `bulk` API significantly increases indexing speed.
NOTE: You can also use the <<bulk-helper,bulk helper>>. NOTE: You can also use the {jsclient}/client-helpers.html[bulk helper].
[source,js] [source,js]
---- ----

View File

@ -6,7 +6,7 @@ Check that the document `/game-of-thrones/1` exists.
NOTE: Since this API uses the `HEAD` method, the body value will be boolean. NOTE: Since this API uses the `HEAD` method, the body value will be boolean.
[source,js] [source,js]
---- ---------
'use strict' 'use strict'
const { Client } = require('@elastic/elasticsearch') const { Client } = require('@elastic/elasticsearch')
@ -34,4 +34,4 @@ async function run () {
} }
run().catch(console.log) run().catch(console.log)
---- ---------

View File

@ -6,7 +6,7 @@ The following example gets a JSON document from an index called
`game-of-thrones`, under a type called `_doc`, with id valued `'1'`. `game-of-thrones`, under a type called `_doc`, with id valued `'1'`.
[source,js] [source,js]
---- ---------
'use strict' 'use strict'
const { Client } = require('@elastic/elasticsearch') const { Client } = require('@elastic/elasticsearch')
@ -34,4 +34,4 @@ async function run () {
} }
run().catch(console.log) run().catch(console.log)
---- ---------

View File

@ -19,7 +19,7 @@ In order to use scrolling, the initial search request should specify the scroll
parameter in the query string, which tells {es} how long it should keep the parameter in the query string, which tells {es} how long it should keep the
“search context” alive. “search context” alive.
NOTE: Did you know that we provide an helper for sending scroll requests? You can find it <<scroll-search-helper,here>>. NOTE: Did you know that we provide an helper for sending scroll requests? You can find it {jsclient}/client-helpers.html[here].
[source,js] [source,js]
---- ----

View File

@ -6,7 +6,7 @@ the following example, we will index a document that also tracks how many times
a character has said the given quote, and then we will update the `times` field. a character has said the given quote, and then we will update the `times` field.
[source,js] [source,js]
---- ---------
'use strict' 'use strict'
const { Client } = require('@elastic/elasticsearch') const { Client } = require('@elastic/elasticsearch')
@ -48,12 +48,12 @@ async function run () {
run().catch(console.log) run().catch(console.log)
---- ---------
With the update API, you can also run a partial update of a document. With the update API, you can also run a partial update of a document.
[source,js] [source,js]
---- ---------
'use strict' 'use strict'
const { Client } = require('@elastic/elasticsearch') const { Client } = require('@elastic/elasticsearch')
@ -92,4 +92,4 @@ async function run () {
run().catch(console.log) run().catch(console.log)
---- ---------

View File

@ -6,7 +6,7 @@ in the index without changing the source. This is useful to pick up a new
property or some other online mapping change. property or some other online mapping change.
[source,js] [source,js]
---- ---------
'use strict' 'use strict'
const { Client } = require('@elastic/elasticsearch') const { Client } = require('@elastic/elasticsearch')
@ -57,4 +57,4 @@ async function run () {
run().catch(console.log) run().catch(console.log)
---- ---------

View File

@ -707,42 +707,3 @@ const result = await client.helpers
.esql({ query: 'FROM sample_data | LIMIT 2' }) .esql({ query: 'FROM sample_data | LIMIT 2' })
.toRecords<EventLog>() .toRecords<EventLog>()
---- ----
[discrete]
===== `toArrowReader`
~Added~ ~in~ ~`v8.16.0`~
ES|QL can return results in multiple binary formats, including https://arrow.apache.org/[Apache Arrow]'s streaming format. Because it is a very efficient format to read, it can be valuable for performing high-performance in-memory analytics. And, because the response is streamed as batches of records, it can be used to produce aggregations and other calculations on larger-than-memory data sets.
`toArrowReader` returns a https://arrow.apache.org/docs/js/classes/Arrow_dom.RecordBatchReader.html[`RecordBatchStreamReader`].
[source,ts]
----
const reader = await client.helpers
.esql({ query: 'FROM sample_data' })
.toArrowReader()
// print each record as JSON
for (const recordBatch of reader) {
for (const record of recordBatch) {
console.log(record.toJSON())
}
}
----
[discrete]
===== `toArrowTable`
~Added~ ~in~ ~`v8.16.0`~
If you would like to pull the entire data set in Arrow format but without streaming, you can use the `toArrowTable` helper to get a https://arrow.apache.org/docs/js/classes/Arrow_dom.Table.html[Table] back instead.
[source,ts]
----
const table = await client.helpers
.esql({ query: 'FROM sample_data' })
.toArrowTable()
console.log(table.toArray())
----

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,10 @@
[[timeout-best-practices]] [[timeout-best-practices]]
=== Timeout best practices === Timeout best practices
Starting in 9.0.0, this client is configured to not time out any HTTP request by default. {es} will always eventually respond to any request, even if it takes several minutes. Reissuing a request that it has not responded to yet can cause performance side effects. See the {ref}/modules-network.html#_http_client_configuration[official {es} recommendations for HTTP clients] for more information. This client is configured by default to operate like many HTTP client libraries do, by using a relatively short (30 second) timeout on all requests sent to {es}, raising a `TimeoutError` when that time period has elapsed without receiving a response. However, {es} will always eventually respond to any request, even if it takes several minutes. The {ref}/modules-network.html#_http_client_configuration[official {es} recommendation] is to disable response timeouts entirely by default.
Prior to 9.0, this client was configured by default to operate like many HTTP client libraries do, by using a relatively short (30 second) timeout on all requests sent to {es}, raising a `TimeoutError` when that time period elapsed without receiving a response. Since changing this default would be a breaking change, we won't do that until the next major release. In the meantime, here is our recommendation for properly configuring your client:
If your circumstances require you to set timeouts on Elasticsearch requests, setting the `requestTimeout` value to a millisecond value will cause this client to operate as it did prior to 9.0. * Ensure keep-alive is enabled; this is the default, so no settings need to be changed, unless you have set `agent` to `false` or provided an alternate `agent` that disables keep-alive
* If using the default `UndiciConnection`, disable request timeouts by setting `timeout` to `0`
* If using the legacy `HttpConnection`, set `timeout` to a very large number (e.g. `86400000`, or one day)

View File

@ -35,39 +35,8 @@ class MyTransport extends Transport {
==== Supported content types ==== Supported content types
Depending on the `content-type` of the response, the transport will return the body as different types: - `application/json`, in this case the transport will return a plain JavaScript object
- `text/plain`, in this case the transport will return a plain string
- `application/vnd.mapbox-vector-tile`, in this case the transport will return a Buffer
- `application/vnd.elasticsearch+json`, in this case the transport will return a plain JavaScript object
[cols="1,1"]
|===
|Content-Type |JavaScript type
|`application/json`
|`object`
|`text/plain`
|`string`
|`application/vnd.elasticsearch+json`
|`object`
|`application/vnd.mapbox-vector-tile`
|`Buffer`
|`application/vnd.apache.arrow.stream`
|`Buffer`
|`application/vnd.elasticsearch+arrow+stream`
|`Buffer`
|`application/smile`
|`Buffer`
|`application/vnd.elasticsearch+smile`
|`Buffer`
|`application/cbor`
|`Buffer`
|`application/vnd.elasticsearch+cbor`
|`Buffer`
|===

View File

@ -1,29 +1,23 @@
{ {
"name": "@elastic/elasticsearch", "name": "@elastic/elasticsearch",
"version": "9.0.0-alpha.4", "version": "8.15.3",
"versionCanary": "9.0.0-canary.0", "versionCanary": "8.15.3-canary.0",
"description": "The official Elasticsearch client for Node.js", "description": "The official Elasticsearch client for Node.js",
"main": "./index.js", "main": "index.js",
"types": "index.d.ts", "types": "index.d.ts",
"exports": { "type": "commonjs",
"require": "./index.js",
"import": "./index.js",
"types": "./index.d.ts"
},
"scripts": { "scripts": {
"test": "npm run build && npm run lint && tap", "test": "npm run build && npm run lint && tap test/unit/{*,**/*}.test.ts",
"test:unit": "npm run build && tap", "test:unit": "npm run build && tap test/unit/{*,**/*}.test.ts",
"test:unit-bun": "bun run build && bunx tap", "test:coverage-100": "npm run build && tap test/unit/{*,**/*}.test.ts --coverage --100",
"test:esm": "npm run build && cd test/esm/ && npm install && node test-import.mjs", "test:coverage-report": "npm run build && tap test/unit/{*,**/*}.test.ts --coverage && nyc report --reporter=text-lcov > coverage.lcov",
"test:coverage-100": "npm run build && tap --coverage --100", "test:coverage-ui": "npm run build && tap test/unit/{*,**/*}.test.ts --coverage --coverage-report=html",
"test:coverage-report": "npm run build && tap --coverage && nyc report --reporter=text-lcov > coverage.lcov",
"test:coverage-ui": "npm run build && tap --coverage --coverage-report=html",
"test:integration": "tsc && node test/integration/index.js", "test:integration": "tsc && node test/integration/index.js",
"lint": "ts-standard src", "lint": "ts-standard src",
"lint:fix": "ts-standard --fix 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-checker": "license-checker --production --onlyAllow='MIT;Apache-2.0;Apache1.1;ISC;BSD-3-Clause;BSD-2-Clause;0BSD'",
"prebuild": "npm run clean-build && npm run lint", "prebuild": "npm run clean-build && npm run lint",
"build": "tsc && rm lib/package.json && mv lib/src/* lib/ && rm -rf lib/src", "build": "tsc",
"clean-build": "rimraf ./lib && mkdir lib", "clean-build": "rimraf ./lib && mkdir lib",
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
@ -56,41 +50,41 @@
"node": ">=18" "node": ">=18"
}, },
"devDependencies": { "devDependencies": {
"@elastic/request-converter": "8.17.0", "@elastic/request-converter": "^8.15.2",
"@sinonjs/fake-timers": "14.0.0", "@sinonjs/fake-timers": "github:sinonjs/fake-timers#0bfffc1",
"@types/debug": "4.1.12", "@types/debug": "^4.1.7",
"@types/ms": "0.7.34", "@types/ms": "^0.7.31",
"@types/node": "22.13.5", "@types/node": "^18.19.55",
"@types/sinonjs__fake-timers": "8.1.5", "@types/sinonjs__fake-timers": "^8.1.2",
"@types/split2": "4.2.3", "@types/split2": "^3.2.1",
"@types/stoppable": "1.1.3", "@types/stoppable": "^1.1.1",
"chai": "5.2.0", "@types/tap": "^15.0.7",
"cross-zip": "4.0.1", "chai": "^4.3.7",
"desm": "1.3.1", "cross-zip": "^4.0.0",
"into-stream": "8.0.1", "desm": "^1.2.0",
"js-yaml": "4.1.0", "into-stream": "^7.0.0",
"license-checker": "25.0.1", "js-yaml": "^4.1.0",
"minimist": "1.2.8", "license-checker": "^25.0.1",
"ms": "2.1.3", "minimist": "^1.2.6",
"node-abort-controller": "3.1.1", "ms": "^2.1.3",
"node-fetch": "2.7.0", "node-abort-controller": "^3.0.1",
"ora": "5.4.1", "node-fetch": "^2.6.7",
"proxy": "1.0.2", "ora": "^5.4.1",
"rimraf": "3.0.2", "proxy": "^1.0.2",
"semver": "7.6.3", "rimraf": "^3.0.2",
"split2": "4.2.0", "semver": "^7.3.7",
"stoppable": "1.1.0", "split2": "^4.1.0",
"tap": "21.0.2", "stoppable": "^1.1.0",
"ts-node": "10.9.2", "tap": "^21.0.1",
"ts-standard": "12.0.2", "ts-node": "^10.7.0",
"typescript": "5.7.3", "ts-standard": "^11.0.0",
"workq": "3.0.0", "typescript": "^4.6.4",
"xmlbuilder2": "3.1.1", "workq": "^3.0.0",
"zx": "7.2.3" "xmlbuilder2": "^3.0.2",
"zx": "^7.2.2"
}, },
"dependencies": { "dependencies": {
"@elastic/transport": "9.0.0-alpha.1", "@elastic/transport": "^8.8.1",
"apache-arrow": "^18.0.0",
"tslib": "^2.4.0" "tslib": "^2.4.0"
}, },
"tap": { "tap": {

View File

@ -1,32 +0,0 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>elastic/renovate-config"
],
"schedule": [
"* * * * 0"
],
"packageRules": [
{
"matchDepTypes": [
"devDependencies"
],
"automerge": true,
"labels": [
"backport 8.x"
]
},
{
"matchManagers": [
"dockerfile"
],
"pinDigests": false
},
{
"matchDatasources": [
"docker"
],
"pinDigests": false
}
]
}

View File

@ -35,164 +35,31 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class AsyncSearch { export default class AsyncSearch {
transport: Transport transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) { constructor (transport: Transport) {
this.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'
]
}
}
} }
/** /**
* Delete an async search. If the asynchronous search is still running, it is cancelled. Otherwise, the saved search results are deleted. If the Elasticsearch security features are enabled, the deletion of a specific async search is restricted to: the authenticated user that submitted the original search request; users that have the `cancel_task` cluster privilege. * Deletes an async search by identifier. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. If the Elasticsearch security features are enabled, the deletion of a specific async search is restricted to: the authenticated user that submitted the original search request; users that have the `cancel_task` cluster privilege.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-async-search-submit | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/async-search.html | Elasticsearch API documentation}
*/ */
async delete (this: That, params: T.AsyncSearchDeleteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchDeleteResponse> async delete (this: That, params: T.AsyncSearchDeleteRequest | TB.AsyncSearchDeleteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchDeleteResponse>
async delete (this: That, params: T.AsyncSearchDeleteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchDeleteResponse, unknown>> async delete (this: That, params: T.AsyncSearchDeleteRequest | TB.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 | TB.AsyncSearchDeleteRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchDeleteResponse>
async delete (this: That, params: T.AsyncSearchDeleteRequest, options?: TransportRequestOptions): Promise<any> { async delete (this: That, params: T.AsyncSearchDeleteRequest | TB.AsyncSearchDeleteRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['async_search.delete'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -210,34 +77,21 @@ export default class AsyncSearch {
} }
/** /**
* Get async search results. Retrieve the results of a previously submitted asynchronous search request. If the Elasticsearch security features are enabled, access to the results of a specific async search is restricted to the user or API key that submitted it. * Retrieves the results of a previously submitted async search request given its identifier. If the Elasticsearch security features are enabled, access to the results of a specific async search is restricted to the user or API key that submitted it.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-async-search-submit | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/async-search.html | Elasticsearch API documentation}
*/ */
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchGetResponse<TDocument, TAggregations>> async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchGetResponse<TDocument, TAggregations>>
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 | TB.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 | TB.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> { async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['async_search.get'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -255,34 +109,21 @@ export default class AsyncSearch {
} }
/** /**
* Get the async search status. Get the status of a previously submitted async search request given its identifier, without retrieving search results. If the Elasticsearch security features are enabled, the access to the status of a specific async search is restricted to: * The user or API key that submitted the original async search request. * Users that have the `monitor` cluster privilege or greater privileges. * Get async search status Retrieves the status of a previously submitted async search request given its identifier, without retrieving search results. If the Elasticsearch security features are enabled, use of this API is restricted to the `monitoring_user` role.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-async-search-submit | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/async-search.html | Elasticsearch API documentation}
*/ */
async status (this: That, params: T.AsyncSearchStatusRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchStatusResponse> async status (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchStatusResponse>
async status (this: That, params: T.AsyncSearchStatusRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchStatusResponse, unknown>> async status (this: That, params: T.AsyncSearchStatusRequest | TB.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 | TB.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchStatusResponse>
async status (this: That, params: T.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<any> { async status (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['async_search.status'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -300,37 +141,32 @@ export default class AsyncSearch {
} }
/** /**
* Run an async search. When the primary sort of the results is an indexed field, shards get sorted based on minimum and maximum value that they hold for that field. Partial results become available following the sort criteria that was requested. Warning: Asynchronous search does not support scroll or search requests that include only the suggest section. By default, Elasticsearch does not allow you to store an async search response larger than 10Mb and an attempt to do this results in an error. The maximum allowed size for a stored async search response can be set by changing the `search.max_async_search_response_size` cluster level setting. * Runs a search request asynchronously. When the primary sort of the results is an indexed field, shards get sorted based on minimum and maximum value that they hold for that field, hence partial results become available following the sort criteria that was requested. Warning: Async search does not support scroll nor search requests that only include the suggest section. By default, Elasticsearch doesnt allow you to store an async search response larger than 10Mb and an attempt to do this results in an error. The maximum allowed size for a stored async search response can be set by changing the `search.max_async_search_response_size` cluster level setting.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-async-search-submit | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/async-search.html | Elasticsearch API documentation}
*/ */
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchSubmitResponse<TDocument, TAggregations>> async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchSubmitResponse<TDocument, TAggregations>>
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 | TB.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 | TB.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> { async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath, 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']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['async_search.submit'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedBody.includes(key)) { if (acceptedBody.includes(key)) {
body = body ?? {} body = body ?? {}
// @ts-expect-error
if (key === 'sort' && typeof params[key] === 'string' && params[key].includes(':')) { // eslint-disable-line if (key === 'sort' && typeof params[key] === 'string' && params[key].includes(':')) { // eslint-disable-line
// @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else { } else {
// @ts-expect-error // @ts-expect-error
@ -338,15 +174,9 @@ export default class AsyncSearch {
} }
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }

View File

@ -35,90 +35,31 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class Autoscaling { export default class Autoscaling {
transport: Transport transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) { constructor (transport: Transport) {
this.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'
]
}
}
} }
/** /**
* Delete an autoscaling policy. NOTE: This feature is designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported. * Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-autoscaling-delete-autoscaling-policy | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/autoscaling-delete-autoscaling-policy.html | Elasticsearch API documentation}
*/ */
async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AutoscalingDeleteAutoscalingPolicyResponse> async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest | TB.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AutoscalingDeleteAutoscalingPolicyResponse>
async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingDeleteAutoscalingPolicyResponse, unknown>> async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest | TB.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 | TB.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<T.AutoscalingDeleteAutoscalingPolicyResponse>
async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> { async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest | TB.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['autoscaling.delete_autoscaling_policy'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -136,35 +77,22 @@ export default class Autoscaling {
} }
/** /**
* Get the autoscaling capacity. NOTE: This feature is designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported. This API gets the current autoscaling capacity based on the configured autoscaling policy. It will return information to size the cluster appropriately to the current workload. The `required_capacity` is calculated as the maximum of the `required_capacity` result of all individual deciders that are enabled for the policy. The operator should verify that the `current_nodes` match the operators knowledge of the cluster to avoid making autoscaling decisions based on stale or incomplete information. The response contains decider-specific information you can use to diagnose how and why autoscaling determined a certain capacity was required. This information is provided for diagnosis only. Do not use this information to make autoscaling decisions. * Gets the current autoscaling capacity based on the configured autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-autoscaling-get-autoscaling-capacity | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/autoscaling-get-autoscaling-capacity.html | Elasticsearch API documentation}
*/ */
async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AutoscalingGetAutoscalingCapacityResponse> async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest | TB.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AutoscalingGetAutoscalingCapacityResponse>
async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingGetAutoscalingCapacityResponse, unknown>> async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest | TB.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 | TB.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptions): Promise<T.AutoscalingGetAutoscalingCapacityResponse>
async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptions): Promise<any> { async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest | TB.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['autoscaling.get_autoscaling_capacity'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -179,34 +107,21 @@ export default class Autoscaling {
} }
/** /**
* Get an autoscaling policy. NOTE: This feature is designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported. * Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-autoscaling-get-autoscaling-capacity | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/autoscaling-get-autoscaling-capacity.html | Elasticsearch API documentation}
*/ */
async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AutoscalingGetAutoscalingPolicyResponse> async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest | TB.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AutoscalingGetAutoscalingPolicyResponse>
async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingGetAutoscalingPolicyResponse, unknown>> async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest | TB.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 | TB.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<T.AutoscalingGetAutoscalingPolicyResponse>
async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> { async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest | TB.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['autoscaling.get_autoscaling_policy'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -224,38 +139,28 @@ export default class Autoscaling {
} }
/** /**
* Create or update an autoscaling policy. NOTE: This feature is designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported. * Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-autoscaling-put-autoscaling-policy | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/autoscaling-put-autoscaling-policy.html | Elasticsearch API documentation}
*/ */
async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AutoscalingPutAutoscalingPolicyResponse> async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest | TB.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AutoscalingPutAutoscalingPolicyResponse>
async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingPutAutoscalingPolicyResponse, unknown>> async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest | TB.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 | TB.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<T.AutoscalingPutAutoscalingPolicyResponse>
async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> { async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest | TB.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath, const acceptedBody: string[] = ['policy']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['autoscaling.put_autoscaling_policy']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: any = params.body ?? undefined let body: any = params.body ?? undefined
for (const key in params) { for (const key in params) {
if (acceptedBody.includes(key)) { if (acceptedBody.includes(key)) {
// @ts-expect-error // @ts-expect-error
body = params[key] body = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] 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

@ -35,49 +35,26 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
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 * Checks if the specified combination of method, API, parameters, and arbitrary capabilities are supported
* @see {@link https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/README.asciidoc#require-or-skip-api-capabilities | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/capabilities.html | Elasticsearch API documentation}
*/ */
export default async function CapabilitiesApi (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO> export default async function CapabilitiesApi (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
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 | TB.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 | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
export default async function CapabilitiesApi (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> { export default async function CapabilitiesApi (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = acceptedParams.capabilities const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
querystring[key] = params[key] querystring[key] = params[key]
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -35,216 +35,31 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class Ccr { export default class Ccr {
transport: Transport transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) { constructor (transport: Transport) {
this.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'
]
}
}
} }
/** /**
* Delete auto-follow patterns. Delete a collection of cross-cluster replication auto-follow patterns. * Deletes auto-follow patterns.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-delete-auto-follow-pattern | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-delete-auto-follow-pattern.html | Elasticsearch API documentation}
*/ */
async deleteAutoFollowPattern (this: That, params: T.CcrDeleteAutoFollowPatternRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrDeleteAutoFollowPatternResponse> async deleteAutoFollowPattern (this: That, params: T.CcrDeleteAutoFollowPatternRequest | TB.CcrDeleteAutoFollowPatternRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrDeleteAutoFollowPatternResponse>
async deleteAutoFollowPattern (this: That, params: T.CcrDeleteAutoFollowPatternRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrDeleteAutoFollowPatternResponse, unknown>> async deleteAutoFollowPattern (this: That, params: T.CcrDeleteAutoFollowPatternRequest | TB.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 | TB.CcrDeleteAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<T.CcrDeleteAutoFollowPatternResponse>
async deleteAutoFollowPattern (this: That, params: T.CcrDeleteAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> { async deleteAutoFollowPattern (this: That, params: T.CcrDeleteAutoFollowPatternRequest | TB.CcrDeleteAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['ccr.delete_auto_follow_pattern'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -262,30 +77,23 @@ export default class Ccr {
} }
/** /**
* Create a follower. Create a cross-cluster replication follower index that follows a specific leader index. When the API returns, the follower index exists and cross-cluster replication starts replicating operations from the leader index to the follower index. * Creates a new follower index configured to follow the referenced leader index.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-follow | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-put-follow.html | Elasticsearch API documentation}
*/ */
async follow (this: That, params: T.CcrFollowRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrFollowResponse> async follow (this: That, params: T.CcrFollowRequest | TB.CcrFollowRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrFollowResponse>
async follow (this: That, params: T.CcrFollowRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrFollowResponse, unknown>> async follow (this: That, params: T.CcrFollowRequest | TB.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 | TB.CcrFollowRequest, options?: TransportRequestOptions): Promise<T.CcrFollowResponse>
async follow (this: That, params: T.CcrFollowRequest, options?: TransportRequestOptions): Promise<any> { async follow (this: That, params: T.CcrFollowRequest | TB.CcrFollowRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath, const acceptedBody: string[] = ['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']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['ccr.follow'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -295,15 +103,9 @@ export default class Ccr {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -319,34 +121,21 @@ export default class Ccr {
} }
/** /**
* Get follower information. Get information about all cross-cluster replication follower indices. For example, the results include follower index names, leader index names, replication options, and whether the follower indices are active or paused. * Retrieves information about all follower indices, including parameters and status for each follower index
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-follow-info | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-get-follow-info.html | Elasticsearch API documentation}
*/ */
async followInfo (this: That, params: T.CcrFollowInfoRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrFollowInfoResponse> async followInfo (this: That, params: T.CcrFollowInfoRequest | TB.CcrFollowInfoRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrFollowInfoResponse>
async followInfo (this: That, params: T.CcrFollowInfoRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrFollowInfoResponse, unknown>> async followInfo (this: That, params: T.CcrFollowInfoRequest | TB.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 | TB.CcrFollowInfoRequest, options?: TransportRequestOptions): Promise<T.CcrFollowInfoResponse>
async followInfo (this: That, params: T.CcrFollowInfoRequest, options?: TransportRequestOptions): Promise<any> { async followInfo (this: That, params: T.CcrFollowInfoRequest | TB.CcrFollowInfoRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['ccr.follow_info'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -364,34 +153,21 @@ export default class Ccr {
} }
/** /**
* Get follower stats. Get cross-cluster replication follower stats. The API returns shard-level stats about the "following tasks" associated with each shard for the specified indices. * Retrieves follower stats. return shard-level stats about the following tasks associated with each shard for the specified indices.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-follow-stats | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-get-follow-stats.html | Elasticsearch API documentation}
*/ */
async followStats (this: That, params: T.CcrFollowStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrFollowStatsResponse> async followStats (this: That, params: T.CcrFollowStatsRequest | TB.CcrFollowStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrFollowStatsResponse>
async followStats (this: That, params: T.CcrFollowStatsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrFollowStatsResponse, unknown>> async followStats (this: That, params: T.CcrFollowStatsRequest | TB.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 | TB.CcrFollowStatsRequest, options?: TransportRequestOptions): Promise<T.CcrFollowStatsResponse>
async followStats (this: That, params: T.CcrFollowStatsRequest, options?: TransportRequestOptions): Promise<any> { async followStats (this: That, params: T.CcrFollowStatsRequest | TB.CcrFollowStatsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['ccr.follow_stats'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -409,30 +185,23 @@ export default class Ccr {
} }
/** /**
* Forget a follower. Remove the cross-cluster replication follower retention leases from the leader. A following index takes out retention leases on its leader index. These leases are used to increase the likelihood that the shards of the leader index retain the history of operations that the shards of the following index need to run replication. When a follower index is converted to a regular index by the unfollow API (either by directly calling the API or by index lifecycle management tasks), these leases are removed. However, removal of the leases can fail, for example when the remote cluster containing the leader index is unavailable. While the leases will eventually expire on their own, their extended existence can cause the leader index to hold more history than necessary and prevent index lifecycle management from performing some operations on the leader index. This API exists to enable manually removing the leases when the unfollow API is unable to do so. NOTE: This API does not stop replication by a following index. If you use this API with a follower index that is still actively following, the following index will add back retention leases on the leader. The only purpose of this API is to handle the case of failure to remove the following retention leases after the unfollow API is invoked. * Removes the follower retention leases from the leader.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-forget-follower | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-post-forget-follower.html | Elasticsearch API documentation}
*/ */
async forgetFollower (this: That, params: T.CcrForgetFollowerRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrForgetFollowerResponse> async forgetFollower (this: That, params: T.CcrForgetFollowerRequest | TB.CcrForgetFollowerRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrForgetFollowerResponse>
async forgetFollower (this: That, params: T.CcrForgetFollowerRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrForgetFollowerResponse, unknown>> async forgetFollower (this: That, params: T.CcrForgetFollowerRequest | TB.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 | TB.CcrForgetFollowerRequest, options?: TransportRequestOptions): Promise<T.CcrForgetFollowerResponse>
async forgetFollower (this: That, params: T.CcrForgetFollowerRequest, options?: TransportRequestOptions): Promise<any> { async forgetFollower (this: That, params: T.CcrForgetFollowerRequest | TB.CcrForgetFollowerRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath, const acceptedBody: string[] = ['follower_cluster', 'follower_index', 'follower_index_uuid', 'leader_remote_cluster']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['ccr.forget_follower'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -442,15 +211,9 @@ export default class Ccr {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -466,35 +229,22 @@ export default class Ccr {
} }
/** /**
* Get auto-follow patterns. Get cross-cluster replication auto-follow patterns. * Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-get-auto-follow-pattern-1 | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-get-auto-follow-pattern.html | Elasticsearch API documentation}
*/ */
async getAutoFollowPattern (this: That, params?: T.CcrGetAutoFollowPatternRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrGetAutoFollowPatternResponse> async getAutoFollowPattern (this: That, params?: T.CcrGetAutoFollowPatternRequest | TB.CcrGetAutoFollowPatternRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrGetAutoFollowPatternResponse>
async getAutoFollowPattern (this: That, params?: T.CcrGetAutoFollowPatternRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrGetAutoFollowPatternResponse, unknown>> async getAutoFollowPattern (this: That, params?: T.CcrGetAutoFollowPatternRequest | TB.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 | TB.CcrGetAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<T.CcrGetAutoFollowPatternResponse>
async getAutoFollowPattern (this: That, params?: T.CcrGetAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> { async getAutoFollowPattern (this: That, params?: T.CcrGetAutoFollowPatternRequest | TB.CcrGetAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['ccr.get_auto_follow_pattern'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -519,34 +269,21 @@ export default class Ccr {
} }
/** /**
* Pause an auto-follow pattern. Pause a cross-cluster replication auto-follow pattern. When the API returns, the auto-follow pattern is inactive. New indices that are created on the remote cluster and match the auto-follow patterns are ignored. You can resume auto-following with the resume auto-follow pattern API. When it resumes, the auto-follow pattern is active again and automatically configures follower indices for newly created indices on the remote cluster that match its patterns. Remote indices that were created while the pattern was paused will also be followed, unless they have been deleted or closed in the interim. * Pauses an auto-follow pattern
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-pause-auto-follow-pattern | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-pause-auto-follow-pattern.html | Elasticsearch API documentation}
*/ */
async pauseAutoFollowPattern (this: That, params: T.CcrPauseAutoFollowPatternRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrPauseAutoFollowPatternResponse> async pauseAutoFollowPattern (this: That, params: T.CcrPauseAutoFollowPatternRequest | TB.CcrPauseAutoFollowPatternRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrPauseAutoFollowPatternResponse>
async pauseAutoFollowPattern (this: That, params: T.CcrPauseAutoFollowPatternRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrPauseAutoFollowPatternResponse, unknown>> async pauseAutoFollowPattern (this: That, params: T.CcrPauseAutoFollowPatternRequest | TB.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 | TB.CcrPauseAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<T.CcrPauseAutoFollowPatternResponse>
async pauseAutoFollowPattern (this: That, params: T.CcrPauseAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> { async pauseAutoFollowPattern (this: That, params: T.CcrPauseAutoFollowPatternRequest | TB.CcrPauseAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['ccr.pause_auto_follow_pattern'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -564,34 +301,21 @@ export default class Ccr {
} }
/** /**
* Pause a follower. Pause a cross-cluster replication follower index. The follower index will not fetch any additional operations from the leader index. You can resume following with the resume follower API. You can pause and resume a follower index to change the configuration of the following task. * Pauses a follower index. The follower index will not fetch any additional operations from the leader index.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-pause-follow | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-post-pause-follow.html | Elasticsearch API documentation}
*/ */
async pauseFollow (this: That, params: T.CcrPauseFollowRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrPauseFollowResponse> async pauseFollow (this: That, params: T.CcrPauseFollowRequest | TB.CcrPauseFollowRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrPauseFollowResponse>
async pauseFollow (this: That, params: T.CcrPauseFollowRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrPauseFollowResponse, unknown>> async pauseFollow (this: That, params: T.CcrPauseFollowRequest | TB.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 | TB.CcrPauseFollowRequest, options?: TransportRequestOptions): Promise<T.CcrPauseFollowResponse>
async pauseFollow (this: That, params: T.CcrPauseFollowRequest, options?: TransportRequestOptions): Promise<any> { async pauseFollow (this: That, params: T.CcrPauseFollowRequest | TB.CcrPauseFollowRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['ccr.pause_follow'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -609,30 +333,23 @@ export default class Ccr {
} }
/** /**
* Create or update auto-follow patterns. Create a collection of cross-cluster replication auto-follow patterns for a remote cluster. Newly created indices on the remote cluster that match any of the patterns are automatically configured as follower indices. Indices on the remote cluster that were created before the auto-follow pattern was created will not be auto-followed even if they match the pattern. This API can also be used to update auto-follow patterns. NOTE: Follower indices that were configured automatically before updating an auto-follow pattern will remain unchanged even if they do not match against the new patterns. * Creates a new named collection of auto-follow patterns against a specified remote cluster. Newly created indices on the remote cluster matching any of the specified patterns will be automatically configured as follower indices.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-put-auto-follow-pattern | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-put-auto-follow-pattern.html | Elasticsearch API documentation}
*/ */
async putAutoFollowPattern (this: That, params: T.CcrPutAutoFollowPatternRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrPutAutoFollowPatternResponse> async putAutoFollowPattern (this: That, params: T.CcrPutAutoFollowPatternRequest | TB.CcrPutAutoFollowPatternRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrPutAutoFollowPatternResponse>
async putAutoFollowPattern (this: That, params: T.CcrPutAutoFollowPatternRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrPutAutoFollowPatternResponse, unknown>> async putAutoFollowPattern (this: That, params: T.CcrPutAutoFollowPatternRequest | TB.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 | TB.CcrPutAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<T.CcrPutAutoFollowPatternResponse>
async putAutoFollowPattern (this: That, params: T.CcrPutAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> { async putAutoFollowPattern (this: That, params: T.CcrPutAutoFollowPatternRequest | TB.CcrPutAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath, 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']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['ccr.put_auto_follow_pattern'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -642,15 +359,9 @@ export default class Ccr {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -666,34 +377,21 @@ export default class Ccr {
} }
/** /**
* Resume an auto-follow pattern. Resume a cross-cluster replication auto-follow pattern that was paused. The auto-follow pattern will resume configuring following indices for newly created indices that match its patterns on the remote cluster. Remote indices created while the pattern was paused will also be followed unless they have been deleted or closed in the interim. * Resumes an auto-follow pattern that has been paused
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-resume-auto-follow-pattern | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-resume-auto-follow-pattern.html | Elasticsearch API documentation}
*/ */
async resumeAutoFollowPattern (this: That, params: T.CcrResumeAutoFollowPatternRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrResumeAutoFollowPatternResponse> async resumeAutoFollowPattern (this: That, params: T.CcrResumeAutoFollowPatternRequest | TB.CcrResumeAutoFollowPatternRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrResumeAutoFollowPatternResponse>
async resumeAutoFollowPattern (this: That, params: T.CcrResumeAutoFollowPatternRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrResumeAutoFollowPatternResponse, unknown>> async resumeAutoFollowPattern (this: That, params: T.CcrResumeAutoFollowPatternRequest | TB.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 | TB.CcrResumeAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<T.CcrResumeAutoFollowPatternResponse>
async resumeAutoFollowPattern (this: That, params: T.CcrResumeAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> { async resumeAutoFollowPattern (this: That, params: T.CcrResumeAutoFollowPatternRequest | TB.CcrResumeAutoFollowPatternRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['ccr.resume_auto_follow_pattern'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -711,30 +409,23 @@ export default class Ccr {
} }
/** /**
* Resume a follower. Resume a cross-cluster replication follower index that was paused. The follower index could have been paused with the pause follower API. Alternatively it could be paused due to replication that cannot be retried due to failures during following tasks. When this API returns, the follower index will resume fetching operations from the leader index. * Resumes a follower index that has been paused
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-resume-follow | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-post-resume-follow.html | Elasticsearch API documentation}
*/ */
async resumeFollow (this: That, params: T.CcrResumeFollowRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrResumeFollowResponse> async resumeFollow (this: That, params: T.CcrResumeFollowRequest | TB.CcrResumeFollowRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrResumeFollowResponse>
async resumeFollow (this: That, params: T.CcrResumeFollowRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrResumeFollowResponse, unknown>> async resumeFollow (this: That, params: T.CcrResumeFollowRequest | TB.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 | TB.CcrResumeFollowRequest, options?: TransportRequestOptions): Promise<T.CcrResumeFollowResponse>
async resumeFollow (this: That, params: T.CcrResumeFollowRequest, options?: TransportRequestOptions): Promise<any> { async resumeFollow (this: That, params: T.CcrResumeFollowRequest | TB.CcrResumeFollowRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath, 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']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['ccr.resume_follow'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -744,15 +435,9 @@ export default class Ccr {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -768,35 +453,22 @@ export default class Ccr {
} }
/** /**
* Get cross-cluster replication stats. This API returns stats about auto-following and the same shard-level stats as the get follower stats API. * Gets all stats related to cross-cluster replication.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-stats | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-get-stats.html | Elasticsearch API documentation}
*/ */
async stats (this: That, params?: T.CcrStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrStatsResponse> async stats (this: That, params?: T.CcrStatsRequest | TB.CcrStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrStatsResponse>
async stats (this: That, params?: T.CcrStatsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrStatsResponse, unknown>> async stats (this: That, params?: T.CcrStatsRequest | TB.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 | TB.CcrStatsRequest, options?: TransportRequestOptions): Promise<T.CcrStatsResponse>
async stats (this: That, params?: T.CcrStatsRequest, options?: TransportRequestOptions): Promise<any> { async stats (this: That, params?: T.CcrStatsRequest | TB.CcrStatsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['ccr.stats'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -811,34 +483,21 @@ export default class Ccr {
} }
/** /**
* Unfollow an index. Convert a cross-cluster replication follower index to a regular index. The API stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication. The follower index must be paused and closed before you call the unfollow API. > info > Currently cross-cluster replication does not support converting an existing regular index to a follower index. Converting a follower index to a regular index is an irreversible operation. * Stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-unfollow | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/ccr-post-unfollow.html | Elasticsearch API documentation}
*/ */
async unfollow (this: That, params: T.CcrUnfollowRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrUnfollowResponse> async unfollow (this: That, params: T.CcrUnfollowRequest | TB.CcrUnfollowRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CcrUnfollowResponse>
async unfollow (this: That, params: T.CcrUnfollowRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CcrUnfollowResponse, unknown>> async unfollow (this: That, params: T.CcrUnfollowRequest | TB.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 | TB.CcrUnfollowRequest, options?: TransportRequestOptions): Promise<T.CcrUnfollowResponse>
async unfollow (this: That, params: T.CcrUnfollowRequest, options?: TransportRequestOptions): Promise<any> { async unfollow (this: That, params: T.CcrUnfollowRequest | TB.CcrUnfollowRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['ccr.unfollow'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }

View File

@ -35,48 +35,27 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
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. * Clears the search context and results for a scrolling search.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-clear-scroll | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/clear-scroll-api.html | Elasticsearch API documentation}
*/ */
export default async function ClearScrollApi (this: That, params?: T.ClearScrollRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClearScrollResponse> export default async function ClearScrollApi (this: That, params?: T.ClearScrollRequest | TB.ClearScrollRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClearScrollResponse>
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 | TB.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 | TB.ClearScrollRequest, options?: TransportRequestOptions): Promise<T.ClearScrollResponse>
export default async function ClearScrollApi (this: That, params?: T.ClearScrollRequest, options?: TransportRequestOptions): Promise<any> { export default async function ClearScrollApi (this: That, params?: T.ClearScrollRequest | TB.ClearScrollRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath, const acceptedBody: string[] = ['scroll_id']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = acceptedParams.clear_scroll const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
params = params ?? {} params = params ?? {}
@ -87,15 +66,9 @@ export default async function ClearScrollApi (this: That, params?: T.ClearScroll
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }

View File

@ -35,48 +35,27 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
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. * Closes a point-in-time.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-open-point-in-time | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/point-in-time-api.html | Elasticsearch API documentation}
*/ */
export default async function ClosePointInTimeApi (this: That, params: T.ClosePointInTimeRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClosePointInTimeResponse> export default async function ClosePointInTimeApi (this: That, params: T.ClosePointInTimeRequest | TB.ClosePointInTimeRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClosePointInTimeResponse>
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 | TB.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 | TB.ClosePointInTimeRequest, options?: TransportRequestOptions): Promise<T.ClosePointInTimeResponse>
export default async function ClosePointInTimeApi (this: That, params: T.ClosePointInTimeRequest, options?: TransportRequestOptions): Promise<any> { export default async function ClosePointInTimeApi (this: That, params: T.ClosePointInTimeRequest | TB.ClosePointInTimeRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath, const acceptedBody: string[] = ['id']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = acceptedParams.close_point_in_time const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -86,15 +65,9 @@ export default async function ClosePointInTimeApi (this: That, params: T.ClosePo
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }

View File

@ -35,229 +35,33 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class Cluster { export default class Cluster {
transport: Transport transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) { constructor (transport: Transport) {
this.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'
]
}
}
} }
/** /**
* Explain the shard allocations. Get explanations for shard allocations in the cluster. For unassigned shards, it provides an explanation for why the shard is unassigned. For assigned shards, it provides an explanation for why the shard is remaining on its current node and has not moved or rebalanced to another node. This API can be very useful when attempting to diagnose why a shard is unassigned or why a shard continues to remain on its current node when you might expect otherwise. * Provides explanations for shard allocations in the cluster.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-allocation-explain | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/cluster-allocation-explain.html | Elasticsearch API documentation}
*/ */
async allocationExplain (this: That, params?: T.ClusterAllocationExplainRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterAllocationExplainResponse> async allocationExplain (this: That, params?: T.ClusterAllocationExplainRequest | TB.ClusterAllocationExplainRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterAllocationExplainResponse>
async allocationExplain (this: That, params?: T.ClusterAllocationExplainRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterAllocationExplainResponse, unknown>> async allocationExplain (this: That, params?: T.ClusterAllocationExplainRequest | TB.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 | TB.ClusterAllocationExplainRequest, options?: TransportRequestOptions): Promise<T.ClusterAllocationExplainResponse>
async allocationExplain (this: That, params?: T.ClusterAllocationExplainRequest, options?: TransportRequestOptions): Promise<any> { async allocationExplain (this: That, params?: T.ClusterAllocationExplainRequest | TB.ClusterAllocationExplainRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath, const acceptedBody: string[] = ['current_node', 'index', 'primary', 'shard']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['cluster.allocation_explain'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
params = params ?? {} params = params ?? {}
@ -268,15 +72,9 @@ export default class Cluster {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -289,34 +87,21 @@ export default class Cluster {
} }
/** /**
* Delete component templates. Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases. * Deletes component templates. Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/indices-component-template.html | Elasticsearch API documentation}
*/ */
async deleteComponentTemplate (this: That, params: T.ClusterDeleteComponentTemplateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterDeleteComponentTemplateResponse> async deleteComponentTemplate (this: That, params: T.ClusterDeleteComponentTemplateRequest | TB.ClusterDeleteComponentTemplateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterDeleteComponentTemplateResponse>
async deleteComponentTemplate (this: That, params: T.ClusterDeleteComponentTemplateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterDeleteComponentTemplateResponse, unknown>> async deleteComponentTemplate (this: That, params: T.ClusterDeleteComponentTemplateRequest | TB.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 | TB.ClusterDeleteComponentTemplateRequest, options?: TransportRequestOptions): Promise<T.ClusterDeleteComponentTemplateResponse>
async deleteComponentTemplate (this: That, params: T.ClusterDeleteComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> { async deleteComponentTemplate (this: That, params: T.ClusterDeleteComponentTemplateRequest | TB.ClusterDeleteComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.delete_component_template'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -334,35 +119,22 @@ export default class Cluster {
} }
/** /**
* Clear cluster voting config exclusions. Remove master-eligible nodes from the voting configuration exclusion list. * Clears cluster voting config exclusions.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-post-voting-config-exclusions | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/voting-config-exclusions.html | Elasticsearch API documentation}
*/ */
async deleteVotingConfigExclusions (this: That, params?: T.ClusterDeleteVotingConfigExclusionsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterDeleteVotingConfigExclusionsResponse> async deleteVotingConfigExclusions (this: That, params?: T.ClusterDeleteVotingConfigExclusionsRequest | TB.ClusterDeleteVotingConfigExclusionsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterDeleteVotingConfigExclusionsResponse>
async deleteVotingConfigExclusions (this: That, params?: T.ClusterDeleteVotingConfigExclusionsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterDeleteVotingConfigExclusionsResponse, unknown>> async deleteVotingConfigExclusions (this: That, params?: T.ClusterDeleteVotingConfigExclusionsRequest | TB.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 | TB.ClusterDeleteVotingConfigExclusionsRequest, options?: TransportRequestOptions): Promise<T.ClusterDeleteVotingConfigExclusionsResponse>
async deleteVotingConfigExclusions (this: That, params?: T.ClusterDeleteVotingConfigExclusionsRequest, options?: TransportRequestOptions): Promise<any> { async deleteVotingConfigExclusions (this: That, params?: T.ClusterDeleteVotingConfigExclusionsRequest | TB.ClusterDeleteVotingConfigExclusionsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.delete_voting_config_exclusions'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -377,34 +149,21 @@ export default class Cluster {
} }
/** /**
* Check component templates. Returns information about whether a particular component template exists. * Returns information about whether a particular component template exist
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/indices-component-template.html | Elasticsearch API documentation}
*/ */
async existsComponentTemplate (this: That, params: T.ClusterExistsComponentTemplateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterExistsComponentTemplateResponse> async existsComponentTemplate (this: That, params: T.ClusterExistsComponentTemplateRequest | TB.ClusterExistsComponentTemplateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterExistsComponentTemplateResponse>
async existsComponentTemplate (this: That, params: T.ClusterExistsComponentTemplateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterExistsComponentTemplateResponse, unknown>> async existsComponentTemplate (this: That, params: T.ClusterExistsComponentTemplateRequest | TB.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 | TB.ClusterExistsComponentTemplateRequest, options?: TransportRequestOptions): Promise<T.ClusterExistsComponentTemplateResponse>
async existsComponentTemplate (this: That, params: T.ClusterExistsComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> { async existsComponentTemplate (this: That, params: T.ClusterExistsComponentTemplateRequest | TB.ClusterExistsComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.exists_component_template'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -422,35 +181,22 @@ export default class Cluster {
} }
/** /**
* Get component templates. Get information about component templates. * Retrieves information about component templates.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/indices-component-template.html | Elasticsearch API documentation}
*/ */
async getComponentTemplate (this: That, params?: T.ClusterGetComponentTemplateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterGetComponentTemplateResponse> async getComponentTemplate (this: That, params?: T.ClusterGetComponentTemplateRequest | TB.ClusterGetComponentTemplateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterGetComponentTemplateResponse>
async getComponentTemplate (this: That, params?: T.ClusterGetComponentTemplateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterGetComponentTemplateResponse, unknown>> async getComponentTemplate (this: That, params?: T.ClusterGetComponentTemplateRequest | TB.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 | TB.ClusterGetComponentTemplateRequest, options?: TransportRequestOptions): Promise<T.ClusterGetComponentTemplateResponse>
async getComponentTemplate (this: That, params?: T.ClusterGetComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> { async getComponentTemplate (this: That, params?: T.ClusterGetComponentTemplateRequest | TB.ClusterGetComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.get_component_template'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -475,35 +221,22 @@ export default class Cluster {
} }
/** /**
* Get cluster-wide settings. By default, it returns only settings that have been explicitly defined. * Returns cluster-wide settings. By default, it returns only settings that have been explicitly defined.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-get-settings | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/cluster-get-settings.html | Elasticsearch API documentation}
*/ */
async getSettings (this: That, params?: T.ClusterGetSettingsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterGetSettingsResponse> async getSettings (this: That, params?: T.ClusterGetSettingsRequest | TB.ClusterGetSettingsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterGetSettingsResponse>
async getSettings (this: That, params?: T.ClusterGetSettingsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterGetSettingsResponse, unknown>> async getSettings (this: That, params?: T.ClusterGetSettingsRequest | TB.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 | TB.ClusterGetSettingsRequest, options?: TransportRequestOptions): Promise<T.ClusterGetSettingsResponse>
async getSettings (this: That, params?: T.ClusterGetSettingsRequest, options?: TransportRequestOptions): Promise<any> { async getSettings (this: That, params?: T.ClusterGetSettingsRequest | TB.ClusterGetSettingsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.get_settings'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -518,35 +251,22 @@ export default class Cluster {
} }
/** /**
* Get the cluster health status. You can also use the API to get the health status of only specified data streams and indices. For data streams, the API retrieves the health status of the streams backing indices. The cluster health status is: green, yellow or red. On the shard level, a red status indicates that the specific shard is not allocated in the cluster. Yellow means that the primary shard is allocated but replicas are not. Green means that all shards are allocated. The index level status is controlled by the worst shard status. One of the main benefits of the API is the ability to wait until the cluster reaches a certain high watermark health level. The cluster status is controlled by the worst index status. * The cluster health API returns a simple status on the health of the cluster. You can also use the API to get the health status of only specified data streams and indices. For data streams, the API retrieves the health status of the streams backing indices. The cluster health status is: green, yellow or red. On the shard level, a red status indicates that the specific shard is not allocated in the cluster, yellow means that the primary shard is allocated but replicas are not, and green means that all shards are allocated. The index level status is controlled by the worst shard status. The cluster status is controlled by the worst index status.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-health | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/cluster-health.html | Elasticsearch API documentation}
*/ */
async health (this: That, params?: T.ClusterHealthRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterHealthResponse> async health (this: That, params?: T.ClusterHealthRequest | TB.ClusterHealthRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterHealthResponse>
async health (this: That, params?: T.ClusterHealthRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterHealthResponse, unknown>> async health (this: That, params?: T.ClusterHealthRequest | TB.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 | TB.ClusterHealthRequest, options?: TransportRequestOptions): Promise<T.ClusterHealthResponse>
async health (this: That, params?: T.ClusterHealthRequest, options?: TransportRequestOptions): Promise<any> { async health (this: That, params?: T.ClusterHealthRequest | TB.ClusterHealthRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.health'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -571,34 +291,21 @@ export default class Cluster {
} }
/** /**
* Get cluster info. Returns basic information about the cluster. * Returns different information about the cluster.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-info | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/cluster-info.html | Elasticsearch API documentation}
*/ */
async info (this: That, params: T.ClusterInfoRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterInfoResponse> async info (this: That, params: T.ClusterInfoRequest | TB.ClusterInfoRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterInfoResponse>
async info (this: That, params: T.ClusterInfoRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterInfoResponse, unknown>> async info (this: That, params: T.ClusterInfoRequest | TB.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 | TB.ClusterInfoRequest, options?: TransportRequestOptions): Promise<T.ClusterInfoResponse>
async info (this: That, params: T.ClusterInfoRequest, options?: TransportRequestOptions): Promise<any> { async info (this: That, params: T.ClusterInfoRequest | TB.ClusterInfoRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['target']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.info'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -616,35 +323,22 @@ export default class Cluster {
} }
/** /**
* Get the pending cluster tasks. Get information about cluster-level changes (such as create index, update mapping, allocate or fail shard) that have not yet taken effect. NOTE: This API returns a list of any pending updates to the cluster state. These are distinct from the tasks reported by the task management API which include periodic tasks and tasks initiated by the user, such as node stats, search queries, or create index requests. However, if a user-initiated task such as a create index command causes a cluster state update, the activity of this task might be reported by both task api and pending cluster tasks API. * Returns cluster-level changes (such as create index, update mapping, allocate or fail shard) that have not yet been executed. NOTE: This API returns a list of any pending updates to the cluster state. These are distinct from the tasks reported by the Task Management API which include periodic tasks and tasks initiated by the user, such as node stats, search queries, or create index requests. However, if a user-initiated task such as a create index command causes a cluster state update, the activity of this task might be reported by both task api and pending cluster tasks API.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-pending-tasks | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/cluster-pending.html | Elasticsearch API documentation}
*/ */
async pendingTasks (this: That, params?: T.ClusterPendingTasksRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterPendingTasksResponse> async pendingTasks (this: That, params?: T.ClusterPendingTasksRequest | TB.ClusterPendingTasksRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterPendingTasksResponse>
async pendingTasks (this: That, params?: T.ClusterPendingTasksRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterPendingTasksResponse, unknown>> async pendingTasks (this: That, params?: T.ClusterPendingTasksRequest | TB.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 | TB.ClusterPendingTasksRequest, options?: TransportRequestOptions): Promise<T.ClusterPendingTasksResponse>
async pendingTasks (this: That, params?: T.ClusterPendingTasksRequest, options?: TransportRequestOptions): Promise<any> { async pendingTasks (this: That, params?: T.ClusterPendingTasksRequest | TB.ClusterPendingTasksRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.pending_tasks'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -659,35 +353,22 @@ export default class Cluster {
} }
/** /**
* Update voting configuration exclusions. Update the cluster voting config exclusions by node IDs or node names. By default, if there are more than three master-eligible nodes in the cluster and you remove fewer than half of the master-eligible nodes in the cluster at once, the voting configuration automatically shrinks. If you want to shrink the voting configuration to contain fewer than three nodes or to remove half or more of the master-eligible nodes in the cluster at once, use this API to remove departing nodes from the voting configuration manually. The API adds an entry for each specified node to the clusters voting configuration exclusions list. It then waits until the cluster has reconfigured its voting configuration to exclude the specified nodes. Clusters should have no voting configuration exclusions in normal operation. Once the excluded nodes have stopped, clear the voting configuration exclusions with `DELETE /_cluster/voting_config_exclusions`. This API waits for the nodes to be fully removed from the cluster before it returns. If your cluster has voting configuration exclusions for nodes that you no longer intend to remove, use `DELETE /_cluster/voting_config_exclusions?wait_for_removal=false` to clear the voting configuration exclusions without waiting for the nodes to leave the cluster. A response to `POST /_cluster/voting_config_exclusions` with an HTTP status code of 200 OK guarantees that the node has been removed from the voting configuration and will not be reinstated until the voting configuration exclusions are cleared by calling `DELETE /_cluster/voting_config_exclusions`. If the call to `POST /_cluster/voting_config_exclusions` fails or returns a response with an HTTP status code other than 200 OK then the node may not have been removed from the voting configuration. In that case, you may safely retry the call. NOTE: Voting exclusions are required only when you remove at least half of the master-eligible nodes from a cluster in a short time period. They are not required when removing master-ineligible nodes or when removing fewer than half of the master-eligible nodes. * Updates the cluster voting config exclusions by node ids or node names.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-post-voting-config-exclusions | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/voting-config-exclusions.html | Elasticsearch API documentation}
*/ */
async postVotingConfigExclusions (this: That, params?: T.ClusterPostVotingConfigExclusionsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterPostVotingConfigExclusionsResponse> async postVotingConfigExclusions (this: That, params?: T.ClusterPostVotingConfigExclusionsRequest | TB.ClusterPostVotingConfigExclusionsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterPostVotingConfigExclusionsResponse>
async postVotingConfigExclusions (this: That, params?: T.ClusterPostVotingConfigExclusionsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterPostVotingConfigExclusionsResponse, unknown>> async postVotingConfigExclusions (this: That, params?: T.ClusterPostVotingConfigExclusionsRequest | TB.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 | TB.ClusterPostVotingConfigExclusionsRequest, options?: TransportRequestOptions): Promise<T.ClusterPostVotingConfigExclusionsResponse>
async postVotingConfigExclusions (this: That, params?: T.ClusterPostVotingConfigExclusionsRequest, options?: TransportRequestOptions): Promise<any> { async postVotingConfigExclusions (this: That, params?: T.ClusterPostVotingConfigExclusionsRequest | TB.ClusterPostVotingConfigExclusionsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.post_voting_config_exclusions'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -702,30 +383,23 @@ export default class Cluster {
} }
/** /**
* Create or update a component template. Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases. An index template can be composed of multiple component templates. To use a component template, specify it in an index templates `composed_of` list. Component templates are only applied to new data streams and indices as part of a matching index template. Settings and mappings specified directly in the index template or the create index request override any settings or mappings specified in a component template. Component templates are only used during index creation. For data streams, this includes data stream creation and the creation of a streams backing indices. Changes to component templates do not affect existing indices, including a streams backing indices. You can use C-style `/* *\/` block comments in component templates. You can include comments anywhere in the request body except before the opening curly bracket. **Applying component templates** You cannot directly apply a component template to a data stream or index. To be applied, a component template must be included in an index template's `composed_of` list. * Creates or updates a component template. Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases. An index template can be composed of multiple component templates. To use a component template, specify it in an index templates `composed_of` list. Component templates are only applied to new data streams and indices as part of a matching index template. Settings and mappings specified directly in the index template or the create index request override any settings or mappings specified in a component template. Component templates are only used during index creation. For data streams, this includes data stream creation and the creation of a streams backing indices. Changes to component templates do not affect existing indices, including a streams backing indices. You can use C-style `/* *\/` block comments in component templates. You can include comments anywhere in the request body except before the opening curly bracket.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/indices-component-template.html | Elasticsearch API documentation}
*/ */
async putComponentTemplate (this: That, params: T.ClusterPutComponentTemplateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterPutComponentTemplateResponse> async putComponentTemplate (this: That, params: T.ClusterPutComponentTemplateRequest | TB.ClusterPutComponentTemplateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterPutComponentTemplateResponse>
async putComponentTemplate (this: That, params: T.ClusterPutComponentTemplateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterPutComponentTemplateResponse, unknown>> async putComponentTemplate (this: That, params: T.ClusterPutComponentTemplateRequest | TB.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 | TB.ClusterPutComponentTemplateRequest, options?: TransportRequestOptions): Promise<T.ClusterPutComponentTemplateResponse>
async putComponentTemplate (this: That, params: T.ClusterPutComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> { async putComponentTemplate (this: That, params: T.ClusterPutComponentTemplateRequest | TB.ClusterPutComponentTemplateRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath, const acceptedBody: string[] = ['template', 'version', '_meta', 'deprecated']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['cluster.put_component_template'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -735,15 +409,9 @@ export default class Cluster {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -759,30 +427,23 @@ export default class Cluster {
} }
/** /**
* Update the cluster settings. Configure and update dynamic settings on a running cluster. You can also configure dynamic settings locally on an unstarted or shut down node in `elasticsearch.yml`. Updates made with this API can be persistent, which apply across cluster restarts, or transient, which reset after a cluster restart. You can also reset transient or persistent settings by assigning them a null value. If you configure the same setting using multiple methods, Elasticsearch applies the settings in following order of precedence: 1) Transient setting; 2) Persistent setting; 3) `elasticsearch.yml` setting; 4) Default setting value. For example, you can apply a transient setting to override a persistent setting or `elasticsearch.yml` setting. However, a change to an `elasticsearch.yml` setting will not override a defined transient or persistent setting. TIP: In Elastic Cloud, use the user settings feature to configure all cluster settings. This method automatically rejects unsafe settings that could break your cluster. If you run Elasticsearch on your own hardware, use this API to configure dynamic cluster settings. Only use `elasticsearch.yml` for static cluster settings and node settings. The API doesnt require a restart and ensures a settings value is the same on all nodes. WARNING: Transient cluster settings are no longer recommended. Use persistent cluster settings instead. If a cluster becomes unstable, transient settings can clear unexpectedly, resulting in a potentially undesired cluster configuration. * Updates the cluster settings.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-settings | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/cluster-update-settings.html | Elasticsearch API documentation}
*/ */
async putSettings (this: That, params?: T.ClusterPutSettingsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterPutSettingsResponse> async putSettings (this: That, params?: T.ClusterPutSettingsRequest | TB.ClusterPutSettingsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterPutSettingsResponse>
async putSettings (this: That, params?: T.ClusterPutSettingsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterPutSettingsResponse, unknown>> async putSettings (this: That, params?: T.ClusterPutSettingsRequest | TB.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 | TB.ClusterPutSettingsRequest, options?: TransportRequestOptions): Promise<T.ClusterPutSettingsResponse>
async putSettings (this: That, params?: T.ClusterPutSettingsRequest, options?: TransportRequestOptions): Promise<any> { async putSettings (this: That, params?: T.ClusterPutSettingsRequest | TB.ClusterPutSettingsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath, const acceptedBody: string[] = ['persistent', 'transient']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['cluster.put_settings'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
params = params ?? {} params = params ?? {}
@ -793,15 +454,9 @@ export default class Cluster {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -814,35 +469,22 @@ export default class Cluster {
} }
/** /**
* Get remote cluster information. Get information about configured remote clusters. The API returns connection and endpoint information keyed by the configured remote cluster alias. > info > This API returns information that reflects current state on the local cluster. > The `connected` field does not necessarily reflect whether a remote cluster is down or unavailable, only whether there is currently an open connection to it. > Elasticsearch does not spontaneously try to reconnect to a disconnected remote cluster. > To trigger a reconnection, attempt a cross-cluster search, ES|QL cross-cluster search, or try the [resolve cluster endpoint](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-resolve-cluster). * The cluster remote info API allows you to retrieve all of the configured remote cluster information. It returns connection and endpoint information keyed by the configured remote cluster alias.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-remote-info | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/cluster-remote-info.html | Elasticsearch API documentation}
*/ */
async remoteInfo (this: That, params?: T.ClusterRemoteInfoRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterRemoteInfoResponse> async remoteInfo (this: That, params?: T.ClusterRemoteInfoRequest | TB.ClusterRemoteInfoRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterRemoteInfoResponse>
async remoteInfo (this: That, params?: T.ClusterRemoteInfoRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterRemoteInfoResponse, unknown>> async remoteInfo (this: That, params?: T.ClusterRemoteInfoRequest | TB.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 | TB.ClusterRemoteInfoRequest, options?: TransportRequestOptions): Promise<T.ClusterRemoteInfoResponse>
async remoteInfo (this: That, params?: T.ClusterRemoteInfoRequest, options?: TransportRequestOptions): Promise<any> { async remoteInfo (this: That, params?: T.ClusterRemoteInfoRequest | TB.ClusterRemoteInfoRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.remote_info'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -857,30 +499,23 @@ export default class Cluster {
} }
/** /**
* Reroute the cluster. Manually change the allocation of individual shards in the cluster. For example, a shard can be moved from one node to another explicitly, an allocation can be canceled, and an unassigned shard can be explicitly allocated to a specific node. It is important to note that after processing any reroute commands Elasticsearch will perform rebalancing as normal (respecting the values of settings such as `cluster.routing.rebalance.enable`) in order to remain in a balanced state. For example, if the requested allocation includes moving a shard from node1 to node2 then this may cause a shard to be moved from node2 back to node1 to even things out. The cluster can be set to disable allocations using the `cluster.routing.allocation.enable` setting. If allocations are disabled then the only allocations that will be performed are explicit ones given using the reroute command, and consequent allocations due to rebalancing. The cluster will attempt to allocate a shard a maximum of `index.allocation.max_retries` times in a row (defaults to `5`), before giving up and leaving the shard unallocated. This scenario can be caused by structural problems such as having an analyzer which refers to a stopwords file which doesnt exist on all nodes. Once the problem has been corrected, allocation can be manually retried by calling the reroute API with the `?retry_failed` URI query parameter, which will attempt a single retry round for these shards. * Allows to manually change the allocation of individual shards in the cluster.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-reroute | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/cluster-reroute.html | Elasticsearch API documentation}
*/ */
async reroute (this: That, params?: T.ClusterRerouteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterRerouteResponse> async reroute (this: That, params?: T.ClusterRerouteRequest | TB.ClusterRerouteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterRerouteResponse>
async reroute (this: That, params?: T.ClusterRerouteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterRerouteResponse, unknown>> async reroute (this: That, params?: T.ClusterRerouteRequest | TB.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 | TB.ClusterRerouteRequest, options?: TransportRequestOptions): Promise<T.ClusterRerouteResponse>
async reroute (this: That, params?: T.ClusterRerouteRequest, options?: TransportRequestOptions): Promise<any> { async reroute (this: That, params?: T.ClusterRerouteRequest | TB.ClusterRerouteRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath, const acceptedBody: string[] = ['commands']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['cluster.reroute'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
params = params ?? {} params = params ?? {}
@ -891,15 +526,9 @@ export default class Cluster {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -912,35 +541,22 @@ export default class Cluster {
} }
/** /**
* Get the cluster state. Get comprehensive information about the state of the cluster. The cluster state is an internal data structure which keeps track of a variety of information needed by every node, including the identity and attributes of the other nodes in the cluster; cluster-wide settings; index metadata, including the mapping and settings for each index; the location and status of every shard copy in the cluster. The elected master node ensures that every node in the cluster has a copy of the same cluster state. This API lets you retrieve a representation of this internal state for debugging or diagnostic purposes. You may need to consult the Elasticsearch source code to determine the precise meaning of the response. By default the API will route requests to the elected master node since this node is the authoritative source of cluster states. You can also retrieve the cluster state held on the node handling the API request by adding the `?local=true` query parameter. Elasticsearch may need to expend significant effort to compute a response to this API in larger clusters, and the response may comprise a very large quantity of data. If you use this API repeatedly, your cluster may become unstable. WARNING: The response is a representation of an internal data structure. Its format is not subject to the same compatibility guarantees as other more stable APIs and may change from version to version. Do not query this API using external monitoring tools. Instead, obtain the information you require using other more stable cluster APIs. * Returns a comprehensive information about the state of the cluster.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-state | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/cluster-state.html | Elasticsearch API documentation}
*/ */
async state (this: That, params?: T.ClusterStateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterStateResponse> async state (this: That, params?: T.ClusterStateRequest | TB.ClusterStateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterStateResponse>
async state (this: That, params?: T.ClusterStateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterStateResponse, unknown>> async state (this: That, params?: T.ClusterStateRequest | TB.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 | TB.ClusterStateRequest, options?: TransportRequestOptions): Promise<T.ClusterStateResponse>
async state (this: That, params?: T.ClusterStateRequest, options?: TransportRequestOptions): Promise<any> { async state (this: That, params?: T.ClusterStateRequest | TB.ClusterStateRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['metric', 'index']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.state'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -969,35 +585,22 @@ export default class Cluster {
} }
/** /**
* Get cluster statistics. Get basic index metrics (shard numbers, store size, memory usage) and information about the current nodes that form the cluster (number, roles, os, jvm versions, memory usage, cpu and installed plugins). * Returns cluster statistics. It returns basic index metrics (shard numbers, store size, memory usage) and information about the current nodes that form the cluster (number, roles, os, jvm versions, memory usage, cpu and installed plugins).
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-stats | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/cluster-stats.html | Elasticsearch API documentation}
*/ */
async stats (this: That, params?: T.ClusterStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterStatsResponse> async stats (this: That, params?: T.ClusterStatsRequest | TB.ClusterStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ClusterStatsResponse>
async stats (this: That, params?: T.ClusterStatsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ClusterStatsResponse, unknown>> async stats (this: That, params?: T.ClusterStatsRequest | TB.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 | TB.ClusterStatsRequest, options?: TransportRequestOptions): Promise<T.ClusterStatsResponse>
async stats (this: That, params?: T.ClusterStatsRequest, options?: TransportRequestOptions): Promise<any> { async stats (this: That, params?: T.ClusterStatsRequest | TB.ClusterStatsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['node_id']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['cluster.stats'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }

File diff suppressed because it is too large Load Diff

View File

@ -35,65 +35,27 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
count: {
path: [
'index'
],
body: [
'query'
],
query: [
'allow_no_indices',
'analyzer',
'analyze_wildcard',
'default_operator',
'df',
'expand_wildcards',
'ignore_throttled',
'ignore_unavailable',
'lenient',
'min_score',
'preference',
'routing',
'terminate_after',
'q'
]
}
}
/** /**
* Count search results. Get the number of documents matching a query. The query can be provided either by using a simple query string as a parameter, or by defining Query DSL within the request body. The query is optional. When no query is provided, the API uses `match_all` to count all the documents. The count API supports multi-target syntax. You can run a single count API search across multiple data streams and indices. The operation is broadcast across all shards. For each shard ID group, a replica is chosen and the search is run against it. This means that replicas increase the scalability of the count. * Returns number of documents matching a query.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-count | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/search-count.html | Elasticsearch API documentation}
*/ */
export default async function CountApi (this: That, params?: T.CountRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CountResponse> export default async function CountApi (this: That, params?: T.CountRequest | TB.CountRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CountResponse>
export default async function CountApi (this: That, params?: T.CountRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CountResponse, unknown>> export default async function CountApi (this: That, params?: T.CountRequest | TB.CountRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CountResponse, unknown>>
export default async function CountApi (this: That, params?: T.CountRequest, options?: TransportRequestOptions): Promise<T.CountResponse> export default async function CountApi (this: That, params?: T.CountRequest | TB.CountRequest, options?: TransportRequestOptions): Promise<T.CountResponse>
export default async function CountApi (this: That, params?: T.CountRequest, options?: TransportRequestOptions): Promise<any> { export default async function CountApi (this: That, params?: T.CountRequest | TB.CountRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath, const acceptedBody: string[] = ['query']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = acceptedParams.count const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
params = params ?? {} params = params ?? {}
@ -104,15 +66,9 @@ export default async function CountApi (this: That, params?: T.CountRequest, opt
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] 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

@ -35,77 +35,31 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
export default class DanglingIndices { export default class DanglingIndices {
transport: Transport transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) { constructor (transport: Transport) {
this.transport = transport this.transport = transport
this.acceptedParams = {
'dangling_indices.delete_dangling_index': {
path: [
'index_uuid'
],
body: [],
query: [
'accept_data_loss',
'master_timeout',
'timeout'
]
},
'dangling_indices.import_dangling_index': {
path: [
'index_uuid'
],
body: [],
query: [
'accept_data_loss',
'master_timeout',
'timeout'
]
},
'dangling_indices.list_dangling_indices': {
path: [],
body: [],
query: []
}
}
} }
/** /**
* Delete a dangling index. If Elasticsearch encounters index data that is absent from the current cluster state, those indices are considered to be dangling. For example, this can happen if you delete more than `cluster.indices.tombstones.size` indices while an Elasticsearch node is offline. * Deletes the specified dangling index
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-dangling-indices-delete-dangling-index | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/modules-gateway-dangling-indices.html | Elasticsearch API documentation}
*/ */
async deleteDanglingIndex (this: That, params: T.DanglingIndicesDeleteDanglingIndexRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DanglingIndicesDeleteDanglingIndexResponse> async deleteDanglingIndex (this: That, params: T.DanglingIndicesDeleteDanglingIndexRequest | TB.DanglingIndicesDeleteDanglingIndexRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DanglingIndicesDeleteDanglingIndexResponse>
async deleteDanglingIndex (this: That, params: T.DanglingIndicesDeleteDanglingIndexRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DanglingIndicesDeleteDanglingIndexResponse, unknown>> async deleteDanglingIndex (this: That, params: T.DanglingIndicesDeleteDanglingIndexRequest | TB.DanglingIndicesDeleteDanglingIndexRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DanglingIndicesDeleteDanglingIndexResponse, unknown>>
async deleteDanglingIndex (this: That, params: T.DanglingIndicesDeleteDanglingIndexRequest, options?: TransportRequestOptions): Promise<T.DanglingIndicesDeleteDanglingIndexResponse> async deleteDanglingIndex (this: That, params: T.DanglingIndicesDeleteDanglingIndexRequest | TB.DanglingIndicesDeleteDanglingIndexRequest, options?: TransportRequestOptions): Promise<T.DanglingIndicesDeleteDanglingIndexResponse>
async deleteDanglingIndex (this: That, params: T.DanglingIndicesDeleteDanglingIndexRequest, options?: TransportRequestOptions): Promise<any> { async deleteDanglingIndex (this: That, params: T.DanglingIndicesDeleteDanglingIndexRequest | TB.DanglingIndicesDeleteDanglingIndexRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index_uuid']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['dangling_indices.delete_dangling_index'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -123,34 +77,21 @@ export default class DanglingIndices {
} }
/** /**
* Import a dangling index. If Elasticsearch encounters index data that is absent from the current cluster state, those indices are considered to be dangling. For example, this can happen if you delete more than `cluster.indices.tombstones.size` indices while an Elasticsearch node is offline. * Imports the specified dangling index
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-dangling-indices-import-dangling-index | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/modules-gateway-dangling-indices.html | Elasticsearch API documentation}
*/ */
async importDanglingIndex (this: That, params: T.DanglingIndicesImportDanglingIndexRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DanglingIndicesImportDanglingIndexResponse> async importDanglingIndex (this: That, params: T.DanglingIndicesImportDanglingIndexRequest | TB.DanglingIndicesImportDanglingIndexRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DanglingIndicesImportDanglingIndexResponse>
async importDanglingIndex (this: That, params: T.DanglingIndicesImportDanglingIndexRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DanglingIndicesImportDanglingIndexResponse, unknown>> async importDanglingIndex (this: That, params: T.DanglingIndicesImportDanglingIndexRequest | TB.DanglingIndicesImportDanglingIndexRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DanglingIndicesImportDanglingIndexResponse, unknown>>
async importDanglingIndex (this: That, params: T.DanglingIndicesImportDanglingIndexRequest, options?: TransportRequestOptions): Promise<T.DanglingIndicesImportDanglingIndexResponse> async importDanglingIndex (this: That, params: T.DanglingIndicesImportDanglingIndexRequest | TB.DanglingIndicesImportDanglingIndexRequest, options?: TransportRequestOptions): Promise<T.DanglingIndicesImportDanglingIndexResponse>
async importDanglingIndex (this: That, params: T.DanglingIndicesImportDanglingIndexRequest, options?: TransportRequestOptions): Promise<any> { async importDanglingIndex (this: That, params: T.DanglingIndicesImportDanglingIndexRequest | TB.DanglingIndicesImportDanglingIndexRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index_uuid']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['dangling_indices.import_dangling_index'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -168,35 +109,22 @@ export default class DanglingIndices {
} }
/** /**
* Get the dangling indices. If Elasticsearch encounters index data that is absent from the current cluster state, those indices are considered to be dangling. For example, this can happen if you delete more than `cluster.indices.tombstones.size` indices while an Elasticsearch node is offline. Use this API to list dangling indices, which you can then import or delete. * Returns all dangling indices.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-dangling-indices-list-dangling-indices | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/modules-gateway-dangling-indices.html | Elasticsearch API documentation}
*/ */
async listDanglingIndices (this: That, params?: T.DanglingIndicesListDanglingIndicesRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DanglingIndicesListDanglingIndicesResponse> async listDanglingIndices (this: That, params?: T.DanglingIndicesListDanglingIndicesRequest | TB.DanglingIndicesListDanglingIndicesRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DanglingIndicesListDanglingIndicesResponse>
async listDanglingIndices (this: That, params?: T.DanglingIndicesListDanglingIndicesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DanglingIndicesListDanglingIndicesResponse, unknown>> async listDanglingIndices (this: That, params?: T.DanglingIndicesListDanglingIndicesRequest | TB.DanglingIndicesListDanglingIndicesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DanglingIndicesListDanglingIndicesResponse, unknown>>
async listDanglingIndices (this: That, params?: T.DanglingIndicesListDanglingIndicesRequest, options?: TransportRequestOptions): Promise<T.DanglingIndicesListDanglingIndicesResponse> async listDanglingIndices (this: That, params?: T.DanglingIndicesListDanglingIndicesRequest | TB.DanglingIndicesListDanglingIndicesRequest, options?: TransportRequestOptions): Promise<T.DanglingIndicesListDanglingIndicesResponse>
async listDanglingIndices (this: That, params?: T.DanglingIndicesListDanglingIndicesRequest, options?: TransportRequestOptions): Promise<any> { async listDanglingIndices (this: That, params?: T.DanglingIndicesListDanglingIndicesRequest | TB.DanglingIndicesListDanglingIndicesRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['dangling_indices.list_dangling_indices'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }

View File

@ -35,60 +35,25 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
}
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
delete: {
path: [
'id',
'index'
],
body: [],
query: [
'if_primary_term',
'if_seq_no',
'refresh',
'routing',
'timeout',
'version',
'version_type',
'wait_for_active_shards'
]
}
}
/** /**
* Delete a document. Remove a JSON document from the specified index. NOTE: You cannot send deletion requests directly to a data stream. To delete a document in a data stream, you must target the backing index containing the document. **Optimistic concurrency control** Delete operations can be made conditional and only be performed if the last modification to the document was assigned the sequence number and primary term specified by the `if_seq_no` and `if_primary_term` parameters. If a mismatch is detected, the operation will result in a `VersionConflictException` and a status code of `409`. **Versioning** Each document indexed is versioned. When deleting a document, the version can be specified to make sure the relevant document you are trying to delete is actually being deleted and it has not changed in the meantime. Every write operation run on a document, deletes included, causes its version to be incremented. The version number of a deleted document remains available for a short time after deletion to allow for control of concurrent operations. The length of time for which a deleted document's version remains available is determined by the `index.gc_deletes` index setting. **Routing** If routing is used during indexing, the routing value also needs to be specified to delete a document. If the `_routing` mapping is set to `required` and no routing value is specified, the delete API throws a `RoutingMissingException` and rejects the request. For example: ``` DELETE /my-index-000001/_doc/1?routing=shard-1 ``` This request deletes the document with ID 1, but it is routed based on the user. The document is not deleted if the correct routing is not specified. **Distributed** The delete operation gets hashed into a specific shard ID. It then gets redirected into the primary shard within that ID group and replicated (if needed) to shard replicas within that ID group. * Removes a JSON document from the specified index.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/docs-delete.html | Elasticsearch API documentation}
*/ */
export default async function DeleteApi (this: That, params: T.DeleteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DeleteResponse> export default async function DeleteApi (this: That, params: T.DeleteRequest | TB.DeleteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DeleteResponse>
export default async function DeleteApi (this: That, params: T.DeleteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DeleteResponse, unknown>> export default async function DeleteApi (this: That, params: T.DeleteRequest | TB.DeleteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DeleteResponse, unknown>>
export default async function DeleteApi (this: That, params: T.DeleteRequest, options?: TransportRequestOptions): Promise<T.DeleteResponse> export default async function DeleteApi (this: That, params: T.DeleteRequest | TB.DeleteRequest, options?: TransportRequestOptions): Promise<T.DeleteResponse>
export default async function DeleteApi (this: That, params: T.DeleteRequest, options?: TransportRequestOptions): Promise<any> { export default async function DeleteApi (this: That, params: T.DeleteRequest | TB.DeleteRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id', 'index']
path: acceptedPath const querystring: Record<string, any> = {}
} = acceptedParams.delete const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }

File diff suppressed because one or more lines are too long

View File

@ -35,52 +35,25 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
}
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
delete_by_query_rethrottle: {
path: [
'task_id'
],
body: [],
query: [
'requests_per_second'
]
}
}
/** /**
* Throttle a delete by query operation. Change the number of requests per second for a particular delete by query operation. Rethrottling that speeds up the query takes effect immediately but rethrotting that slows down the query takes effect after completing the current batch to prevent scroll timeouts. * Changes the number of requests per second for a particular Delete By Query operation.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete-by-query-rethrottle | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/docs-delete-by-query.html | Elasticsearch API documentation}
*/ */
export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DeleteByQueryRethrottleResponse> export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest | TB.DeleteByQueryRethrottleRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DeleteByQueryRethrottleResponse>
export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DeleteByQueryRethrottleResponse, unknown>> export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest | TB.DeleteByQueryRethrottleRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DeleteByQueryRethrottleResponse, unknown>>
export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest, options?: TransportRequestOptions): Promise<T.DeleteByQueryRethrottleResponse> export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest | TB.DeleteByQueryRethrottleRequest, options?: TransportRequestOptions): Promise<T.DeleteByQueryRethrottleResponse>
export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest, options?: TransportRequestOptions): Promise<any> { export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest | TB.DeleteByQueryRethrottleRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['task_id']
path: acceptedPath const querystring: Record<string, any> = {}
} = acceptedParams.delete_by_query_rethrottle const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }

View File

@ -35,53 +35,25 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
}
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
delete_script: {
path: [
'id'
],
body: [],
query: [
'master_timeout',
'timeout'
]
}
}
/** /**
* Delete a script or search template. Deletes a stored script or search template. * Deletes a stored script or search template.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete-script | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/modules-scripting.html | Elasticsearch API documentation}
*/ */
export default async function DeleteScriptApi (this: That, params: T.DeleteScriptRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DeleteScriptResponse> export default async function DeleteScriptApi (this: That, params: T.DeleteScriptRequest | TB.DeleteScriptRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DeleteScriptResponse>
export default async function DeleteScriptApi (this: That, params: T.DeleteScriptRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DeleteScriptResponse, unknown>> export default async function DeleteScriptApi (this: That, params: T.DeleteScriptRequest | TB.DeleteScriptRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DeleteScriptResponse, unknown>>
export default async function DeleteScriptApi (this: That, params: T.DeleteScriptRequest, options?: TransportRequestOptions): Promise<T.DeleteScriptResponse> export default async function DeleteScriptApi (this: That, params: T.DeleteScriptRequest | TB.DeleteScriptRequest, options?: TransportRequestOptions): Promise<T.DeleteScriptResponse>
export default async function DeleteScriptApi (this: That, params: T.DeleteScriptRequest, options?: TransportRequestOptions): Promise<any> { export default async function DeleteScriptApi (this: That, params: T.DeleteScriptRequest | TB.DeleteScriptRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id']
path: acceptedPath const querystring: Record<string, any> = {}
} = acceptedParams.delete_script const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }

View File

@ -35,100 +35,31 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class Enrich { export default class Enrich {
transport: Transport transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) { constructor (transport: Transport) {
this.transport = transport this.transport = transport
this.acceptedParams = {
'enrich.delete_policy': {
path: [
'name'
],
body: [],
query: [
'master_timeout'
]
},
'enrich.execute_policy': {
path: [
'name'
],
body: [],
query: [
'master_timeout',
'wait_for_completion'
]
},
'enrich.get_policy': {
path: [
'name'
],
body: [],
query: [
'master_timeout'
]
},
'enrich.put_policy': {
path: [
'name'
],
body: [
'geo_match',
'match',
'range'
],
query: [
'master_timeout'
]
},
'enrich.stats': {
path: [],
body: [],
query: [
'master_timeout'
]
}
}
} }
/** /**
* Delete an enrich policy. Deletes an existing enrich policy and its enrich index. * Deletes an existing enrich policy and its enrich index.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-delete-policy | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/delete-enrich-policy-api.html | Elasticsearch API documentation}
*/ */
async deletePolicy (this: That, params: T.EnrichDeletePolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EnrichDeletePolicyResponse> async deletePolicy (this: That, params: T.EnrichDeletePolicyRequest | TB.EnrichDeletePolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EnrichDeletePolicyResponse>
async deletePolicy (this: That, params: T.EnrichDeletePolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EnrichDeletePolicyResponse, unknown>> async deletePolicy (this: That, params: T.EnrichDeletePolicyRequest | TB.EnrichDeletePolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EnrichDeletePolicyResponse, unknown>>
async deletePolicy (this: That, params: T.EnrichDeletePolicyRequest, options?: TransportRequestOptions): Promise<T.EnrichDeletePolicyResponse> async deletePolicy (this: That, params: T.EnrichDeletePolicyRequest | TB.EnrichDeletePolicyRequest, options?: TransportRequestOptions): Promise<T.EnrichDeletePolicyResponse>
async deletePolicy (this: That, params: T.EnrichDeletePolicyRequest, options?: TransportRequestOptions): Promise<any> { async deletePolicy (this: That, params: T.EnrichDeletePolicyRequest | TB.EnrichDeletePolicyRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['enrich.delete_policy'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -146,34 +77,21 @@ export default class Enrich {
} }
/** /**
* Run an enrich policy. Create the enrich index for an existing enrich policy. * Creates the enrich index for an existing enrich policy.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-execute-policy | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/execute-enrich-policy-api.html | Elasticsearch API documentation}
*/ */
async executePolicy (this: That, params: T.EnrichExecutePolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EnrichExecutePolicyResponse> async executePolicy (this: That, params: T.EnrichExecutePolicyRequest | TB.EnrichExecutePolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EnrichExecutePolicyResponse>
async executePolicy (this: That, params: T.EnrichExecutePolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EnrichExecutePolicyResponse, unknown>> async executePolicy (this: That, params: T.EnrichExecutePolicyRequest | TB.EnrichExecutePolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EnrichExecutePolicyResponse, unknown>>
async executePolicy (this: That, params: T.EnrichExecutePolicyRequest, options?: TransportRequestOptions): Promise<T.EnrichExecutePolicyResponse> async executePolicy (this: That, params: T.EnrichExecutePolicyRequest | TB.EnrichExecutePolicyRequest, options?: TransportRequestOptions): Promise<T.EnrichExecutePolicyResponse>
async executePolicy (this: That, params: T.EnrichExecutePolicyRequest, options?: TransportRequestOptions): Promise<any> { async executePolicy (this: That, params: T.EnrichExecutePolicyRequest | TB.EnrichExecutePolicyRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['enrich.execute_policy'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -191,35 +109,22 @@ export default class Enrich {
} }
/** /**
* Get an enrich policy. Returns information about an enrich policy. * Returns information about an enrich policy.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-get-policy | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/get-enrich-policy-api.html | Elasticsearch API documentation}
*/ */
async getPolicy (this: That, params?: T.EnrichGetPolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EnrichGetPolicyResponse> async getPolicy (this: That, params?: T.EnrichGetPolicyRequest | TB.EnrichGetPolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EnrichGetPolicyResponse>
async getPolicy (this: That, params?: T.EnrichGetPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EnrichGetPolicyResponse, unknown>> async getPolicy (this: That, params?: T.EnrichGetPolicyRequest | TB.EnrichGetPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EnrichGetPolicyResponse, unknown>>
async getPolicy (this: That, params?: T.EnrichGetPolicyRequest, options?: TransportRequestOptions): Promise<T.EnrichGetPolicyResponse> async getPolicy (this: That, params?: T.EnrichGetPolicyRequest | TB.EnrichGetPolicyRequest, options?: TransportRequestOptions): Promise<T.EnrichGetPolicyResponse>
async getPolicy (this: That, params?: T.EnrichGetPolicyRequest, options?: TransportRequestOptions): Promise<any> { async getPolicy (this: That, params?: T.EnrichGetPolicyRequest | TB.EnrichGetPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['enrich.get_policy'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -244,30 +149,23 @@ export default class Enrich {
} }
/** /**
* Create an enrich policy. Creates an enrich policy. * Creates an enrich policy.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-put-policy | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/put-enrich-policy-api.html | Elasticsearch API documentation}
*/ */
async putPolicy (this: That, params: T.EnrichPutPolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EnrichPutPolicyResponse> async putPolicy (this: That, params: T.EnrichPutPolicyRequest | TB.EnrichPutPolicyRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EnrichPutPolicyResponse>
async putPolicy (this: That, params: T.EnrichPutPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EnrichPutPolicyResponse, unknown>> async putPolicy (this: That, params: T.EnrichPutPolicyRequest | TB.EnrichPutPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EnrichPutPolicyResponse, unknown>>
async putPolicy (this: That, params: T.EnrichPutPolicyRequest, options?: TransportRequestOptions): Promise<T.EnrichPutPolicyResponse> async putPolicy (this: That, params: T.EnrichPutPolicyRequest | TB.EnrichPutPolicyRequest, options?: TransportRequestOptions): Promise<T.EnrichPutPolicyResponse>
async putPolicy (this: That, params: T.EnrichPutPolicyRequest, options?: TransportRequestOptions): Promise<any> { async putPolicy (this: That, params: T.EnrichPutPolicyRequest | TB.EnrichPutPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['name']
path: acceptedPath, const acceptedBody: string[] = ['geo_match', 'match', 'range']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['enrich.put_policy'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -277,15 +175,9 @@ export default class Enrich {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -301,35 +193,22 @@ export default class Enrich {
} }
/** /**
* Get enrich stats. Returns enrich coordinator statistics and information about enrich policies that are currently executing. * Returns enrich coordinator statistics and information about enrich policies that are currently executing.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-stats | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/enrich-stats-api.html | Elasticsearch API documentation}
*/ */
async stats (this: That, params?: T.EnrichStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EnrichStatsResponse> async stats (this: That, params?: T.EnrichStatsRequest | TB.EnrichStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EnrichStatsResponse>
async stats (this: That, params?: T.EnrichStatsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EnrichStatsResponse, unknown>> async stats (this: That, params?: T.EnrichStatsRequest | TB.EnrichStatsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EnrichStatsResponse, unknown>>
async stats (this: That, params?: T.EnrichStatsRequest, options?: TransportRequestOptions): Promise<T.EnrichStatsResponse> async stats (this: That, params?: T.EnrichStatsRequest | TB.EnrichStatsRequest, options?: TransportRequestOptions): Promise<T.EnrichStatsResponse>
async stats (this: That, params?: T.EnrichStatsRequest, options?: TransportRequestOptions): Promise<any> { async stats (this: That, params?: T.EnrichStatsRequest | TB.EnrichStatsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['enrich.stats'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }

View File

@ -35,110 +35,31 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class Eql { export default class Eql {
transport: Transport transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) { constructor (transport: Transport) {
this.transport = transport this.transport = transport
this.acceptedParams = {
'eql.delete': {
path: [
'id'
],
body: [],
query: []
},
'eql.get': {
path: [
'id'
],
body: [],
query: [
'keep_alive',
'wait_for_completion_timeout'
]
},
'eql.get_status': {
path: [
'id'
],
body: [],
query: []
},
'eql.search': {
path: [
'index'
],
body: [
'query',
'case_sensitive',
'event_category_field',
'tiebreaker_field',
'timestamp_field',
'fetch_size',
'filter',
'keep_alive',
'keep_on_completion',
'wait_for_completion_timeout',
'allow_partial_search_results',
'allow_partial_sequence_results',
'size',
'fields',
'result_position',
'runtime_mappings',
'max_samples_per_key'
],
query: [
'allow_no_indices',
'allow_partial_search_results',
'allow_partial_sequence_results',
'expand_wildcards',
'ignore_unavailable',
'keep_alive',
'keep_on_completion',
'wait_for_completion_timeout'
]
}
}
} }
/** /**
* Delete an async EQL search. Delete an async EQL search or a stored synchronous EQL search. The API also deletes results for the search. * Deletes an async EQL search or a stored synchronous EQL search. The API also deletes results for the search.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-delete | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/eql-search-api.html | Elasticsearch API documentation}
*/ */
async delete (this: That, params: T.EqlDeleteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EqlDeleteResponse> async delete (this: That, params: T.EqlDeleteRequest | TB.EqlDeleteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EqlDeleteResponse>
async delete (this: That, params: T.EqlDeleteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EqlDeleteResponse, unknown>> async delete (this: That, params: T.EqlDeleteRequest | TB.EqlDeleteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EqlDeleteResponse, unknown>>
async delete (this: That, params: T.EqlDeleteRequest, options?: TransportRequestOptions): Promise<T.EqlDeleteResponse> async delete (this: That, params: T.EqlDeleteRequest | TB.EqlDeleteRequest, options?: TransportRequestOptions): Promise<T.EqlDeleteResponse>
async delete (this: That, params: T.EqlDeleteRequest, options?: TransportRequestOptions): Promise<any> { async delete (this: That, params: T.EqlDeleteRequest | TB.EqlDeleteRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['eql.delete'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -156,34 +77,21 @@ export default class Eql {
} }
/** /**
* Get async EQL search results. Get the current status and available results for an async EQL search or a stored synchronous EQL search. * Returns the current status and available results for an async EQL search or a stored synchronous EQL search.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-get | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/get-async-eql-search-api.html | Elasticsearch API documentation}
*/ */
async get<TEvent = unknown> (this: That, params: T.EqlGetRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EqlGetResponse<TEvent>> async get<TEvent = unknown> (this: That, params: T.EqlGetRequest | TB.EqlGetRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EqlGetResponse<TEvent>>
async get<TEvent = unknown> (this: That, params: T.EqlGetRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EqlGetResponse<TEvent>, unknown>> async get<TEvent = unknown> (this: That, params: T.EqlGetRequest | TB.EqlGetRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EqlGetResponse<TEvent>, unknown>>
async get<TEvent = unknown> (this: That, params: T.EqlGetRequest, options?: TransportRequestOptions): Promise<T.EqlGetResponse<TEvent>> async get<TEvent = unknown> (this: That, params: T.EqlGetRequest | TB.EqlGetRequest, options?: TransportRequestOptions): Promise<T.EqlGetResponse<TEvent>>
async get<TEvent = unknown> (this: That, params: T.EqlGetRequest, options?: TransportRequestOptions): Promise<any> { async get<TEvent = unknown> (this: That, params: T.EqlGetRequest | TB.EqlGetRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['eql.get'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -201,34 +109,21 @@ export default class Eql {
} }
/** /**
* Get the async EQL status. Get the current status for an async EQL search or a stored synchronous EQL search without returning results. * Returns the current status for an async EQL search or a stored synchronous EQL search without returning results.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-get-status | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/get-async-eql-status-api.html | Elasticsearch API documentation}
*/ */
async getStatus (this: That, params: T.EqlGetStatusRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EqlGetStatusResponse> async getStatus (this: That, params: T.EqlGetStatusRequest | TB.EqlGetStatusRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EqlGetStatusResponse>
async getStatus (this: That, params: T.EqlGetStatusRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EqlGetStatusResponse, unknown>> async getStatus (this: That, params: T.EqlGetStatusRequest | TB.EqlGetStatusRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EqlGetStatusResponse, unknown>>
async getStatus (this: That, params: T.EqlGetStatusRequest, options?: TransportRequestOptions): Promise<T.EqlGetStatusResponse> async getStatus (this: That, params: T.EqlGetStatusRequest | TB.EqlGetStatusRequest, options?: TransportRequestOptions): Promise<T.EqlGetStatusResponse>
async getStatus (this: That, params: T.EqlGetStatusRequest, options?: TransportRequestOptions): Promise<any> { async getStatus (this: That, params: T.EqlGetStatusRequest | TB.EqlGetStatusRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['eql.get_status'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -246,30 +141,23 @@ export default class Eql {
} }
/** /**
* Get EQL search results. Returns search results for an Event Query Language (EQL) query. EQL assumes each document in a data stream or index corresponds to an event. * Returns results matching a query expressed in Event Query Language (EQL)
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-search | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/eql-search-api.html | Elasticsearch API documentation}
*/ */
async search<TEvent = unknown> (this: That, params: T.EqlSearchRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EqlSearchResponse<TEvent>> async search<TEvent = unknown> (this: That, params: T.EqlSearchRequest | TB.EqlSearchRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EqlSearchResponse<TEvent>>
async search<TEvent = unknown> (this: That, params: T.EqlSearchRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EqlSearchResponse<TEvent>, unknown>> async search<TEvent = unknown> (this: That, params: T.EqlSearchRequest | TB.EqlSearchRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EqlSearchResponse<TEvent>, unknown>>
async search<TEvent = unknown> (this: That, params: T.EqlSearchRequest, options?: TransportRequestOptions): Promise<T.EqlSearchResponse<TEvent>> async search<TEvent = unknown> (this: That, params: T.EqlSearchRequest | TB.EqlSearchRequest, options?: TransportRequestOptions): Promise<T.EqlSearchResponse<TEvent>>
async search<TEvent = unknown> (this: That, params: T.EqlSearchRequest, options?: TransportRequestOptions): Promise<any> { async search<TEvent = unknown> (this: That, params: T.EqlSearchRequest | TB.EqlSearchRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath, const acceptedBody: string[] = ['query', 'case_sensitive', 'event_category_field', 'tiebreaker_field', 'timestamp_field', 'fetch_size', 'filter', 'keep_alive', 'keep_on_completion', 'wait_for_completion_timeout', 'size', 'fields', 'result_position', 'runtime_mappings']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['eql.search'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -279,15 +167,9 @@ export default class Eql {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }

View File

@ -35,132 +35,33 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class Esql { export default class Esql {
transport: Transport transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) { constructor (transport: Transport) {
this.transport = transport this.transport = transport
this.acceptedParams = {
'esql.async_query': {
path: [],
body: [
'columnar',
'filter',
'locale',
'params',
'profile',
'query',
'tables',
'include_ccs_metadata'
],
query: [
'delimiter',
'drop_null_columns',
'format',
'keep_alive',
'keep_on_completion',
'wait_for_completion_timeout'
]
},
'esql.async_query_delete': {
path: [
'id'
],
body: [],
query: []
},
'esql.async_query_get': {
path: [
'id'
],
body: [],
query: [
'drop_null_columns',
'keep_alive',
'wait_for_completion_timeout'
]
},
'esql.async_query_stop': {
path: [
'id'
],
body: [],
query: [
'drop_null_columns'
]
},
'esql.query': {
path: [],
body: [
'columnar',
'filter',
'locale',
'params',
'profile',
'query',
'tables',
'include_ccs_metadata'
],
query: [
'format',
'delimiter',
'drop_null_columns'
]
}
}
} }
/** /**
* Run an async ES|QL query. Asynchronously run an ES|QL (Elasticsearch query language) query, monitor its progress, and retrieve results when they become available. The API accepts the same parameters and request body as the synchronous query API, along with additional async related properties. * Executes an ESQL request asynchronously
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/esql-async-query-api.html | Elasticsearch API documentation}
*/ */
async asyncQuery (this: That, params: T.EsqlAsyncQueryRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EsqlAsyncQueryResponse> async asyncQuery (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async asyncQuery (this: That, params: T.EsqlAsyncQueryRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EsqlAsyncQueryResponse, unknown>> async asyncQuery (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async asyncQuery (this: That, params: T.EsqlAsyncQueryRequest, options?: TransportRequestOptions): Promise<T.EsqlAsyncQueryResponse> async asyncQuery (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async asyncQuery (this: That, params: T.EsqlAsyncQueryRequest, options?: TransportRequestOptions): Promise<any> { async asyncQuery (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath, const querystring: Record<string, any> = {}
body: acceptedBody, const body = undefined
query: acceptedQuery
} = this.acceptedParams['esql.async_query']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedBody.includes(key)) { if (acceptedPath.includes(key)) {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
} else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -173,80 +74,22 @@ export default class Esql {
} }
/** /**
* Delete an async ES|QL query. If the query is still running, it is cancelled. Otherwise, the stored results are deleted. If the Elasticsearch security features are enabled, only the following users can use this API to delete a query: * The authenticated user that submitted the original query request * Users with the `cancel_task` cluster privilege * Retrieves the results of a previously submitted async query request given its ID.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query-delete | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/esql-async-query-get-api.html | Elasticsearch API documentation}
*/ */
async asyncQueryDelete (this: That, params: T.EsqlAsyncQueryDeleteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EsqlAsyncQueryDeleteResponse> async asyncQueryGet (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async asyncQueryDelete (this: That, params: T.EsqlAsyncQueryDeleteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EsqlAsyncQueryDeleteResponse, unknown>> async asyncQueryGet (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async asyncQueryDelete (this: That, params: T.EsqlAsyncQueryDeleteRequest, options?: TransportRequestOptions): Promise<T.EsqlAsyncQueryDeleteResponse> async asyncQueryGet (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async asyncQueryDelete (this: That, params: T.EsqlAsyncQueryDeleteRequest, options?: TransportRequestOptions): Promise<any> { async asyncQueryGet (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['esql.async_query_delete'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error
querystring[key] = params[key]
}
}
const method = 'DELETE'
const path = `/_query/async/${encodeURIComponent(params.id.toString())}`
const meta: TransportRequestMetadata = {
name: 'esql.async_query_delete',
pathParts: {
id: params.id
}
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
}
/**
* Get async ES|QL query results. Get the current status and available results or stored results for an ES|QL asynchronous query. If the Elasticsearch security features are enabled, only the user who first submitted the ES|QL query can retrieve the results using this API.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query-get | Elasticsearch API documentation}
*/
async asyncQueryGet (this: That, params: T.EsqlAsyncQueryGetRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EsqlAsyncQueryGetResponse>
async asyncQueryGet (this: That, params: T.EsqlAsyncQueryGetRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EsqlAsyncQueryGetResponse, unknown>>
async asyncQueryGet (this: That, params: T.EsqlAsyncQueryGetRequest, options?: TransportRequestOptions): Promise<T.EsqlAsyncQueryGetResponse>
async asyncQueryGet (this: That, params: T.EsqlAsyncQueryGetRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath
} = this.acceptedParams['esql.async_query_get']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) {
if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
} }
@ -263,75 +106,23 @@ export default class Esql {
} }
/** /**
* Stop async ES|QL query. This API interrupts the query execution and returns the results so far. If the Elasticsearch security features are enabled, only the user who first submitted the ES|QL query can stop it. * Executes an ES|QL request
* @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-stop-api.html | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/esql-rest.html | Elasticsearch API documentation}
*/ */
async asyncQueryStop (this: That, params: T.EsqlAsyncQueryStopRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EsqlAsyncQueryStopResponse> async query (this: That, params: T.EsqlQueryRequest | TB.EsqlQueryRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EsqlQueryResponse>
async asyncQueryStop (this: That, params: T.EsqlAsyncQueryStopRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EsqlAsyncQueryStopResponse, unknown>> async query (this: That, params: T.EsqlQueryRequest | TB.EsqlQueryRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EsqlQueryResponse, unknown>>
async asyncQueryStop (this: That, params: T.EsqlAsyncQueryStopRequest, options?: TransportRequestOptions): Promise<T.EsqlAsyncQueryStopResponse> async query (this: That, params: T.EsqlQueryRequest | TB.EsqlQueryRequest, options?: TransportRequestOptions): Promise<T.EsqlQueryResponse>
async asyncQueryStop (this: That, params: T.EsqlAsyncQueryStopRequest, options?: TransportRequestOptions): Promise<any> { async query (this: That, params: T.EsqlQueryRequest | TB.EsqlQueryRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const acceptedBody: string[] = ['columnar', 'filter', 'locale', 'params', 'query']
} = this.acceptedParams['esql.async_query_stop'] const querystring: Record<string, any> = {}
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) {
if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] const userBody: any = params?.body
} let body: Record<string, any> | string
}
const method = 'POST'
const path = `/_query/async/${encodeURIComponent(params.id.toString())}/stop`
const meta: TransportRequestMetadata = {
name: 'esql.async_query_stop',
pathParts: {
id: params.id
}
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
}
/**
* Run an ES|QL query. Get search results for an ES|QL (Elasticsearch query language) query.
* @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-rest.html | Elasticsearch API documentation}
*/
async query (this: That, params: T.EsqlQueryRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.EsqlQueryResponse>
async query (this: That, params: T.EsqlQueryRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.EsqlQueryResponse, unknown>>
async query (this: That, params: T.EsqlQueryRequest, options?: TransportRequestOptions): Promise<T.EsqlQueryResponse>
async query (this: That, params: T.EsqlQueryRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['esql.query']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -341,15 +132,9 @@ export default class Esql {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }

View File

@ -35,62 +35,25 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
}
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
exists: {
path: [
'id',
'index'
],
body: [],
query: [
'preference',
'realtime',
'refresh',
'routing',
'_source',
'_source_excludes',
'_source_includes',
'stored_fields',
'version',
'version_type'
]
}
}
/** /**
* Check a document. Verify that a document exists. For example, check to see if a document with the `_id` 0 exists: ``` HEAD my-index-000001/_doc/0 ``` If the document exists, the API returns a status code of `200 - OK`. If the document doesnt exist, the API returns `404 - Not Found`. **Versioning support** You can use the `version` parameter to check the document only if its current version is equal to the specified one. Internally, Elasticsearch has marked the old document as deleted and added an entirely new document. The old version of the document doesn't disappear immediately, although you won't be able to access it. Elasticsearch cleans up deleted documents in the background as you continue to index more data. * Checks if a document in an index exists.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/docs-get.html | Elasticsearch API documentation}
*/ */
export default async function ExistsApi (this: That, params: T.ExistsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ExistsResponse> export default async function ExistsApi (this: That, params: T.ExistsRequest | TB.ExistsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ExistsResponse>
export default async function ExistsApi (this: That, params: T.ExistsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ExistsResponse, unknown>> export default async function ExistsApi (this: That, params: T.ExistsRequest | TB.ExistsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ExistsResponse, unknown>>
export default async function ExistsApi (this: That, params: T.ExistsRequest, options?: TransportRequestOptions): Promise<T.ExistsResponse> export default async function ExistsApi (this: That, params: T.ExistsRequest | TB.ExistsRequest, options?: TransportRequestOptions): Promise<T.ExistsResponse>
export default async function ExistsApi (this: That, params: T.ExistsRequest, options?: TransportRequestOptions): Promise<any> { export default async function ExistsApi (this: That, params: T.ExistsRequest | TB.ExistsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id', 'index']
path: acceptedPath const querystring: Record<string, any> = {}
} = acceptedParams.exists const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }

View File

@ -35,61 +35,25 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
}
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
exists_source: {
path: [
'id',
'index'
],
body: [],
query: [
'preference',
'realtime',
'refresh',
'routing',
'_source',
'_source_excludes',
'_source_includes',
'version',
'version_type'
]
}
}
/** /**
* Check for a document source. Check whether a document source exists in an index. For example: ``` HEAD my-index-000001/_source/1 ``` A document's source is not available if it is disabled in the mapping. * Checks if a document's `_source` is stored.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/docs-get.html | Elasticsearch API documentation}
*/ */
export default async function ExistsSourceApi (this: That, params: T.ExistsSourceRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ExistsSourceResponse> export default async function ExistsSourceApi (this: That, params: T.ExistsSourceRequest | TB.ExistsSourceRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ExistsSourceResponse>
export default async function ExistsSourceApi (this: That, params: T.ExistsSourceRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ExistsSourceResponse, unknown>> export default async function ExistsSourceApi (this: That, params: T.ExistsSourceRequest | TB.ExistsSourceRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ExistsSourceResponse, unknown>>
export default async function ExistsSourceApi (this: That, params: T.ExistsSourceRequest, options?: TransportRequestOptions): Promise<T.ExistsSourceResponse> export default async function ExistsSourceApi (this: That, params: T.ExistsSourceRequest | TB.ExistsSourceRequest, options?: TransportRequestOptions): Promise<T.ExistsSourceResponse>
export default async function ExistsSourceApi (this: That, params: T.ExistsSourceRequest, options?: TransportRequestOptions): Promise<any> { export default async function ExistsSourceApi (this: That, params: T.ExistsSourceRequest | TB.ExistsSourceRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id', 'index']
path: acceptedPath const querystring: Record<string, any> = {}
} = acceptedParams.exists_source const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }

View File

@ -35,64 +35,27 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
explain: {
path: [
'id',
'index'
],
body: [
'query'
],
query: [
'analyzer',
'analyze_wildcard',
'default_operator',
'df',
'lenient',
'preference',
'routing',
'_source',
'_source_excludes',
'_source_includes',
'stored_fields',
'q'
]
}
}
/** /**
* Explain a document match result. Get information about why a specific document matches, or doesn't match, a query. It computes a score explanation for a query and a specific document. * Returns information about why a specific document matches (or doesnt match) a query.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-explain | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/search-explain.html | Elasticsearch API documentation}
*/ */
export default async function ExplainApi<TDocument = unknown> (this: That, params: T.ExplainRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ExplainResponse<TDocument>> export default async function ExplainApi<TDocument = unknown> (this: That, params: T.ExplainRequest | TB.ExplainRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ExplainResponse<TDocument>>
export default async function ExplainApi<TDocument = unknown> (this: That, params: T.ExplainRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ExplainResponse<TDocument>, unknown>> export default async function ExplainApi<TDocument = unknown> (this: That, params: T.ExplainRequest | TB.ExplainRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ExplainResponse<TDocument>, unknown>>
export default async function ExplainApi<TDocument = unknown> (this: That, params: T.ExplainRequest, options?: TransportRequestOptions): Promise<T.ExplainResponse<TDocument>> export default async function ExplainApi<TDocument = unknown> (this: That, params: T.ExplainRequest | TB.ExplainRequest, options?: TransportRequestOptions): Promise<T.ExplainResponse<TDocument>>
export default async function ExplainApi<TDocument = unknown> (this: That, params: T.ExplainRequest, options?: TransportRequestOptions): Promise<any> { export default async function ExplainApi<TDocument = unknown> (this: That, params: T.ExplainRequest | TB.ExplainRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id', 'index']
path: acceptedPath, const acceptedBody: string[] = ['query']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = acceptedParams.explain const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -102,15 +65,9 @@ export default async function ExplainApi<TDocument = unknown> (this: That, param
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }

View File

@ -35,65 +35,32 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
export default class Features { export default class Features {
transport: Transport transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) { constructor (transport: Transport) {
this.transport = transport this.transport = transport
this.acceptedParams = {
'features.get_features': {
path: [],
body: [],
query: [
'master_timeout'
]
},
'features.reset_features': {
path: [],
body: [],
query: [
'master_timeout'
]
}
}
} }
/** /**
* Get the features. Get a list of features that can be included in snapshots using the `feature_states` field when creating a snapshot. You can use this API to determine which feature states to include when taking a snapshot. By default, all feature states are included in a snapshot if that snapshot includes the global state, or none if it does not. A feature state includes one or more system indices necessary for a given feature to function. In order to ensure data integrity, all system indices that comprise a feature state are snapshotted and restored together. The features listed by this API are a combination of built-in features and features defined by plugins. In order for a feature state to be listed in this API and recognized as a valid feature state by the create snapshot API, the plugin that defines that feature must be installed on the master node. * Gets a list of features which can be included in snapshots using the feature_states field when creating a snapshot
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-features-get-features | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/get-features-api.html | Elasticsearch API documentation}
*/ */
async getFeatures (this: That, params?: T.FeaturesGetFeaturesRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FeaturesGetFeaturesResponse> async getFeatures (this: That, params?: T.FeaturesGetFeaturesRequest | TB.FeaturesGetFeaturesRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FeaturesGetFeaturesResponse>
async getFeatures (this: That, params?: T.FeaturesGetFeaturesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FeaturesGetFeaturesResponse, unknown>> async getFeatures (this: That, params?: T.FeaturesGetFeaturesRequest | TB.FeaturesGetFeaturesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FeaturesGetFeaturesResponse, unknown>>
async getFeatures (this: That, params?: T.FeaturesGetFeaturesRequest, options?: TransportRequestOptions): Promise<T.FeaturesGetFeaturesResponse> async getFeatures (this: That, params?: T.FeaturesGetFeaturesRequest | TB.FeaturesGetFeaturesRequest, options?: TransportRequestOptions): Promise<T.FeaturesGetFeaturesResponse>
async getFeatures (this: That, params?: T.FeaturesGetFeaturesRequest, options?: TransportRequestOptions): Promise<any> { async getFeatures (this: That, params?: T.FeaturesGetFeaturesRequest | TB.FeaturesGetFeaturesRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['features.get_features'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -108,35 +75,22 @@ export default class Features {
} }
/** /**
* Reset the features. Clear all of the state information stored in system indices by Elasticsearch features, including the security and machine learning indices. WARNING: Intended for development and testing use only. Do not reset features on a production cluster. Return a cluster to the same state as a new installation by resetting the feature state for all Elasticsearch features. This deletes all state information stored in system indices. The response code is HTTP 200 if the state is successfully reset for all features. It is HTTP 500 if the reset operation failed for any feature. Note that select features might provide a way to reset particular system indices. Using this API resets all features, both those that are built-in and implemented as plugins. To list the features that will be affected, use the get features API. IMPORTANT: The features installed on the node you submit this request to are the features that will be reset. Run on the master node if you have any doubts about which plugins are installed on individual nodes. * Resets the internal state of features, usually by deleting system indices
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-features-reset-features | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/modules-snapshots.html | Elasticsearch API documentation}
*/ */
async resetFeatures (this: That, params?: T.FeaturesResetFeaturesRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FeaturesResetFeaturesResponse> async resetFeatures (this: That, params?: T.FeaturesResetFeaturesRequest | TB.FeaturesResetFeaturesRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FeaturesResetFeaturesResponse>
async resetFeatures (this: That, params?: T.FeaturesResetFeaturesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FeaturesResetFeaturesResponse, unknown>> async resetFeatures (this: That, params?: T.FeaturesResetFeaturesRequest | TB.FeaturesResetFeaturesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FeaturesResetFeaturesResponse, unknown>>
async resetFeatures (this: That, params?: T.FeaturesResetFeaturesRequest, options?: TransportRequestOptions): Promise<T.FeaturesResetFeaturesResponse> async resetFeatures (this: That, params?: T.FeaturesResetFeaturesRequest | TB.FeaturesResetFeaturesRequest, options?: TransportRequestOptions): Promise<T.FeaturesResetFeaturesResponse>
async resetFeatures (this: That, params?: T.FeaturesResetFeaturesRequest, options?: TransportRequestOptions): Promise<any> { async resetFeatures (this: That, params?: T.FeaturesResetFeaturesRequest | TB.FeaturesResetFeaturesRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['features.reset_features'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }

View File

@ -35,61 +35,27 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
field_caps: {
path: [
'index'
],
body: [
'fields',
'index_filter',
'runtime_mappings'
],
query: [
'allow_no_indices',
'expand_wildcards',
'fields',
'ignore_unavailable',
'include_unmapped',
'filters',
'types',
'include_empty_fields'
]
}
}
/** /**
* Get the field capabilities. Get information about the capabilities of fields among multiple indices. For data streams, the API returns field capabilities among the streams backing indices. It returns runtime fields like any other field. For example, a runtime field with a type of keyword is returned the same as any other field that belongs to the `keyword` family. * The field capabilities API returns the information about the capabilities of fields among multiple indices. The field capabilities API returns runtime fields like any other field. For example, a runtime field with a type of keyword is returned as any other field that belongs to the `keyword` family.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-field-caps | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/search-field-caps.html | Elasticsearch API documentation}
*/ */
export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FieldCapsResponse> export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FieldCapsResponse>
export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FieldCapsResponse, unknown>> export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FieldCapsResponse, unknown>>
export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest, options?: TransportRequestOptions): Promise<T.FieldCapsResponse> export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptions): Promise<T.FieldCapsResponse>
export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest, options?: TransportRequestOptions): Promise<any> { export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath, const acceptedBody: string[] = ['fields', 'index_filter', 'runtime_mappings']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = acceptedParams.field_caps const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
params = params ?? {} params = params ?? {}
@ -100,15 +66,9 @@ export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequ
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }

View File

@ -35,190 +35,31 @@ import {
TransportResult TransportResult
} from '@elastic/transport' } from '@elastic/transport'
import * as T from '../types' import * as T from '../types'
import * as TB from '../typesWithBodyKey'
interface That { interface That { transport: Transport }
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}
const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']
export default class Fleet { export default class Fleet {
transport: Transport transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) { constructor (transport: Transport) {
this.transport = transport this.transport = transport
this.acceptedParams = {
'fleet.delete_secret': {
path: [
'id'
],
body: [],
query: []
},
'fleet.get_secret': {
path: [
'id'
],
body: [],
query: []
},
'fleet.global_checkpoints': {
path: [
'index'
],
body: [],
query: [
'wait_for_advance',
'wait_for_index',
'checkpoints',
'timeout'
]
},
'fleet.msearch': {
path: [
'index'
],
body: [
'searches'
],
query: [
'allow_no_indices',
'ccs_minimize_roundtrips',
'expand_wildcards',
'ignore_throttled',
'ignore_unavailable',
'max_concurrent_searches',
'max_concurrent_shard_requests',
'pre_filter_shard_size',
'search_type',
'rest_total_hits_as_int',
'typed_keys',
'wait_for_checkpoints',
'allow_partial_search_results'
]
},
'fleet.post_secret': {
path: [],
body: [],
query: []
},
'fleet.search': {
path: [
'index'
],
body: [
'aggregations',
'aggs',
'collapse',
'explain',
'ext',
'from',
'highlight',
'track_total_hits',
'indices_boost',
'docvalue_fields',
'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: [
'allow_no_indices',
'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',
'pre_filter_shard_size',
'request_cache',
'routing',
'scroll',
'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',
'wait_for_checkpoints',
'allow_partial_search_results'
]
}
}
} }
/** /**
* Deletes a secret stored by Fleet. * Deletes a secret stored by Fleet.
*/ */
async deleteSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO> async deleteSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async deleteSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>> async deleteSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async deleteSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO> async deleteSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async deleteSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> { async deleteSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['fleet.delete_secret'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
querystring[key] = params[key] querystring[key] = params[key]
} }
} }
@ -237,32 +78,19 @@ export default class Fleet {
/** /**
* Retrieves a secret stored by Fleet. * Retrieves a secret stored by Fleet.
*/ */
async getSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO> async getSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async getSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>> async getSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async getSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO> async getSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async getSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> { async getSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['id']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['fleet.get_secret'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
querystring[key] = params[key] querystring[key] = params[key]
} }
} }
@ -279,34 +107,21 @@ export default class Fleet {
} }
/** /**
* Get global checkpoints. Get the current global checkpoints for an index. This API is designed for internal use by the Fleet server project. * Returns the current global checkpoints for an index. This API is design for internal use by the fleet server project.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-fleet | Elasticsearch API documentation} * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.15/get-global-checkpoints.html | Elasticsearch API documentation}
*/ */
async globalCheckpoints (this: That, params: T.FleetGlobalCheckpointsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetGlobalCheckpointsResponse> async globalCheckpoints (this: That, params: T.FleetGlobalCheckpointsRequest | TB.FleetGlobalCheckpointsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetGlobalCheckpointsResponse>
async globalCheckpoints (this: That, params: T.FleetGlobalCheckpointsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetGlobalCheckpointsResponse, unknown>> async globalCheckpoints (this: That, params: T.FleetGlobalCheckpointsRequest | TB.FleetGlobalCheckpointsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetGlobalCheckpointsResponse, unknown>>
async globalCheckpoints (this: That, params: T.FleetGlobalCheckpointsRequest, options?: TransportRequestOptions): Promise<T.FleetGlobalCheckpointsResponse> async globalCheckpoints (this: That, params: T.FleetGlobalCheckpointsRequest | TB.FleetGlobalCheckpointsRequest, options?: TransportRequestOptions): Promise<T.FleetGlobalCheckpointsResponse>
async globalCheckpoints (this: That, params: T.FleetGlobalCheckpointsRequest, options?: TransportRequestOptions): Promise<any> { async globalCheckpoints (this: That, params: T.FleetGlobalCheckpointsRequest | TB.FleetGlobalCheckpointsRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['fleet.global_checkpoints'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} }
@ -324,38 +139,27 @@ export default class Fleet {
} }
/** /**
* Run multiple Fleet searches. Run several Fleet searches with a single API request. The API follows the same structure as the multi search API. However, similar to the Fleet search API, it supports the `wait_for_checkpoints` parameter. * Executes several [fleet searches](https://www.elastic.co/guide/en/elasticsearch/reference/current/fleet-search.html) with a single API request. The API follows the same structure as the [multi search](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) API. However, similar to the fleet search API, it supports the wait_for_checkpoints parameter.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-fleet-msearch | Elasticsearch API documentation}
*/ */
async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetMsearchResponse<TDocument>> async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest | TB.FleetMsearchRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetMsearchResponse<TDocument>>
async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetMsearchResponse<TDocument>, unknown>> async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest | TB.FleetMsearchRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetMsearchResponse<TDocument>, unknown>>
async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest, options?: TransportRequestOptions): Promise<T.FleetMsearchResponse<TDocument>> async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest | TB.FleetMsearchRequest, options?: TransportRequestOptions): Promise<T.FleetMsearchResponse<TDocument>>
async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest, options?: TransportRequestOptions): Promise<any> { async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest | TB.FleetMsearchRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath, const acceptedBody: string[] = ['searches']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['fleet.msearch']
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: any = params.body ?? undefined let body: any = params.body ?? undefined
for (const key in params) { for (const key in params) {
if (acceptedBody.includes(key)) { if (acceptedBody.includes(key)) {
// @ts-expect-error // @ts-expect-error
body = params[key] body = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }
@ -380,32 +184,19 @@ export default class Fleet {
/** /**
* Creates a secret stored by Fleet. * Creates a secret stored by Fleet.
*/ */
async postSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO> async postSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async postSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>> async postSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async postSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO> async postSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async postSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> { async postSecret (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = []
path: acceptedPath const querystring: Record<string, any> = {}
} = this.acceptedParams['fleet.post_secret'] const body = undefined
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') {
body = userBody
} else {
body = { ...userBody }
}
}
params = params ?? {} params = params ?? {}
for (const key in params) { for (const key in params) {
if (acceptedPath.includes(key)) { if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
querystring[key] = params[key] querystring[key] = params[key]
} }
} }
@ -419,30 +210,22 @@ export default class Fleet {
} }
/** /**
* Run a Fleet search. The purpose of the Fleet search API is to provide an API where the search will be run only after the provided checkpoint has been processed and is visible for searches inside of Elasticsearch. * The purpose of the fleet search api is to provide a search api where the search will only be executed after provided checkpoint has been processed and is visible for searches inside of Elasticsearch.
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-fleet-search | Elasticsearch API documentation}
*/ */
async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetSearchResponse<TDocument>> async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest | TB.FleetSearchRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetSearchResponse<TDocument>>
async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetSearchResponse<TDocument>, unknown>> async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest | TB.FleetSearchRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetSearchResponse<TDocument>, unknown>>
async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest, options?: TransportRequestOptions): Promise<T.FleetSearchResponse<TDocument>> async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest | TB.FleetSearchRequest, options?: TransportRequestOptions): Promise<T.FleetSearchResponse<TDocument>>
async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest, options?: TransportRequestOptions): Promise<any> { async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest | TB.FleetSearchRequest, options?: TransportRequestOptions): Promise<any> {
const { const acceptedPath: string[] = ['index']
path: acceptedPath, const acceptedBody: string[] = ['aggregations', 'aggs', 'collapse', 'explain', 'ext', 'from', 'highlight', 'track_total_hits', 'indices_boost', 'docvalue_fields', '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']
body: acceptedBody, const querystring: Record<string, any> = {}
query: acceptedQuery // @ts-expect-error
} = this.acceptedParams['fleet.search'] const userBody: any = params?.body
let body: Record<string, any> | string
const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
let body: Record<string, any> | string | undefined
const userBody = params?.body
if (userBody != null) {
if (typeof userBody === 'string') { if (typeof userBody === 'string') {
body = userBody body = userBody
} else { } else {
body = { ...userBody } body = userBody != null ? { ...userBody } : undefined
}
} }
for (const key in params) { for (const key in params) {
@ -452,15 +235,9 @@ export default class Fleet {
body[key] = params[key] body[key] = params[key]
} else if (acceptedPath.includes(key)) { } else if (acceptedPath.includes(key)) {
continue continue
} else if (key !== 'body' && key !== 'querystring') { } else if (key !== 'body') {
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error // @ts-expect-error
querystring[key] = params[key] querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
} }
} }

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