diff --git a/.buildkite/Dockerfile b/.buildkite/Dockerfile index 7d267991f..fb0f905d9 100644 --- a/.buildkite/Dockerfile +++ b/.buildkite/Dockerfile @@ -1,4 +1,4 @@ -ARG PHP_VERSION=8.0-cli +ARG PHP_VERSION=8.4-cli FROM php:${PHP_VERSION} WORKDIR /usr/src/app @@ -39,4 +39,4 @@ RUN composer install --no-progress > /dev/null COPY . . -CMD ["bash", ".buildkite/yaml-tests.sh"] +CMD ["bash", ".buildkite/yaml-tests.sh"] \ No newline at end of file diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index d087788f2..128c2c338 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -7,17 +7,16 @@ steps: env: PHP_VERSION: "{{ matrix.php }}" TEST_SUITE: "{{ matrix.suite }}" - STACK_VERSION: 8.14.0-SNAPSHOT + STACK_VERSION: 9.0.0-SNAPSHOT + BRANCH_CLIENT_TESTS: 9.0 matrix: setup: suite: - - "free" - "platinum" php: + - "8.4-cli" - "8.3-cli" - "8.2-cli" - "8.1-cli" - - "8.0-cli" - - "7.4-cli" command: ./.buildkite/run-tests artifact_paths: "*.xml" diff --git a/.buildkite/run-repository.sh b/.buildkite/run-repository.sh index 51a3d2bb5..6d31f4fd7 100644 --- a/.buildkite/run-repository.sh +++ b/.buildkite/run-repository.sh @@ -9,7 +9,7 @@ script_path=$(dirname $(realpath -s $0)) source $script_path/functions/imports.sh set -euo pipefail -PHP_VERSION=${PHP_VERSION-8.2-cli} +PHP_VERSION=${PHP_VERSION-8.4-cli} ELASTICSEARCH_URL=${ELASTICSEARCH_URL-"$elasticsearch_url"} elasticsearch_container=${elasticsearch_container-} @@ -18,6 +18,7 @@ echo -e "\033[34;1mINFO:\033[0m TEST_SUITE ${TEST_SUITE}\033[0m" echo -e "\033[34;1mINFO:\033[0m URL ${ELASTICSEARCH_URL}\033[0m" echo -e "\033[34;1mINFO:\033[0m CONTAINER ${elasticsearch_container}\033[0m" echo -e "\033[34;1mINFO:\033[0m PHP_VERSION ${PHP_VERSION}\033[0m" +echo -e "\033[34;1mINFO:\033[0m BRANCH_CLIENT_TESTS ${BRANCH_CLIENT_TESTS}\033[0m" echo -e "\033[1m>>>>> Build docker container >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" @@ -40,7 +41,8 @@ docker run \ --env TEST_SUITE=${TEST_SUITE} \ --env PHP_VERSION=${PHP_VERSION} \ --env ELASTICSEARCH_URL=${ELASTICSEARCH_URL} \ + --env BRANCH_CLIENT_TESTS=${BRANCH_CLIENT_TESTS} \ --ulimit nofile=65535:65535 \ --name elasticsearch-php \ --rm \ - elastic/elasticsearch-php + elastic/elasticsearch-php \ No newline at end of file diff --git a/.buildkite/yaml-tests.sh b/.buildkite/yaml-tests.sh index 0a83f93e2..5891bf6b2 100755 --- a/.buildkite/yaml-tests.sh +++ b/.buildkite/yaml-tests.sh @@ -1,10 +1,16 @@ #!/usr/bin/env bash -# Checkout the YAML test from Elasticsearch tag -php util/RestSpecRunner.php +# Clone the elasticsearch-clients-tests repository +git clone -b ${BRANCH_CLIENT_TESTS} https://github.com/elastic/elasticsearch-clients-tests.git tests/elasticsearch-clients-tests -# Generate the YAML tests for PHPUnit -php util/build_tests.php +# Build the YAML tests +php tests/build_es_tests.php tests/elasticsearch-clients-tests/tests stack tests/Yaml # Run YAML tests -vendor/bin/phpunit -c "phpunit-yaml-${TEST_SUITE}-tests.xml" \ No newline at end of file +vendor/bin/phpunit -c "phpunit-yaml-stack-tests.xml" + +# Remove Yaml tests +rm -rf tests/Yaml + +# Remove elasticsearch-clients-tests folder +rm -rf tests/elasticsearch-clients-tests \ No newline at end of file diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml new file mode 100644 index 000000000..bb466166d --- /dev/null +++ b/.github/workflows/docs-build.yml @@ -0,0 +1,19 @@ +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 diff --git a/.github/workflows/docs-cleanup.yml b/.github/workflows/docs-cleanup.yml new file mode 100644 index 000000000..f83e017b5 --- /dev/null +++ b/.github/workflows/docs-cleanup.yml @@ -0,0 +1,14 @@ +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 diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml new file mode 100644 index 000000000..b91994068 --- /dev/null +++ b/.github/workflows/integration_test.yml @@ -0,0 +1,50 @@ +name: PHP integration tests + +on: [push, pull_request] + +jobs: + test: + name: Test + runs-on: ${{ matrix.os }} + + strategy: + matrix: + php-version: [8.1, 8.2, 8.3, 8.4] + os: [ubuntu-latest] + es-version: [9.0.0-SNAPSHOT] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Use PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: yaml, zip, curl + coverage: none + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get composer cache directory + id: composercache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composercache.outputs.dir }} + key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}- + + - name: Install dependencies + run: | + composer install --prefer-dist + + - name: Run Elasticsearch using start-local + run: | + curl -fsSL https://elastic.co/start-local | sh -s -- -v ${{ matrix.es-version }} -esonly + + - name: Integration tests + run: | + source elastic-start-local/.env + ELASTICSEARCH_URL="http://elastic:${ES_LOCAL_PASSWORD}@localhost:9200" TEST_SUITE="free" composer run-script integration-test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 822de1841..0e60b4ef9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: PHP test +name: PHP tests on: [push, pull_request] @@ -9,9 +9,9 @@ jobs: strategy: matrix: - php-version: [7.4, 8.0, 8.1, 8.2, 8.3] + php-version: [8.1, 8.2, 8.3, 8.4] os: [ubuntu-latest] - es-version: [8.14-SNAPSHOT] + es-version: [9.0.0-SNAPSHOT] steps: - name: Checkout diff --git a/.github/workflows/yaml_test.yml b/.github/workflows/yaml_test.yml new file mode 100644 index 000000000..dd4ac3f1f --- /dev/null +++ b/.github/workflows/yaml_test.yml @@ -0,0 +1,57 @@ +name: PHP YAML tests + +on: [push, pull_request] + +jobs: + test: + name: Test + runs-on: ${{ matrix.os }} + + strategy: + matrix: + php-version: [8.1, 8.2, 8.3, 8.4] + os: [ubuntu-latest] + es-version: [9.0.0-SNAPSHOT] + test-suite: [stack] + branch-client-tests: ["9.0"] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Use PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: yaml, zip, curl + coverage: none + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get composer cache directory + id: composercache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composercache.outputs.dir }} + key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}- + + - name: Install dependencies + run: | + composer install --prefer-dist + + - name: Run Elasticsearch using start-local + run: | + curl -fsSL https://elastic.co/start-local | sh -s -- -v ${{ matrix.es-version }} -esonly + + - name: Build PHPUnit tests + run: | + git clone -b ${{ matrix.branch-client-tests }} https://github.com/elastic/elasticsearch-clients-tests.git tests/elasticsearch-clients-tests + php tests/build_es_tests.php tests/elasticsearch-clients-tests/tests ${{ matrix.test-suite }} tests/Yaml + + - name: YAML tests + run: | + source elastic-start-local/.env + ELASTICSEARCH_URL="http://elastic:${ES_LOCAL_PASSWORD}@localhost:9200" TEST_SUITE="free" vendor/bin/phpunit -c "phpunit-yaml-${{ matrix.test-suite }}-tests.xml" diff --git a/.gitignore b/.gitignore index 61b321f53..d2439897f 100755 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ util/cache/ util/*.zip util/output/ util/rest-spec +elastic-start-local/ # Doctum docs generator /doctum.phar @@ -35,6 +36,7 @@ util/doctum.phar # PHPUnit /phpunit.xml .phpunit.result.cache +.phpunit.cache/ # Code coverage build diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index b5b6bc48d..503a9cb57 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -1,3 +1,7 @@ +# 9.0 + +- **Use of PHP 8.1+:** Starting from 9.0.0 the `elasticsearch-php` client requires PHP 8.1+. + # 8.0 This major release is a complete new PHP client for Elasticsearch. We build it from scratch! diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ceda3d5a..8bbd87174 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,27 @@ +## Release 9.0.0 + +- **Use of PHP 8.1+:** Starting from 9.0.0 the `elasticsearch-php` client requires PHP 8.1+. +- **Compatibility with Elasticsearch 9.0:** All changes and additions to Elasticsearch APIs for its 9.0 release are reflected in this release. +- **Serverless client merged in:** the `elastic/elasticsearch-serverless` client is being deprecated, and its functionality has been merged back into this client. This should have zero impact on the way the client works by default. If an endpoint is available in serverless, the PHP function will contains a `@group serverless` phpdoc attribute. +If you try to use an endpoint that is not available in serverless you will get a `410` HTTP error with a message as follows: +"this endpoint exists but is not available when running in serverless mode". +The 9.0.0 client can recognize that it is communicating with a serverless instance if you are using a URL managed by Elastic (e.g. `*.elastic.cloud`). +If you are using a proxy, the client will be able to recognize that the host is serverless from the first response. Alternatively, you can explicitly indicate that the host is serverless using the `Client::setServerless(true)` function (`false` by default). +- **New transport library with PSR-18 cURL client as default:** we've removed the Guzzle dependency from the client. By default, the built-in cURL-based HTTP client will be used if no other PSR-18 compatible clients are detected. See release [9.0.0](https://github.com/elastic/elastic-transport-php/releases/tag/v9.0.0) of elastic-transport-php. + +## Release 8.17.1 + +- Fix and improvements for PHPStan (rule level 5) #1442 (thanks @AJenbo) + +## Release 8.17.0 + +- Updated the APIs to Elasticsearch [8.17.0](https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-8.17.0.html) + +## Release 8.16.0 + +- Updated the APIs to Elasticsearch [8.16.0](https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-8.16.0.html) +- Added the support of PHP 8.4 #1415 (thanks @ruudk) + ## Release 8.15.0 Updated the APIs to Elasticsearch [8.15.0](https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-8.15.0.html) and added the support of OpenTelemetry. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..63a1a249b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,93 @@ +# Contributing to the PHP Elasticsearch Client + +If you have a bugfix or new feature that you would like to contribute to +elasticsearch-php, please find or open an issue about it first. Talk about what +you would like to do. It may be that somebody is already working on it, or that +there are particular issues that you should know about before implementing the +change. + +We enjoy working with contributors to get their code accepted. There are many +approaches to fixing a problem and it is important to find the best approach +before writing too much code. + +## Running Elasticsearch locally + +We've provided a script to start an Elasticsearch cluster of a certain version +found at `.buildkite/run-elasticsearch.sh`. + +There are several environment variables that control integration tests: + +- `TEST_SUITE`: `free` or `platinum` for running Elasticsearch in different + versions. +- `STACK_VERSION`: Version of Elasticsearch to use. These should be + the same as tags of `docker.elastic.co/elasticsearch/elasticsearch` + such as `8.0.0-SNAPSHOT`, `7.x-SNAPSHOT`, etc. Defaults to the + same `*-SNAPSHOT` version as the branch. + +**NOTE: You don't need to run the live integration tests for all changes. If +you don't have Elasticsearch running locally the integration tests will be skipped.** + +## API Code Generation + +All API methods in `src/Endpoints` and in `src/Traits/ClientEndpointsTrait.php` are +automatically generated from the [Elasticsearch specification](https://github.com/elastic/elasticsearch-specification) +and [rest-api-spec](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/api). + +You can check if a PHP file has been generated searching for `@generated` tag +in the source code (e.g. [here](https://github.com/elastic/elasticsearch-php/blob/main/src/Traits/ClientEndpointsTrait.php#L27) +in the `ClientEndpointsTrait.php`). + +Any changes to these files should be avoid, you can submit to the Elasticsearch +specification project and will be imported the next time the client will be generated. +The generator itself is currently a private project. + +## Contributing Code Changes + +The process for contributing to any of the Elasticsearch repositories is similar. + +1. Please make sure you have signed the [Contributor License + Agreement](http://www.elastic.co/contributor-agreement/). We are not + asking you to assign copyright to us, but to give us the right to distribute + your code without restriction. We ask this of all contributors in order to + assure our users of the origin and continuing existence of the code. You only + need to sign the CLA once. + +2. Run the linter and test suite to ensure your changes do not break existing code. + Run the last optional step only if you want to test your changes with the + integration tests. You need to specify the `STACK_VERSION` of Elasticsearch (e.g. + `8.17.0`), you can check the Elasticsearch versions [here](https://github.com/elastic/elasticsearch/releases). + + ``` + # Run PHPStan, see https://phpstan.org/ + $ composer run-script phpstan + + # Run the unit tests + $ composer run-script test + + # Run the integration tests (optional) + $ STACK_VERSION="8.17.0" .buildkite/run-tests + ``` + +3. Rebase your changes. + Update your local repository with the most recent code from the main + elasticsearch-php repository, and rebase your branch on top of the latest branch. + If you want to propose a change in the latest version, you need to use the `main` + branch. If you are proposing for `8.x` version you should use the latest + minor branch (e.g. `8.17`). If want to propose a change for the oldest versions + you need to use the `7.17` or `6.8.x` branches. Remember, we support only the latest + minor of the previous majour. For instance, if the latest version is `8.x` we + support the last minor of `7.x` (i.e. `7.17`). + We prefer your changes to be squashed into a single commit for easier + backporting. + +4. Submit a pull request. Push your local changes to your forked copy of the + repository and submit a pull request. In the pull request, describe what your + changes do and mention the number of the issue where discussion has taken + place, eg “Closes #123″. Please consider adding or modifying tests related to + your changes. + +Then sit back and wait. There will probably be a discussion about the pull +request and, if any changes are needed, we would love to work with you to get +your pull request merged into elasticsearch-php. + +Thanks in advance for all your future contributions! \ No newline at end of file diff --git a/README.md b/README.md index 0a686bc77..4464afb4b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- Elastic logo + Elastic logo

# Elasticsearch PHP client @@ -9,9 +9,12 @@ This is the official PHP client for [Elasticsearch](https://www.elastic.co/elasticsearch/). -**[Download the latest version of Elasticsearch](https://www.elastic.co/downloads/elasticsearch)** -or -**[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)** +You can run [Elasticsearch](https://www.elastic.co/elasticsearch) and [Kibana](https://www.elastic.co/kibana) on your local machine using this command: + +```bash +curl -fsSL https://elastic.co/start-local | sh +``` +or **[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)** **for a free trial of Elastic Cloud**. ## Contents @@ -40,7 +43,7 @@ of the getting started documentation. ## Usage -The `elasticsearch-php` client offers 400+ endpoints for interacting with +The `elasticsearch-php` client offers 500+ endpoints for interacting with Elasticsearch. A list of all these endpoints is available in the [official documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html) of Elasticsearch APIs. @@ -63,8 +66,8 @@ This client is versioned and released alongside Elasticsearch server. To guarantee compatibility, use the most recent version of this library within the major version of the corresponding Enterprise Search implementation. -For example, for Elasticsearch `7.16`, use `7.16` of this library or above, but -not `8.0`. +For example, for Elasticsearch `8.16`, use `8.16` of this library or above, but +not `9.0`. ## Compatibility @@ -82,33 +85,24 @@ compatible with default distributions and without guarantees made. | Elasticsearch Version | Elasticsearch-PHP Branch | Supported | | --------------------- | ------------------------ | --------- | | main | main | | +| 9.x | 9.x | 9.x | | 8.x | 8.x | 8.x | -| 7.x | 7.x | 7.17 | ## Backward Incompatible Changes :boom: -The 8.0.0 version of `elasticsearch-php` contains a new implementation compared -with 7.x. It supports [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP -messages and [PSR-18](https://www.php-fig.org/psr/psr-18/) for HTTP client -communications. - -We tried to reduce the BC breaks as much as possible with `7.x` but there are -some (big) differences: - -- we changed the namespace, now everything is under `Elastic\Elasticsearch` -- we used the - [elastic-transport-php](https://github.com/elastic/elastic-transport-php) - library for HTTP communications; -- we changed the `Exception` model, using the namespace - `Elastic\Elasticsearch\Exception`. All the exceptions extends the - `ElasticsearchException` interface, as in 7.x -- we changed the response type of each endpoints using an - [Elasticsearch](src/Response/Elasticsearch.php) response class. This class - wraps a a [PSR-7](https://www.php-fig.org/psr/psr-7/) response allowing the - access of the body response as array or object. This means you can access the - API response as in 7.x, no BC break here! :angel: -- we changed the `ConnectionPool` in `NodePool`. The `connection` naming was - ambigous since the objects are nodes (hosts) +The 9.0.0 version of `elasticsearch-php` contains the same architecture of 8.x. +It supports [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP messages and +[PSR-18](https://www.php-fig.org/psr/psr-18/) for HTTP client communications. + +We tried to avoid BC breaks for `9.x`, here the main changes: + +- **Compatibility with Elasticsearch 9.0:** All changes and additions to Elasticsearch APIs for its 9.0 release are reflected in this release. +- **Serverless client merged in:** the `elastic/elasticsearch-serverless` client is being deprecated, and its functionality has been merged back into this client. This should have zero impact on the way the client works by default. If an endpoint is available in serverless, the PHP function will contains a `@group serverless` phpdoc attribute. +If you try to use an endpoint that is not available in serverless you will get a `410` HTTP error with a message as follows: +"this endpoint exists but is not available when running in serverless mode". +The 9.0.0 client can recognize that it is communicating with a serverless instance if you are using a URL managed by Elastic (e.g. `*.elastic.cloud`). +If you are using a proxy, the client will be able to recognize that the host is serverless from the first response. Alternatively, you can explicitly indicate that the host is serverless using the `Client::setServerless(true)` function (`false` by default). +- **New transport library with PSR-18 cURL client as default:** we've removed the Guzzle dependency from the client. By default, the built-in cURL-based HTTP client will be used if no other PSR-18 compatible clients are detected. See release [9.0.0](https://github.com/elastic/elastic-transport-php/releases/tag/v9.0.0) of elastic-transport-php. You can have a look at the [BREAKING_CHANGES](BREAKING_CHANGES.md) file for more information. @@ -180,19 +174,8 @@ You can checkout the ## Contribute 🚀 -We welcome contributors to the project. Before you begin, some useful info... - -- If you want to contribute to this project you need to subscribe to a - [Contributor Agreement](https://www.elastic.co/contributor-agreement). -- Before opening a pull request, please create an issue to - [discuss the scope of your proposal](https://github.com/elastic/elasticsearch-php/issues). -- If you want to send a PR for version `8.0` please use the `8.0` branch, for - `8.1` use the `8.1` branch and so on. -- Never send PR to `master` unless you want to contribute to the development - version of the client (`master` represents the next major version). -- Each PR should include a **unit test** using [PHPUnit](https://phpunit.de/). - If you are not familiar with PHPUnit you can have a look at the - [reference](https://phpunit.readthedocs.io/en/9.5/). +We welcome contributors to the project. You can refer to the [CONTRIBUTING](CONTRIBUTING.md) +guide for more information. Thanks in advance for your contribution! :heart: diff --git a/composer.json b/composer.json index 1a71c3be8..1d6688b09 100644 --- a/composer.json +++ b/composer.json @@ -3,32 +3,32 @@ "description": "PHP Client for Elasticsearch", "keywords": [ "search", - "client", + "client", "elasticsearch", "elastic" ], "type": "library", "license": "MIT", "require": { - "php": "^7.4 || ^8.0", - "elastic/transport": "^8.10", + "php": "^8.1", + "elastic/transport": "^9.0", "psr/http-client": "^1.0", - "psr/http-message": "^1.1 || ^2.0", - "psr/log": "^1|^2|^3", - "guzzlehttp/guzzle": "^7.0" + "psr/http-message": "^2.0", + "psr/log": "^2.0|^3.0" }, "require-dev": { "ext-yaml": "*", "ext-zip": "*", - "mockery/mockery": "^1.5", - "phpstan/phpstan": "^1.4", - "phpunit/phpunit": "^9.5", - "symfony/finder": "~4.0", - "nyholm/psr7": "^1.5", - "php-http/mock-client": "^1.5", - "symfony/http-client": "^5.0|^6.0|^7.0", + "mockery/mockery": "^1.6", + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^10.0", + "symfony/finder": "^6.0", + "nyholm/psr7": "^1.8", + "php-http/mock-client": "^1.6", "psr/http-factory" : "^1.0", - "php-http/message-factory" : "^1.0" + "guzzlehttp/guzzle": "^7.0", + "symfony/http-client": "^6.0|^7.0", + "nette/php-generator": "^4.0" }, "autoload": { "psr-4": { @@ -52,7 +52,7 @@ "vendor/bin/phpunit --testdox -c phpunit-integration-cloud-tests.xml" ], "phpstan": [ - "phpstan analyse src --level 2 --no-progress --memory-limit 256M" + "phpstan analyse --no-progress --memory-limit 256M" ] }, "config": { diff --git a/docs/breaking-changes.asciidoc b/docs/breaking-changes.asciidoc deleted file mode 100644 index 7bbd4f8d9..000000000 --- a/docs/breaking-changes.asciidoc +++ /dev/null @@ -1,49 +0,0 @@ -[[breaking_changes]] -=== Breaking changes from 7.x - -This major release is a complete new PHP client for {es}. We build it from scratch! -We tried to reduce the BC breaks as much as possible but there are some (big) differences: - -[discrete] -==== Architectural changes - -- we changed the namespace, now everything is under `Elastic\Elasticsearch` -- we used the https://github.com/elastic/elastic-transport-php[elastic-transport-php] library for HTTP communications; -- we changed the `Exception` model, using the namespace `Elastic\Elasticsearch\Exception`. All the exceptions extends the - `ElasticsearchException` interface, as in 7.x -- we changed the response type of each endpoint using an https://github.com/elastic/elasticsearch-php/blob/master/src/Response/Elasticsearch.php[Elasticsearch] response class. - This class wraps a https://www.php-fig.org/psr/psr-7/[PSR-7] response allowing the access of the body response - as array or object. This means you can access the API response as in 7.x, no BC break here! :angel: -- we changed the `ConnectionPool` in `NodePool`. The `connection` naming was ambigous since the objects are nodes (hosts) - -[discrete] -==== Specific changes - -The following functions has been removed: - -- `ClientBuilder::getEndpoint()` -- `ClientBuilder::getRegisteredNamespacesBuilders()` -- `ClientBuilder::getRegisteredNamespacesBuilders()` -- `ClientBuilder::defaultHandler()` -- `ClientBuilder::multiHandler()` -- `ClientBuilder::singleHandler()` -- `ClientBuilder::setConnectionFactory()` -- `ClientBuilder::setConnectionPool()`, you can use `ClientBuilder::setNodePool` instead -- `ClientBuilder::setEndpoint()` -- `ClientBuilder::registerNamespace()` -- `ClientBuilder::setTransport()`, you can specify an HTTP PSR-18 client using `ClientBuilder::setHttpClient()` -- `ClientBuilder::setHandler()` -- `ClientBuilder::setTracer()`, you can only set a Logger using `ClientBuilder::setLogger()` -- `ClientBuilder::setSerializer()` -- `ClientBuilder::setConnectionParams()`, you can use `ClientBuilder::setHttpClientOptions()` instead -- `ClientBuilder::setSelector()`, you can set a `Selector` using the `setNodePool`, see https://github.com/elastic/elastic-transport-php/blob/8.x/README.md#use-a-custom-selector[here] for more information -- `ClientBuilder::setSniffOnStart()` -- `ClientBuilder::includePortInHostHeader()` - -We removed the special `client` parameter passed in `$params` endpoints. In details: - -- `$params['client']['never_retry']` -- `$params['client']['verbose']` -- `$params['client']['port_in_header']` -- `$params['client']['future']`, you can set HTTP async using `Client::setAsync(true)` -- `$params['client']['ignore']`, you can disable the Exception using `Client::setResponseException(false)` diff --git a/docs/config-hash.asciidoc b/docs/config-hash.asciidoc deleted file mode 100644 index 97949e7ed..000000000 --- a/docs/config-hash.asciidoc +++ /dev/null @@ -1,41 +0,0 @@ -[discrete] -[[config-hash]] -=== Building the client from a configuration hash - -To help ease automated building of the client, all configurations can be -provided in a setting hash instead of calling the individual methods directly. -This functionality is exposed through the `ClientBuilder::fromConfig()` static -method, which accepts an array of configurations and returns a fully built -client. - -Array keys correspond to the method name, for example `retries` key corresponds -to `setRetries()` method. - -[source,php] ----- -$params = [ - 'hosts' => [ - 'localhost:9200' - ], - 'retries' => 2 -]; -$client = ClientBuilder::fromConfig($params); ----- - -Unknown parameters throw an exception, to help the user find potential problems. -If this behavior is not desired (for example, you are using the hash for other -purposes), you can set `$quiet = true` in fromConfig() to silence the exceptions. - -[source,php] ----- -$params = [ - 'hosts' => [ - 'localhost:9200' - ], - 'retries' => 2, - 'imNotReal' => 5 -]; - -// Set $quiet to true to ignore the unknown `imNotReal` key -$client = ClientBuilder::fromConfig($params, true); ----- \ No newline at end of file diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc deleted file mode 100644 index e5e2ee2a1..000000000 --- a/docs/configuration.asciidoc +++ /dev/null @@ -1,39 +0,0 @@ -[[configuration]] -== Configuration - -Almost every aspect of the client is configurable. Most users only need to -configure a few parameters to suit their needs, but it is possible to completely -replace much of the internals if required. - -Custom configuration is accomplished before the client is instantiated, through -the `ClientBuilder` class. You can find all the configuration options and -check sample code that helps you replace the various components. - -To learn more about JSON in PHP, read <>. - -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> - -include::php_json_objects.asciidoc[] - -include::host-config.asciidoc[] - -include::set-retries.asciidoc[] - -include::http-meta-data.asciidoc[] - -include::logger.asciidoc[] - -include::http-client.asciidoc[] - -include::namespaces.asciidoc[] - -include::node-pool.asciidoc[] - -include::config-hash.asciidoc[] diff --git a/docs/connecting.asciidoc b/docs/connecting.asciidoc deleted file mode 100644 index 5c67cd43d..000000000 --- a/docs/connecting.asciidoc +++ /dev/null @@ -1,109 +0,0 @@ -[[connecting]] -== Connecting - -This page contains the information you need to connect and use the Client with -{es}. - -**On this page** - -* <> -* <> - -[discrete] -[[auth-ec]] -=== Elastic Cloud - -You can connect to https://www.elastic.co/cloud/[Elastic Cloud] using an **API key** -and a **Cloud ID**: - -[source,php] ----- -$client = ClientBuilder::create() - ->setElasticCloudId('') - ->setApiKey('') - ->build(); ----- - -Where and can be retrieved using the Elastic Cloud web UI. - -You can get the `Cloud ID` from the `My deployment` page of your dashboard (see the red -rectangle reported in the screenshot). - -image::images/cloud_id.png[alt="Elastic Cloud ID",align="center"] - -You can generate an `API key` in the `Management` page under the section `Security`. - -image::images/create_api_key.png[alt="Create API key",align="center"] - -When you click on `Create API key` button you can choose a name and set the other -options (eg. restrict privileges, expire after time, etc). - -image::images/api_key_name.png[alt="Choose an API name",align="center"] - -After this step you will get the `API key`in the API keys page. - -image::images/cloud_api_key.png[alt="Cloud API key",align="center"] - -**IMPORTANT**: you need to copy and store the `API key`in a secure place, since you will not -be able to view it again in Elastic Cloud. - - -[discrete] -[[auth-http]] -=== Security by default (HTTPS) - -{es} 8.0 offers https://www.elastic.co/blog/introducing-simplified-elastic-stack-security[security by default], -that means it uses https://en.wikipedia.org/wiki/Transport_Layer_Security[TLS] -for protect the communication between client and server. - -In order to configure `elasticsearch-php` for connecting to {es} 8.0 we -need to have the certificate authority file (CA). - -You can install {es} in different ways, for instance using https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html[Docker] -you need to execute the followind command: - -[source,shell] --------------------------- -docker pull docker.elastic.co/elasticsearch/elasticsearch:8.0.1 --------------------------- - -Once you have the docker image installed you can execute {es}, -for instance using a single-node cluster configuration, as follows: - -[source,shell] --------------------------- -docker network create elastic -docker run --name es01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.0.1 --------------------------- - -This command creates an `elastic` Docker network and start {es} -using the port `9200` (default). - -When you run the docker image a password is generated for the `elastic` user -and it's printed to the terminal (you might need to scroll back a bit in the terminal -to view it). You have to copy it since we will need to connect to {es}. - -Now that {es} is running we can get the `http_ca.crt` file certificate. -We need to copy it from the docker instance, using the following command: - -[source,shell] --------------------------- -docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt . --------------------------- - -Once we have the `http_ca.crt` certificate and the `password`, copied during the -start of {es} , we can use it to connect with `elasticsearch-php` -as follows: - -[source,php] --------------------------- -$client = ClientBuilder::create() - ->setHosts(['https://localhost:9200']) - ->setBasicAuthentication('elastic', 'password copied during Elasticsearch start') - ->setCABundle('path/to/http_ca.crt') - ->build(); --------------------------- - -For more information about the Docker configuration of Elasticsearch you can -read the official documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html[here]. - diff --git a/docs/crud.asciidoc b/docs/crud.asciidoc deleted file mode 100644 index 98c2897cf..000000000 --- a/docs/crud.asciidoc +++ /dev/null @@ -1,257 +0,0 @@ -[[indexing_documents]] -=== Indexing documents - -When you add documents to {es}, you index JSON documents. This maps naturally to -PHP associative arrays, since they can easily be encoded in JSON. Therefore, in -Elasticsearch-PHP you create and pass associative arrays to the client for -indexing. There are several methods of ingesting data into {es} which we cover -here. - -[discrete] -==== Single document indexing - -When indexing a document, you can either provide an ID or let {es} generate one -for you. - -{zwsp} + - -.Providing an ID value -[source,php] ----- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id', - 'body' => [ 'testField' => 'abc'] -]; - -// Document will be indexed to my_index/_doc/my_id -$response = $client->index($params); ----- -{zwsp} + - -.Omitting an ID value -[source,php] ----- -$params = [ - 'index' => 'my_index', - 'body' => [ 'testField' => 'abc'] -]; - -// Document will be indexed to my_index/_doc/ -$response = $client->index($params); ----- -{zwsp} + - -If you need to set other parameters, such as a `routing` value, you specify -those in the array alongside the `index`, and others. For example, let's set the -routing and timestamp of this new document: - -.Additional parameters -[source,php] ----- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id', - 'routing' => 'company_xyz', - 'timestamp' => strtotime("-1d"), - 'body' => [ 'testField' => 'abc'] -]; - - -$response = $client->index($params); ----- -{zwsp} + - -[discrete] -==== Bulk Indexing - -{es} also supports bulk indexing of documents. The bulk API expects JSON -action/metadata pairs, separated by newlines. When constructing your documents -in PHP, the process is similar. You first create an action array object (for -example, an `index` object), then you create a document body object. This -process repeats for all your documents. - -A simple example might look like this: - -.Bulk indexing with PHP arrays -[source,php] ----- -for($i = 0; $i < 100; $i++) { - $params['body'][] = [ - 'index' => [ - '_index' => 'my_index', - ] - ]; - - $params['body'][] = [ - 'my_field' => 'my_value', - 'second_field' => 'some more values' - ]; -} - -$responses = $client->bulk($params); ----- - -In practice, you'll likely have more documents than you want to send in a single -bulk request. In that case, you need to batch up the requests and periodically -send them: - -.Bulk indexing with batches -[source,php] ----- -$params = ['body' => []]; - -for ($i = 1; $i <= 1234567; $i++) { - $params['body'][] = [ - 'index' => [ - '_index' => 'my_index', - '_id' => $i - ] - ]; - - $params['body'][] = [ - 'my_field' => 'my_value', - 'second_field' => 'some more values' - ]; - - // Every 1000 documents stop and send the bulk request - if ($i % 1000 == 0) { - $responses = $client->bulk($params); - - // erase the old bulk request - $params = ['body' => []]; - - // unset the bulk response when you are done to save memory - unset($responses); - } -} - -// Send the last batch if it exists -if (!empty($params['body'])) { - $responses = $client->bulk($params); -} ----- - -[[getting_documents]] -=== Getting documents - -{es} provides realtime GETs of documents. This means that as soon as the -document is indexed and your client receives an acknowledgement, you can -immediately retrieve the document from any shard. Get operations are performed -by requesting a document by its full `index/type/id` path: - -[source,php] ----- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id' -]; - -// Get doc at /my_index/_doc/my_id -$response = $client->get($params); ----- -{zwsp} + - -[[updating_documents]] -=== Updating documents - -Updating a document allows you to either completely replace the contents of the -existing document, or perform a partial update to just some fields (either -changing an existing field or adding new fields). - -[discrete] -==== Partial document update - -If you want to partially update a document (for example, change an existing -field or add a new one) you can do so by specifying the `doc` in the `body` -parameter. This merges the fields in `doc` with the existing document. - - -[source,php] ----- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id', - 'body' => [ - 'doc' => [ - 'new_field' => 'abc' - ] - ] -]; - -// Update doc at /my_index/_doc/my_id -$response = $client->update($params); ----- -{zwsp} + - -[discrete] -==== Scripted document update - -Sometimes you need to perform a scripted update, such as incrementing a counter -or appending a new value to an array. To perform a scripted update, you need to -provide a script and usually a set of parameters: - -[source,php] ----- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id', - 'body' => [ - 'script' => 'ctx._source.counter += count', - 'params' => [ - 'count' => 4 - ] - ] -]; - -$response = $client->update($params); ----- -{zwsp} + - -[discrete] -==== Upserts - -Upserts are "Update or Insert" operations. This means an upsert attempts to run -your update script, but if the document does not exist (or the field you are -trying to update doesn't exist), default values are inserted instead. - -[source,php] ----- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id', - 'body' => [ - 'script' => [ - 'source' => 'ctx._source.counter += params.count', - 'params' => [ - 'count' => 4 - ], - ], - 'upsert' => [ - 'counter' => 1 - ], - ] -]; - -$response = $client->update($params); ----- -{zwsp} + - - -[[deleting_documents]] -=== Deleting documents - -Finally, you can delete documents by specifying their full `/index/_doc_/id` -path: - -[source,php] ----- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id' -]; - -// Delete doc at /my_index/_doc_/my_id -$response = $client->delete($params); ----- -{zwsp} + diff --git a/docs/docset.yml b/docs/docset.yml new file mode 100644 index 000000000..b7c7189d5 --- /dev/null +++ b/docs/docset.yml @@ -0,0 +1,9 @@ +project: 'PHP client' +cross_links: + - docs-content + - elasticsearch +toc: + - toc: reference + - toc: release-notes +subs: + es: "Elasticsearch" diff --git a/docs/experimental-beta-apis.asciidoc b/docs/experimental-beta-apis.asciidoc deleted file mode 100644 index 541f21a2f..000000000 --- a/docs/experimental-beta-apis.asciidoc +++ /dev/null @@ -1,74 +0,0 @@ -[[experimental_and_beta_apis]] -=== Experimental and beta APIs - -The PHP client offers also `experimental` and `beta` APIs for {es}. - -The {es} APIs are marked using the following convention: - -- **Stable** APIs should be safe to use extensively in production. Any breaking - changes to these APIs should only occur in major versions and will be - documented in the breaking changes documentation for that release. -- **Beta** APIs are on track to become stable and permanent features. Use them - with caution because it is possible that breaking changes are made to these - APIs in a minor version. -- **Experimental** APIs are just that - an experiment. An experimental API might - have breaking changes in any future version, or it might even be removed - entirely. - -All the `experimental` and `beta` APIs are marked with a `@note` tag in the -phpdoc section of the code. - -[discrete] -=== Experimental - -The experimental APIs included in the current version of `elasticsearch-php` -are: - -- https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-rank-eval.html[Ranking Evaluation] - -[source,php] ----- -$client = ClientBuilder::create()->build(); -$params = [ - // ... -]; -$result = $client->rankEval($params); ----- - -- https://www.elastic.co/guide/en/elasticsearch/painless/7.4/painless-execute-api.html[Painless Execute] - -[source,php] ----- -$client = ClientBuilder::create()->build(); -$params = [ - // ... -]; -$result = $client->scriptsPainlessExecute($params); ----- - -- Get Script Context - -Returns all script contexts. - -[source,php] ----- -$client = ClientBuilder::create()->build(); - -$result = $client->getScriptContext(); ----- - -- Get Script Languages - -Returns available script types, languages and contexts. - -[source,php] ----- -$client = ClientBuilder::create()->build(); - -$result = $client->getScriptLanguages(); ----- - -[discrete] -=== Beta - -There are no beta APIs in the current version of `elasticsearch-php`. \ No newline at end of file diff --git a/docs/helpers/index.asciidoc b/docs/helpers/index.asciidoc deleted file mode 100644 index 53b06b77c..000000000 --- a/docs/helpers/index.asciidoc +++ /dev/null @@ -1,10 +0,0 @@ -[[client-helpers]] -== Client helpers - -The PHP client comes with the following helpers: - -* <> -* <> - -include::iterators.asciidoc[] -include::esql.asciidoc[] \ No newline at end of file diff --git a/docs/http-meta-data.asciidoc b/docs/http-meta-data.asciidoc deleted file mode 100644 index 4195d08c8..000000000 --- a/docs/http-meta-data.asciidoc +++ /dev/null @@ -1,27 +0,0 @@ -[[http-meta-data]] -=== HTTP Meta Data - -By default, the client sends some meta data about the HTTP connection using -custom headers. - -You can disable or enable it using the following methods: - - -==== Elastic Meta Header - -The client sends a `x-elastic-client-meta` header by default. -This header is used to collect meta data about the versions of the components -used by the client. For instance, a value of `x-elastic-client-meta` can be -`es=8.0.0-s,php=8.0.0,t=8.0.0-s,a=0,gu=7.4.2, where each value is the -version of `es=Elasticsearch`, `t` is the transport version (same of client), -`a` is asyncronouts (`0=false` by default) and `gu=Guzzle`. - -If you would like to disable it you can use the `setElasticMetaHeader()` -method, as follows: - -[source,php] ----- -$client = Elasticsearch\ClientBuilder::create() - ->setElasticMetaHeader(false) - ->build(); ----- diff --git a/docs/index.asciidoc b/docs/index.asciidoc deleted file mode 100644 index 63dbe4551..000000000 --- a/docs/index.asciidoc +++ /dev/null @@ -1,29 +0,0 @@ - -= Elasticsearch-PHP - -:doctype: book - -include::{docs-root}/shared/versions/stack/{source_branch}.asciidoc[] -include::{asciidoc-dir}/../../shared/attributes.asciidoc[] - -:es-docs: https://www.elastic.co/guide/en/elasticsearch/reference/{branch} - -include::overview.asciidoc[] - -include::getting-started.asciidoc[] - -include::installation.asciidoc[] - -include::connecting.asciidoc[] - -include::usage.asciidoc[] - -include::configuration.asciidoc[] - -include::operations.asciidoc[] - -include::helpers/index.asciidoc[] - -include::release-notes.asciidoc[] - -include::redirects.asciidoc[] \ No newline at end of file diff --git a/docs/installation.asciidoc b/docs/installation.asciidoc deleted file mode 100644 index 9766efe58..000000000 --- a/docs/installation.asciidoc +++ /dev/null @@ -1,39 +0,0 @@ -[[installation]] -== Installation - -Elasticsearch-php can be used starting from PHP 7.4. -To install the library you need to use http://getcomposer.org[composer] with the -following command: - -[source,shell] --------------------------- -composer require elasticsearch/elasticsearch --------------------------- - -If you don't have composer you can install it as follows: - -[source,shell] --------------------------- -curl -s http://getcomposer.org/installer | php -php composer.phar install --------------------------- - -More information about -https://getcomposer.org/[Composer can be found at their website]. - -When you have installed elasticsearch-php you can start using it -with the `Client` class. You can use the `ClientBuilder` class to -create this object, as follows: - -[source,php] --------------------------- -require 'vendor/autoload.php'; - -$client = Elastic\Elasticsearch\ClientBuilder::create()->build(); --------------------------- -+ -Client instantiation is performed with a static helper function `create()`. This -creates a ClientBuilder object, which helps you to set custom configurations. -When you are done configuring, call the `build()` method to generate a `Client` -object. For further info, consult the <> section. - diff --git a/docs/logger.asciidoc b/docs/logger.asciidoc deleted file mode 100644 index 94f92a426..000000000 --- a/docs/logger.asciidoc +++ /dev/null @@ -1,31 +0,0 @@ -[[enabling_logger]] -=== Enabling the Logger - -Elasticsearch-PHP supports logging, but it is not enabled by default for -performance reasons. If you wish to enable logging, you need to select a logging -implementation, install it, then enable the logger in the Client. The -recommended logger is https://github.com/Seldaek/monolog[Monolog], but any -logger that implements the https://www.php-fig.org/psr/psr-3/[PSR-3] interface works. - -To begin using Monolog, just require it using composer: - -[source,shell] ----------------------------- -composer require monolog/monolog ----------------------------- - -Once Monolog (or another logger) is installed, you need to create a log object -and inject it into the client: - -[source,php] ----- -use Monolog\Logger; -use Monolog\Handler\StreamHandler; - -$logger = new Logger('name'); -$logger->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); - -$client = ClientBuilder::create() - ->setLogger($logger) // Set your custom logger - ->build(); // Build the client object ----- diff --git a/docs/namespaces.asciidoc b/docs/namespaces.asciidoc deleted file mode 100644 index 48e993524..000000000 --- a/docs/namespaces.asciidoc +++ /dev/null @@ -1,112 +0,0 @@ -[[namespaces]] -=== Namespaces - -The client has a number of "namespaces", which generally expose administrative -functionality. The namespaces correspond to the various administrative endpoints -in {es}. This is a complete list of namespaces: - - -[width="40%",options="header",frame="topbot"] -|============================ -| Namespace | Functionality -| `asyncSearch()` | Provide asyncronous search -| `autoscaling()` | Autoscaling features -| `cat()` | Compact and aligned text (CAT), mainly for terminal -| `ccr()` | Cross-cluster replication operations -| `cluster()` | Cluster-centric stats and info -| `danglingIndices()` | Dangling indices management -| `enrich()` | Enrich policy management -| `eql()` | Event Query Language -| `features()` | Manage features provided by Elasticsearch and plugins -| `fleet()` | Fleet’s use of Elasticsearch (experimental) -| `graph()` | Graph explore for documents and terms -| `ilm()` | Index lifecycle management (ILM) -| `indices()` | Index-centric stats and info -| `ingest()` | Ingest pipelines and processors -| `license()` | License management -| `logStash()` | Manage pipelines used by Logstash Central Management -| `migration()` | Designed for indirect use by Kibana’s Upgrade Assistant -| `ml()` | Machine learning features -| `monitoring()` | Monitoring features -| `monitoring()` | Monitoring features -| `nodes()` | Node-centric stats and info -| `rollup()` | Rollup features -| `searchableSnapshots()` | Searchable snapshots operations -| `security()` | Security features -| `shutdown()` | Prepare nodes for temporary or permanent shutdown -| `slm()` | Snapshot lifecycle management (SLM) -| `snapshot()` | Methods to snapshot/restore your cluster and indices -| `sql()` | Run SQL queries on Elasticsearch indices and data streams -| `ssl()` | SSL certificate management -| `tasks()` | Task management -| `textStructure()` | Finds the structure of text -| `transform()` | Transform features -| `watcher()` | Watcher create actions based on conditions -| `xpack()` | Retrieves information about the installed X-Pack features -|============================ - -Some methods are available in several different namespaces, which give you the -same information but grouped into different contexts. To see how these -namespaces work, let's look at the `_stats` output: - - -[source,php] ----- -$client = ClientBuilder::create()->build(); - -// Index Stats -// Corresponds to curl -XGET localhost:9200/_stats -$response = $client->indices()->stats(); - -// Node Stats -// Corresponds to curl -XGET localhost:9200/_nodes/stats -$response = $client->nodes()->stats(); - -// Cluster Stats -// Corresponds to curl -XGET localhost:9200/_cluster/stats -$response = $client->cluster()->stats(); ----- -{zwsp} + - -As you can see, the same `stats()` call is made through three different -namespaces. Sometimes the methods require parameters. These parameters work -just like any other method in the library. - -For example, we can requests index stats about a specific index, or multiple -indices: - -[source,php] ----- -$client = ClientBuilder::create()->build(); - -// Corresponds to curl -XGET localhost:9200/my_index/_stats -$params['index'] = 'my_index'; -$response = $client->indices()->stats($params); - -// Corresponds to curl -XGET localhost:9200/my_index1,my_index2/_stats -$params['index'] = ['my_index1', 'my_index2']; -$response = $client->indices()->stats($params); ----- -{zwsp} + - -The following example shows how you can add an alias to an existing index: - -[source,php] ----- -$params['body'] = [ - 'actions' => [ - [ - 'add' => [ - 'index' => 'myindex', - 'alias' => 'myalias' - ] - ] - ] -]; -$client->indices()->updateAliases($params); ----- - -Notice how both the `stats` calls and the `updateAliases` took a variety of -parameters, each according to what the particular API requires. The `stats` API -only requires an index name(s), while the `updateAliases` requires a body of -actions. \ No newline at end of file diff --git a/docs/node-pool.asciidoc b/docs/node-pool.asciidoc deleted file mode 100644 index fd309a908..000000000 --- a/docs/node-pool.asciidoc +++ /dev/null @@ -1,72 +0,0 @@ -[[node_pool]] -=== Node Pool - -The node pool is a component of https://github.com/elastic/elastic-transport-php[elastic-transport-php] -library used by elasticsearch-php. - -This component is responsible for maintaining the current list of nodes. -Theoretically, nodes are either dead or alive. However, in the real world, things -are never so clear. Nodes are sometimes in a gray-zone of _"probably dead but not -confirmed"_, _"timed-out but unclear why"_ or _"recently dead but now alive"_. -The job of the node pool is to manage this set of unruly connections and try to -provide the best behavior to the client. - -If a node pool is unable to find an alive node to query against, it -returns a `NoNodeAvailableException`. - -By default, the number of retries is equal to the number of nodes in your -cluster. For example, your cluster may have 10 nodes. You execute a -request and 9 out of the 10 nodes fail due to connection timeouts. The tenth -node succeeds and the query executes. The first nine nodes are marked dead -and their "dead" timers begin ticking. - -When the next request is sent to the client, nodes 1-9 are still considered -"dead", so they are skipped. The request is sent to the only known alive node -(#10), if this node fails, a `NoNodesAvailableException` is returned. - -The `SimpleNodePool` is the default node pool algorithm. It uses the following -default values: RoundRobin as `SelectorInterface` and NoResurrect as `ResurrectInterface`. - -The Round-robin algorithm select the nodes in order, from the first node in the array -to the latest. When arrived to the latest nodes, it will start again from the first. - -NOTE: The order of the nodes is randomized at runtime to maximize the usage of all the hosts. - -The `NoResurrect` option does not try to resurrect the node that has been marked as dead. -If you want, you can specify the `ElasticsearchResurrect` class to check if a node that -was dead is online again (resurrected). - -You can use the following configuration to enable the `ElasticsearchResurrect` class: - -[source,php] ----- -use Elastic\Transport\NodePool\Resurrect\ElasticsearchResurrect; -use Elastic\Transport\NodePool\Selector\RoundRobin; -use Elastic\Transport\NodePool\SimpleNodePool; - -$nodePool = new SimpleNodePool( - new RoundRobin(), - new ElasticsearchResurrect() -); - -$transport = TransportBuilder::create() - ->setHosts(['localhost:9200']) - ->setNodePool($nodePool) - ->build(); ----- - - -[discrete] -==== Using a custom NodePool, Selector and Resurrect - -If you want you can implement your custom node pool algorithm. We provided a -https://github.com/elastic/elastic-transport-php/blob/master/src/NodePool/NodePoolInterface.php[NodePoolInterface] - -You can also customize the Selector and the Resurrect components of the node pool. -You can use the following interfaces for the implementation: - -* https://github.com/elastic/elastic-transport-php/blob/master/src/NodePool/Selector/SelectorInterface.php[SelectorInterface] -* https://github.com/elastic/elastic-transport-php/blob/master/src/NodePool/Resurrect/ResurrectInterface.php[ResurrectInterface] - -For more information about the Node Pool you can read the -https://github.com/elastic/elastic-transport-php/blob/master/README.md[elastic-transport-php documentation]. diff --git a/docs/operations.asciidoc b/docs/operations.asciidoc deleted file mode 100644 index e17b64997..000000000 --- a/docs/operations.asciidoc +++ /dev/null @@ -1,28 +0,0 @@ -[[operations]] -== Operations - -This page contains the information you need to perform various {es} operations -by using the Client. - -This section is a crash-course overview of the client and its syntax. If you -are familiar with {es}, you'll notice that the methods are named just like REST -endpoints. - -You may also notice that the client is configured in a manner that facilitates -easy discovery via your IDE. All core actions are available under the `$client` -object (indexing, searching, getting, etc). Index and cluster management are -located under the `$client->indices()` and `$client->cluster()` objects, -respectively. - -* <> -* <> -* <> -* <> -* <> -* <> - -include::index-operations.asciidoc[] - -include::search-operations.asciidoc[] - -include::crud.asciidoc[] \ No newline at end of file diff --git a/docs/overview.asciidoc b/docs/overview.asciidoc deleted file mode 100644 index cc03742c0..000000000 --- a/docs/overview.asciidoc +++ /dev/null @@ -1,54 +0,0 @@ -[[overview]] -== Overview - -This is the official PHP client for {es}. It is designed to be a low-level -client that does not stray from the REST API. - -All methods closely match the REST API, and furthermore, match the method -structure of other language clients (Ruby, Python, and so on). We hope that this -consistency makes it easy to get started with a client and to seamlessly switch -from one language to the next with minimal effort. - -The client is designed to facilitate the API call using different way to read the -results using associative array, object, string or https://www.php-fig.org/psr/psr-7/[PSR-7]. - -Refer to the <> page for a step-by-step quick start with -the PHP client. - -[discrete] -[[psr-7-standard]] -=== PSR 7 standard - -The {es} PHP client uses the https://www.php-fig.org/psr/[PSR] 7 standard. This -standard is a community effort that contains a set of interfaces defined by the -PHP Framework Interop Group. For more information, refer to the -https://www.php-fig.org/psr/psr-7/[PSR 7 standard documentation]. - - -[discrete] -[[version-compatibility]] -=== {es} and PHP version Compatibility - -The {es} client is compatible with currently maintained PHP versions. - -Language clients are forward compatible; meaning that clients support -communicating with greater or equal minor versions of {es} without breaking. It -does not mean that the client automatically supports new features of newer {es} -versions; it is only possible after a release of a new client version. For -example, a 8.12 client version won't automatically support the new features of -the 8.13 version of {es}, the 8.13 client version is required for that. -{es} language clients are only backwards compatible with default distributions -and without guarantees made. - -|=== -| Elasticsearch Version | Elasticsearch-PHP Branch | Supported - -| main | main | -| 8.x | 8.x | 8.x -| 7.x | 7.x | 7.17 -|=== - - -* <> - -include::breaking-changes.asciidoc[] \ No newline at end of file diff --git a/docs/php_json_objects.asciidoc b/docs/php_json_objects.asciidoc deleted file mode 100644 index fa29496dd..000000000 --- a/docs/php_json_objects.asciidoc +++ /dev/null @@ -1,173 +0,0 @@ -[[php_json_objects]] -=== Dealing with JSON arrays and objects in PHP - -A common source of confusion with the client revolves around JSON arrays and -objects, and how to specify them in PHP. In particular, problems are caused by -empty objects and arrays of objects. This page shows you some common patterns -used in {es} JSON API and how to convert that to a PHP representation. - -[discrete] -==== Empty Objects - -The {es} API uses empty JSON objects in several locations which can cause -problems for PHP. Unlike other languages, PHP does not have a "short" notation -for empty objects and many developers are unaware how to specify an empty -object. - -Consider adding a highlight to a query: - -[source,json] ----- -{ - "query" : { - "match" : { - "content" : "quick brown fox" - } - }, - "highlight" : { - "fields" : { - "content" : {} <1> - } - } -} ----- -<1> This empty JSON object is what causes problems. - -The problem is that PHP will automatically convert `"content" : {}` into -`"content" : []`, which is no longer valid {es} DSL. We need to tell PHP that -the empty object is explicitly an object, not an array. To define this query in -PHP, you would do: - -[source,json] ----- -$params['body'] = array( - 'query' => array( - 'match' => array( - 'content' => 'quick brown fox' - ) - ), - 'highlight' => array( - 'fields' => array( - 'content' => new \stdClass() <1> - ) - ) -); -$results = $client->search($params); ----- -<1> We use the generic PHP stdClass object to represent an empty object. The -JSON now encodes correctly. - -By using an explicit stdClass object, we can force the `json_encode` parser to -correctly output an empty object, instead of an empty array. This verbose -solution is the only way to acomplish the goal in PHP... there is no "short" -version of an empty object. - -[discrete] -==== Arrays of Objects - -Another common pattern in {es} DSL is an array of objects. For example, consider -adding a sort to your query: - -[source,json] ----- -{ - "query" : { - "match" : { "content" : "quick brown fox" } - }, - "sort" : [ <1> - {"time" : {"order" : "desc"}}, - {"popularity" : {"order" : "desc"}} - ] -} ----- -<1> "sort" contains an array of JSON objects. - -This arrangement is very common, but the construction in PHP can be tricky since -it requires nesting arrays. The verbosity of PHP tends to obscure what is -actually going on. To construct an array of objects, you actually need an array -of arrays: - -[source,json] ----- -$params['body'] = array( - 'query' => array( - 'match' => array( - 'content' => 'quick brown fox' - ) - ), - 'sort' => array( <1> - array('time' => array('order' => 'desc')), <2> - array('popularity' => array('order' => 'desc')) <3> - ) -); -$results = $client->search($params); ----- -<1> This array encodes the `"sort" : []` array -<2> This array encodes the `{"time" : {"order" : "desc"}}` object -<3> This array encodes the `{"popularity" : {"order" : "desc"}}` object - -If you are on PHP 5.4+, we strongly encourage you to use the short array syntax. -It makes these nested arrays much simpler to read: - -[source,json] ----- -$params['body'] = [ - 'query' => [ - 'match' => [ - 'content' => 'quick brown fox' - ] - ], - 'sort' => [ - ['time' => ['order' => 'desc']], - ['popularity' => ['order' => 'desc']] - ] -]; -$results = $client->search($params); ----- - -[discrete] -==== Arrays of empty objects - -Occasionally, you'll encounter DSL that requires both of the previous patterns. -The function score query is a good example, it sometimes requires an array of -objects, and some of those objects might be empty JSON objects. - -Given this query: - -[source,json] ----- -{ - "query":{ - "function_score":{ - "functions":[ - { - "random_score":{} - } - ], - "boost_mode":"replace" - } - } -} ----- - -We can build it using the following PHP code: - - -[source,json] ----- -$params['body'] = array( - 'query' => array( - 'function_score' => array( - 'functions' => array( <1> - array( <2> - 'random_score' => new \stdClass() <3> - ) - ) - ) - ) -); -$results = $client->search($params); ----- -<1> This encodes the array of objects: `"functions" : []` -<2> This encodes an object inside the array: `{ "random_score": {} }` -<3> This encodes the empty JSON object: `"random_score": {}` \ No newline at end of file diff --git a/docs/redirects.asciidoc b/docs/redirects.asciidoc deleted file mode 100644 index c41a8cda4..000000000 --- a/docs/redirects.asciidoc +++ /dev/null @@ -1,24 +0,0 @@ -["appendix",role="exclude",id="redirects"] -= Deleted pages - -The following pages have moved or been deleted. - -[role="exclude",id="experimental_and_beta_apis"] -== Experimental and beta APIs - -This page has been removed. - -[role="exclude",id="security"] -== Security - -This page has moved. See <>. - -[role="exclude",id="quickstart"] -== Quickstart - -This page has moved. See <>. - -[role="exclude",id="ElasticsearchPHP_Endpoints"] -== Reference – Endpoints - -This page has been removed. \ No newline at end of file diff --git a/docs/reference/client-helpers.md b/docs/reference/client-helpers.md new file mode 100644 index 000000000..fec194e67 --- /dev/null +++ b/docs/reference/client-helpers.md @@ -0,0 +1,14 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/client-helpers.html +--- + +# Client helpers [client-helpers] + +The PHP client comes with the following helpers: + +* [Iterators](/reference/iterators.md) +* [ES|QL](/reference/esql.md) + + + diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md new file mode 100644 index 000000000..1395d7a1e --- /dev/null +++ b/docs/reference/configuration.md @@ -0,0 +1,30 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/configuration.html +--- + +# Configuration [configuration] + +Almost every aspect of the client is configurable. Most users only need to configure a few parameters to suit their needs, but it is possible to completely replace much of the internals if required. + +Custom configuration is accomplished before the client is instantiated, through the `ClientBuilder` class. You can find all the configuration options and check sample code that helps you replace the various components. + +To learn more about JSON in PHP, read [Dealing with JSON arrays and objects in PHP](/reference/php_json_objects.md). + +* [Host Configuration](/reference/host-config.md) +* [Set retries](/reference/set-retries.md) +* [HTTP Meta Data](/reference/http-meta-data.md) +* [Enabling the Logger](/reference/enabling_logger.md) +* [Configure the HTTP client](/reference/http-client.md) +* [Namespaces](/reference/namespaces.md) +* [Node Pool](/reference/node_pool.md) +* [Building the client from a configuration hash](/reference/node_pool.md#config-hash) + + + + + + + + + diff --git a/docs/reference/connecting.md b/docs/reference/connecting.md new file mode 100644 index 000000000..408bb8e22 --- /dev/null +++ b/docs/reference/connecting.md @@ -0,0 +1,341 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/connecting.html +--- + +# Connecting [connecting] + +This page contains the information you need to connect and use the Client with {{es}}. + +## Elastic Cloud [auth-ec] + +You can connect to [Elastic Cloud](https://www.elastic.co/cloud/) using an ***API key*** and a ***Cloud ID***: + +```php +$client = ClientBuilder::create() + ->setElasticCloudId('') + ->setApiKey('') + ->build(); +``` + +Where and can be retrieved using the Elastic Cloud web UI. + +You can get the `Cloud ID` from the `My deployment` page of your dashboard (see the red rectangle reported in the screenshot). + +![Elastic Cloud ID](images/cloud_id.png) + +You can generate an `API key` in the `Management` page under the section `Security`. + +![Create API key](images/create_api_key.png) + +When you click on `Create API key` button you can choose a name and set the other options (eg. restrict privileges, expire after time, etc). + +![Choose an API name](images/api_key_name.png) + +After this step you will get the `API key`in the API keys page. + +![Cloud API key](images/cloud_api_key.png) + +***IMPORTANT***: you need to copy and store the `API key`in a secure place, since you will not be able to view it again in Elastic Cloud. + + +## Security by default (HTTPS) [auth-http] + +{{es}} 8.0 offers [security by default](https://www.elastic.co/blog/introducing-simplified-elastic-stack-security), that means it uses [TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security) for protect the communication between client and server. + +In order to configure `elasticsearch-php` for connecting to {{es}} 8.0 we need to have the certificate authority file (CA). + +You can install {{es}} in different ways, for instance using [Docker](docs-content://deploy-manage/deploy/self-managed/install-elasticsearch-with-docker.md) you need to execute the followind command: + +```shell +docker pull docker.elastic.co/elasticsearch/elasticsearch:8.0.1 +``` + +Once you have the docker image installed you can execute {{es}}, for instance using a single-node cluster configuration, as follows: + +```shell +docker network create elastic +docker run --name es01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.0.1 +``` + +This command creates an `elastic` Docker network and start {{es}} using the port `9200` (default). + +When you run the docker image a password is generated for the `elastic` user and it’s printed to the terminal (you might need to scroll back a bit in the terminal to view it). You have to copy it since we will need to connect to {{es}}. + +Now that {{es}} is running we can get the `http_ca.crt` file certificate. We need to copy it from the docker instance, using the following command: + +```shell +docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt . +``` + +Once we have the `http_ca.crt` certificate and the `password`, copied during the start of {{es}} , we can use it to connect with `elasticsearch-php` as follows: + +```php +$client = ClientBuilder::create() + ->setHosts(['https://localhost:9200']) + ->setBasicAuthentication('elastic', 'password copied during Elasticsearch start') + ->setCABundle('path/to/http_ca.crt') + ->build(); +``` + +For more information about the Docker configuration of Elasticsearch you can read the official documentation [here](docs-content://deploy-manage/deploy/self-managed/install-elasticsearch-with-docker.md). + + +## Usage [client-usage] + +This section is a crash-course overview of the client and its syntax. If you are familiar with {{es}}, you’ll notice that the methods are named just like REST endpoints. + +You may also notice that the client is configured in a manner that facilitates easy discovery via your IDE. All core actions are available under the `$client` object (indexing, searching, getting, etc). Index and cluster management are located under the `$client->indices()` and `$client->cluster()` objects, respectively. + + +### Info API [_info_api] + +You can get information about the {{es}} instance using the `info()` API, as follows: + +```php +$response = $client->info(); +``` + +The response that you get back contains the information about {{es}}. The `$response` is an object of `Elastic\Elasticsearch\Response\Elasticsearch` class that implements `ElasticsearchInterface`, PSR-7 [ResponseInterface](https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface) and [ArrayAccess](https://www.php.net/manual/en/class.arrayaccess.php). + +This means the `$response` is a [PSR-7](https://www.php-fig.org/psr/psr-7/) object: + +```php +echo $response->getStatusCode(); // 200 +echo (string) $response->getBody(); // Response body in JSON +``` + +and also an "array", meaning you can access the response body as an associative array, as follows: + +```php +echo $response['version']['number']; // 8.0.0 + +var_dump($response->asArray()); // response body content as array +``` + +Moreover, you can also access the response body as object, string or bool: + +```php +echo $response->version->number; // 8.0.0 + +var_dump($response->asObject()); // response body content as object +var_dump($response->asString()); // response body as string (JSON) +var_dump($response->asBool()); // true if HTTP response code between 200 and 300 +``` + + +### Indexing a document [_indexing_a_document] + +To index a document, we need to specify three pieces of information: index, id and a document body. This is done by constructing an associative array of key:value pairs. The request body is itself an associative array with key:value pairs corresponding to the data in your document: + +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id', + 'body' => ['testField' => 'abc'] +]; + +$response = $client->index($params); +print_r($response->asArray()); +``` + +The response that you get back indicates that the document was created in the index that you specified. The response can be rendered as associatve array using the `asArray()` function. The array response contains a decoded version of the JSON that Elasticsearch returns: + +```php +Array +( + [_index] => my_index + [_type] => _doc + [_id] => my_id + [_version] => 1 + [created] => 1 +) +``` + + +### Set the body as JSON string [_set_the_body_as_json_string] + +If you want you can specify the `body`parameter as JSON string. This can be useful for testing (eg. copy & paste from online code examples) or if you have already some JSON documents to be stored in Elasticsearch. + +For instance, the previous index example can be re-written as follows: + +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id', + 'body' => '{"testField" : "abc"}' +]; + +$response = $client->index($params); +print_r($response->asArray()); +``` + + +### Getting a document [_getting_a_document] + +Let’s get the document that we just indexed. This returns the document: + +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id' +]; + +$response = $client->get($params); +print_r($response->asArray()); +``` + +The response contains metadata such as index, version, and so on as well as a `_source` field, which is the original document you sent to {{es}}. + +```php +Array +( + [_index] => my_index + [_type] => _doc + [_id] => my_id + [_version] => 1 + [found] => 1 + [_source] => Array + ( + [testField] => abc + ) + +) +``` + + +### Searching for a document [_searching_for_a_document] + +Searching is a hallmark of {{es}}, so let’s perform a search. We are going to use the `match` query as a demonstration: + +```php +$params = [ + 'index' => 'my_index', + 'body' => [ + 'query' => [ + 'match' => [ + 'testField' => 'abc' + ] + ] + ] +]; + +$response = $client->search($params); +print_r($response->asArray()); +``` + +The response here is different from the previous ones. You can see metadata (`took`, `timed_out`, etc.) and an array named `hits`. This represents your search results. Inside of `hits` is another array named `hits`, which contains individual search results: + +```php +Array +( + [took] => 1 + [timed_out] => + [_shards] => Array + ( + [total] => 5 + [successful] => 5 + [failed] => 0 + ) + + [hits] => Array + ( + [total] => 1 + [max_score] => 0.30685282 + [hits] => Array + ( + [0] => Array + ( + [_index] => my_index + [_type] => _doc + [_id] => my_id + [_score] => 0.30685282 + [_source] => Array + ( + [testField] => abc + ) + ) + ) + ) +) +``` + + +### Deleting a document [_deleting_a_document] + +Alright, let’s go ahead and delete the document that we added previously: + +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id' +]; + +$response = $client->delete($params); +print_r($response->asArray()); +``` + +This syntax is identical to the `get` syntax. The only difference is the operation: `delete` instead of `get`. The response confirms the document is deleted: + +```php +Array +( + [found] => 1 + [_index] => my_index + [_type] => _doc + [_id] => my_id + [_version] => 2 +) +``` + + +### Deleting an index [_deleting_an_index_2] + +Due to the dynamic nature of {{es}}, the first document you added automatically built an index with some default settings. Delete that index and specify your own settings later: + +```php +$deleteParams = [ + 'index' => 'my_index' +]; +$response = $client->indices()->delete($deleteParams); +print_r($response->asArray()); +``` + +The response: + +```php +Array +( + [acknowledged] => 1 +) +``` + + +### Creating an index [_creating_an_index_2] + +Now that you are starting fresh (no data or index), add a new index with custom settings: + +```php +$params = [ + 'index' => 'my_index', + 'body' => [ + 'settings' => [ + 'number_of_shards' => 2, + 'number_of_replicas' => 0 + ] + ] +]; + +$response = $client->indices()->create($params); +print_r($response->asArray()); +``` + +{{es}} now creates that index with your chosen settings and return an acknowledgement: + +```php +Array +( + [acknowledged] => 1 +) +``` + diff --git a/docs/reference/deleting_documents.md b/docs/reference/deleting_documents.md new file mode 100644 index 000000000..cfb0bcce3 --- /dev/null +++ b/docs/reference/deleting_documents.md @@ -0,0 +1,21 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/deleting_documents.html +--- + +# Deleting documents [deleting_documents] + +Finally, you can delete documents by specifying their full `/index/_doc_/id` path: + +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id' +]; + +// Delete doc at /my_index/_doc_/my_id +$response = $client->delete($params); +``` + +​
+ diff --git a/docs/reference/enabling_logger.md b/docs/reference/enabling_logger.md new file mode 100644 index 000000000..317d199b4 --- /dev/null +++ b/docs/reference/enabling_logger.md @@ -0,0 +1,29 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/enabling_logger.html +--- + +# Enabling the Logger [enabling_logger] + +Elasticsearch-PHP supports logging, but it is not enabled by default for performance reasons. If you wish to enable logging, you need to select a logging implementation, install it, then enable the logger in the Client. The recommended logger is [Monolog](https://github.com/Seldaek/monolog), but any logger that implements the [PSR-3](https://www.php-fig.org/psr/psr-3/) interface works. + +To begin using Monolog, just require it using composer: + +```shell +composer require monolog/monolog +``` + +Once Monolog (or another logger) is installed, you need to create a log object and inject it into the client: + +```php +use Monolog\Logger; +use Monolog\Handler\StreamHandler; + +$logger = new Logger('name'); +$logger->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); + +$client = ClientBuilder::create() + ->setLogger($logger) // Set your custom logger + ->build(); // Build the client object +``` + diff --git a/docs/helpers/esql.asciidoc b/docs/reference/esql.md similarity index 64% rename from docs/helpers/esql.asciidoc rename to docs/reference/esql.md index 7e1d0ee64..a4cd11655 100644 --- a/docs/helpers/esql.asciidoc +++ b/docs/reference/esql.md @@ -1,37 +1,28 @@ -[[esql]] -=== ES|QL in the PHP client -++++ -ES|QL -++++ +--- +navigation_title: "ES|QL" +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/esql.html +--- + +# ES|QL in the PHP client [esql] + -This page helps you understand and use {ref}/esql.html[ES|QL] in the -PHP client. +This page helps you understand and use [ES|QL](docs-content://explore-analyze/query-filter/languages/esql.md) in the PHP client. There are two ways to use ES|QL in the PHP client: -* Use the Elasticsearch {es-docs}/esql-apis.html[ES|QL API] directly: This -is the most flexible approach, but it's also the most complex because you must handle -results in their raw form. You can choose the precise format of results, -such as JSON, CSV, or text. -* Use ES|QL `mapTo($class)` helper. This mapper takes care of parsing the raw -response and converting into an array of objects. If you don't specify the class -using the `$class` parameter, the mapper uses https://www.php.net/manual/en/class.stdclass.php[stdClass]. +* Use the Elasticsearch [ES|QL API](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-esql) directly: This is the most flexible approach, but it’s also the most complex because you must handle results in their raw form. You can choose the precise format of results, such as JSON, CSV, or text. +* Use ES|QL `mapTo($class)` helper. This mapper takes care of parsing the raw response and converting into an array of objects. If you don’t specify the class using the `$class` parameter, the mapper uses [stdClass](https://www.php.net/manual/en/class.stdclass.php). -[discrete] -[[esql-how-to]] -==== How to use the ES|QL API -The {es-docs}/esql-query-api.html[ES|QL query API] allows you to specify how -results should be returned. You can choose a -{es-docs}/esql-rest.html#esql-rest-format[response format] such as CSV, text, or -JSON, then fine-tune it with parameters like column separators -and locale. +## How to use the ES|QL API [esql-how-to] -The default response from Elasticsearch is a table in JSON, where `columns` -is an array of descriptions and `values` is an array of rows containing the values. +The [ES|QL query API](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-esql) allows you to specify how results should be returned. You can choose a [response format](docs-content://explore-analyze/query-filter/languages/esql-rest.md#esql-rest-format) such as CSV, text, or JSON, then fine-tune it with parameters like column separators and locale. -[[query-script]] -Here's an example query and PHP script: +The default response from Elasticsearch is a table in JSON, where `columns` is an array of descriptions and `values` is an array of rows containing the values. + +$$$query-script$$$ +Here’s an example query and PHP script: ```php $query = <<>) produces the following output: +Using this response, the PHP script (provided [above](#query-script)) produces the following output: ```php author : Stephen King @@ -133,7 +124,7 @@ $result = $client->esql()->query([ var_dump($result->asArray()); ``` -The response looks something like this: +The response looks something like this: ```json array(12) { @@ -168,19 +159,15 @@ array(12) { string(4) "2002" } ``` -In the response, the first row contains the column descriptions and the other rows contain -the values, using a plain PHP array. + +In the response, the first row contains the column descriptions and the other rows contain the values, using a plain PHP array. -[discrete] -[[esql-custom-mapping]] -==== Define your own mapping +## Define your own mapping [esql-custom-mapping] -Although the `esql()->query()` API covers many use cases, your application -might require a custom mapping. +Although the `esql()->query()` API covers many use cases, your application might require a custom mapping. -You can map the ES|QL result into an array of objects, using the `mapTo()` -function. Here's an example: +You can map the ES|QL result into an array of objects, using the `mapTo()` function. Here’s an example: ```php $result = $client->esql()->query([ @@ -199,10 +186,9 @@ foreach ($books as $book) { } ``` -You can also specify a class name for the mapping. -All the values will be assigned to the properties of the class. +You can also specify a class name for the mapping. All the values will be assigned to the properties of the class. -Here's an example mapper that returns an array of `Book` objects: +Here’s an example mapper that returns an array of `Book` objects: ```php class Book @@ -218,4 +204,5 @@ $result = $client->esql()->query([ 'body' => ['query' => $query] ]); $books = $result->mapTo(Book::class); // Array of Book -``` \ No newline at end of file +``` + diff --git a/docs/getting-started.asciidoc b/docs/reference/getting-started.md similarity index 60% rename from docs/getting-started.asciidoc rename to docs/reference/getting-started.md index e98facd81..31208841b 100644 --- a/docs/getting-started.asciidoc +++ b/docs/reference/getting-started.md @@ -1,88 +1,77 @@ -[[getting-started-php]] -== Getting started +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html + - https://www.elastic.co/guide/en/serverless/current/elasticsearch-php-client-getting-started.html +--- -This page guides you through the installation process of the PHP client, shows -you how to instantiate the client, and how to perform basic Elasticsearch -operations with it. +# Getting started [getting-started-php] -[discrete] -=== Requirements +This page guides you through the installation process of the PHP client, shows you how to instantiate the client, and how to perform basic Elasticsearch operations with it. -* http://getcomposer.org[composer] -If you don't have composer you can install it by running the following commands: +### Requirements [_requirements] -[source,shell] --------------------------- +* [composer](http://getcomposer.org) + +If you don’t have composer you can install it by running the following commands: + +```shell curl -s http://getcomposer.org/installer | php php composer.phar install --------------------------- +``` -[discrete] -=== Installation +### Installation [_installation] To install the latest version of the client, run the following command: -[source,shell] --------------------------- +```shell composer require elasticsearch/elasticsearch --------------------------- +``` -When you have installed elasticsearch-php you can start using it with the -`Client` class. You can use the `ClientBuilder` class to create this object: +When you have installed elasticsearch-php you can start using it with the `Client` class. You can use the `ClientBuilder` class to create this object: -[source,php] --------------------------- +```php require 'vendor/autoload.php'; $client = Elastic\Elasticsearch\ClientBuilder::create()->build(); --------------------------- +``` -Refer to the <> page to learn more. +Refer to the [*Installation*](/reference/installation.md) page to learn more. -[discrete] -=== Connecting +### Connecting [_connecting] -You can connect to the Elastic Cloud using an API key and the Elasticsearch -endpoint. +You can connect to the Elastic Cloud using an API key and the Elasticsearch endpoint. -[source,php] ----- +```php $client = ClientBuilder::create() ->setHosts(['']) ->setApiKey('') ->build(); ----- +``` -Your Elasticsearch endpoint can be found on the **My deployment** page of your -deployment: +Your Elasticsearch endpoint can be found on the ***My deployment*** page of your deployment: -image::images/es_endpoint.jpg[alt="Finding Elasticsearch endpoint",align="center"] +![Finding Elasticsearch endpoint](images/es_endpoint.jpg) -You can generate an API key on the **Management** page under Security. +You can generate an API key on the ***Management*** page under Security. -image::images/create_api_key.png[alt="Create API key",align="center"] +![Create API key](images/create_api_key.png) -For other connection options, refer to the <> section. +For other connection options, refer to the [*Connecting*](/reference/connecting.md) section. -[discrete] -=== Operations +### Operations [_operations] -Time to use Elasticsearch! This section walks you through the basic, and most -important, operations of Elasticsearch. For more operations and more advanced -examples, refer to the <> page. +Time to use Elasticsearch! This section walks you through the basic, and most important, operations of Elasticsearch. For more operations and more advanced examples, refer to the [*Operations*](/reference/operations.md) page. -[discrete] -==== Creating an index +#### Creating an index [_creating_an_index] This is how you create the `my_index` index: -[source,php] ----- +```php $client = ClientBuilder::create()->build(); $params = [ 'index' => 'my_index' @@ -90,16 +79,14 @@ $params = [ // Create the index $response = $client->indices()->create($params); ----- +``` -[discrete] -==== Indexing documents +#### Indexing documents [_indexing_documents] This is a simple way of indexing a document: -[source,php] ----- +```php $params = [ 'index' => 'my_index', 'body' => [ 'testField' => 'abc'] @@ -107,13 +94,11 @@ $params = [ // Document will be indexed to my_index/_doc/ $response = $client->index($params); ----- +``` You can bulk index documents with batches in a slightly more complex way: -.Bulk indexing with batches -[source,php] ----- +```php $params = ['body' => []]; for ($i = 1; $i <= 1234567; $i++) { @@ -145,16 +130,14 @@ for ($i = 1; $i <= 1234567; $i++) { if (!empty($params['body'])) { $responses = $client->bulk($params); } ----- +``` -[discrete] -==== Getting documents +#### Getting documents [_getting_documents] You can get documents by using the following code: -[source,php] ----- +```php $params = [ 'index' => 'my_index', 'id' => 'my_id' @@ -162,16 +145,14 @@ $params = [ // Get doc at /my_index/_doc/my_id $response = $client->get($params); ----- +``` -[discrete] -==== Searching documents +#### Searching documents [_searching_documents] -This is how you can create a single match query with the PHP client: +This is how you can create a single match query with the PHP client: -[source,php] ----- +```php $params = [ 'index' => 'my_index', 'body' => [ @@ -184,16 +165,14 @@ $params = [ ]; $results = $client->search($params); ----- +``` -[discrete] -==== Updating documents +#### Updating documents [_updating_documents] This is how you can update a document, for example to add a new field: -[source,php] ----- +```php $params = [ 'index' => 'my_index', 'id' => 'my_id', @@ -206,14 +185,12 @@ $params = [ // Update doc at /my_index/_doc/my_id $response = $client->update($params); ----- +``` -[discrete] -==== Deleting documents +#### Deleting documents [_deleting_documents] -[source,php] ----- +```php $params = [ 'index' => 'my_index', 'id' => 'my_id' @@ -221,20 +198,18 @@ $params = [ // Delete doc at /my_index/_doc_/my_id $response = $client->delete($params); ----- +``` -[discrete] -==== Deleting an index +#### Deleting an index [_deleting_an_index] -[source,php] ----- +```php $params = ['index' => 'my_index']; $response = $client->indices()->delete($params); ----- +``` + +## Further reading [_further_reading] -[discrete] -== Further reading +* Use [*Client helpers*](/reference/client-helpers.md) for a more confortable experience with the APIs. -* Use <> for a more confortable experience with the APIs. \ No newline at end of file diff --git a/docs/reference/getting_documents.md b/docs/reference/getting_documents.md new file mode 100644 index 000000000..8f0523a93 --- /dev/null +++ b/docs/reference/getting_documents.md @@ -0,0 +1,21 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting_documents.html +--- + +# Getting documents [getting_documents] + +{{es}} provides realtime GETs of documents. This means that as soon as the document is indexed and your client receives an acknowledgement, you can immediately retrieve the document from any shard. Get operations are performed by requesting a document by its full `index/type/id` path: + +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id' +]; + +// Get doc at /my_index/_doc/my_id +$response = $client->get($params); +``` + +​
+ diff --git a/docs/host-config.asciidoc b/docs/reference/host-config.md similarity index 68% rename from docs/host-config.asciidoc rename to docs/reference/host-config.md index 81b8c7b86..818116d45 100644 --- a/docs/host-config.asciidoc +++ b/docs/reference/host-config.md @@ -1,19 +1,17 @@ -[[host-config]] -=== Host Configuration +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/host-config.html +--- + +# Host Configuration [host-config] The client offers an options to configure hosts. -The most common configuration is telling the client about your cluster: the -number of nodes, their addresses, and ports. If no hosts are specified, the -client attempts to connect to `localhost:9200`. +The most common configuration is telling the client about your cluster: the number of nodes, their addresses, and ports. If no hosts are specified, the client attempts to connect to `localhost:9200`. -This behavior can be changed by using the `setHosts()` method on -`ClientBuilder`. The method accepts an array of values, each entry corresponding -to one node in your cluster. The format of the host can vary, depending on your -needs (ip vs hostname, port, ssl, etc). +This behavior can be changed by using the `setHosts()` method on `ClientBuilder`. The method accepts an array of values, each entry corresponding to one node in your cluster. The format of the host can vary, depending on your needs (ip vs hostname, port, ssl, etc). -[source,php] ----- +```php $hosts = [ '192.168.1.1:9200', // IP + Port '192.168.1.2', // Just IP @@ -25,13 +23,11 @@ $hosts = [ $client = ClientBuilder::create() // Instantiate a new ClientBuilder ->setHosts($hosts) // Set the hosts ->build(); // Build the client object ----- +``` -Notice that the `ClientBuilder` object allows chaining method calls for brevity. -It is also possible to call the methods individually: +Notice that the `ClientBuilder` object allows chaining method calls for brevity. It is also possible to call the methods individually: -[source,php] ----- +```php $hosts = [ '192.168.1.1:9200', // IP + Port '192.168.1.2', // Just IP @@ -43,4 +39,5 @@ $hosts = [ $clientBuilder = ClientBuilder::create(); // Instantiate a new ClientBuilder $clientBuilder->setHosts($hosts); // Set the hosts $client = $clientBuilder->build(); // Build the client object ----- +``` + diff --git a/docs/http-client.asciidoc b/docs/reference/http-client.md similarity index 54% rename from docs/http-client.asciidoc rename to docs/reference/http-client.md index 170f1473f..dad38e612 100644 --- a/docs/http-client.asciidoc +++ b/docs/reference/http-client.md @@ -1,59 +1,47 @@ -[[http-client]] -=== Configure the HTTP client +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/http-client.html +--- -Elasticsearch-php uses https://github.com/elastic/elastic-transport-php[elastic-transport-php] -for managing the HTTP tranport. This is an HTTP client provided by Elastic -that can be configured to use any https://www.php-fig.org/psr/psr-18/[PSR-18] client library. +# Configure the HTTP client [http-client] -Elasticsearch-php uses Guzzle as default HTTP client but you can specify -any other client using the `setHttpClient()` function, as follows: +Elasticsearch-php uses [elastic-transport-php](https://github.com/elastic/elastic-transport-php) for managing the HTTP tranport. This is an HTTP client provided by Elastic that can be configured to use any [PSR-18](https://www.php-fig.org/psr/psr-18/) client library. +Elasticsearch-php uses Guzzle as default HTTP client but you can specify any other client using the `setHttpClient()` function, as follows: -[source,php] ----- +```php use Symfony\Component\HttpClient\Psr18Client; $client = ClientBuilder::create() ->setHttpClient(new Psr18Client) ->build(); ----- +``` -For instance, in this example we used the https://symfony.com/doc/current/http_client.html[Symfony HTTP Client]. +For instance, in this example we used the [Symfony HTTP Client](https://symfony.com/doc/current/http_client.html). -[discrete] -==== Setting the client options -If you want you can set the options for a specific PSR-18 client -using the `ClientBuilder::setHttpClientOptions($options)` method. -The `$options` is an array of key:value options that are -specifics to the HTTP client used. +## Setting the client options [_setting_the_client_options] -For instance, if you are using Guzzle (default) and you need to use a -https://docs.guzzlephp.org/en/stable/request-options.html#proxy[proxy] -you can use the following settings: +If you want you can set the options for a specific PSR-18 client using the `ClientBuilder::setHttpClientOptions($options)` method. The `$options` is an array of key:value options that are specifics to the HTTP client used. -[source,php] ----- +For instance, if you are using Guzzle (default) and you need to use a [proxy](https://docs.guzzlephp.org/en/stable/request-options.html#proxy) you can use the following settings: + +```php $client = ClientBuilder::create() ->setHttpClientOptions([ 'proxy' => 'http://localhost:8125' ]) ->build(); ----- +``` -[discrete] -==== Configuring the HTTP async client +## Configuring the HTTP async client [_configuring_the_http_async_client] -Elasticsearch-php can works using an asyncronous HTTP client that implements -the https://github.com/php-http/httplug/blob/master/src/HttpAsyncClient.php[HttpAsyncClient] interface -of the http://httplug.io/[HTTPlug] project. +Elasticsearch-php can works using an asyncronous HTTP client that implements the [HttpAsyncClient](https://github.com/php-http/httplug/blob/master/src/HttpAsyncClient.php) interface of the [HTTPlug](http://httplug.io/) project. -Unfortunately, there is not yet a PSR standard for HTTP async client. -We used the HTTPlug interface that is quite simple, as follows: +Unfortunately, there is not yet a PSR standard for HTTP async client. We used the HTTPlug interface that is quite simple, as follows: -[source,php] ----- +```php namespace Http\Client; use Http\Promise\Promise; @@ -66,13 +54,11 @@ interface HttpAsyncClient */ public function sendAsyncRequest(RequestInterface $request); } ----- +``` -You can enable the HTTP async in elasticsearch-php using the `setAsync()` function, -as follows: +You can enable the HTTP async in elasticsearch-php using the `setAsync()` function, as follows: -[source,php] ----- +```php $client = ClientBuilder::create() ->build(); @@ -87,20 +73,15 @@ for ($i=0; $i<10; $i++) { ] ]); } ----- +``` -The previous example stores 10 random documents using the HTTP asyncronous feature. -The `$promise` response is an object of https://github.com/php-http/promise/blob/master/src/Promise.php[promises/a+] -interface. +The previous example stores 10 random documents using the HTTP asyncronous feature. The `$promise` response is an object of [promises/a+](https://github.com/php-http/promise/blob/master/src/Promise.php) interface. -A promise represents a single result of an asynchronous operation. -It is not necessarily available at a specific time, but should become in the future. +A promise represents a single result of an asynchronous operation. It is not necessarily available at a specific time, but should become in the future. -If you need to know the response you can just call the `wait()` function, -as follows: +If you need to know the response you can just call the `wait()` function, as follows: -[source,php] ----- +```php $promise = $client->index([ 'index' => 'my-index', 'body' => [ @@ -109,16 +90,13 @@ $promise = $client->index([ ]); $result = $promise->wait(); print_r($result->asArray()); ----- +``` -The `wait()` function block the execution until we will recevie the -HTTP response from {es}. +The `wait()` function block the execution until we will recevie the HTTP response from {{es}}. -Instead of waiting, you can handle things asynchronously using the -`then()` function, as follows: +Instead of waiting, you can handle things asynchronously using the `then()` function, as follows: -[source,php] ----- +```php use Psr\Http\Message\ResponseInterface; // PSR-7 $promise = $client->index([ @@ -141,8 +119,7 @@ $promise->then( throw $exception; } ); ----- +``` -More information about Promise are available at the -https://docs.php-http.org/en/latest/components/promise.html[HTTPlug documentation page]. +More information about Promise are available at the [HTTPlug documentation page](https://docs.php-http.org/en/latest/components/promise.html). diff --git a/docs/reference/http-meta-data.md b/docs/reference/http-meta-data.md new file mode 100644 index 000000000..08ce86404 --- /dev/null +++ b/docs/reference/http-meta-data.md @@ -0,0 +1,24 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/http-meta-data.html +--- + +# HTTP Meta Data [http-meta-data] + +By default, the client sends some meta data about the HTTP connection using custom headers. + +You can disable or enable it using the following methods: + +## Elastic Meta Header [_elastic_meta_header] + +The client sends a `x-elastic-client-meta` header by default. This header is used to collect meta data about the versions of the components used by the client. For instance, a value of `x-elastic-client-meta` can be `es=8.0.0-s,php=8.0.0,t=8.0.0-s,a=0,gu=7.4.2, where each value is the version of `es=Elasticsearch`, `t` is the transport version (same of client), `a` is asyncronouts (`0=false` by default) and `gu=Guzzle`. + +If you would like to disable it you can use the `setElasticMetaHeader()` method, as follows: + +```php +$client = Elasticsearch\ClientBuilder::create() + ->setElasticMetaHeader(false) + ->build(); +``` + + diff --git a/docs/images/api_key_name.png b/docs/reference/images/api_key_name.png similarity index 100% rename from docs/images/api_key_name.png rename to docs/reference/images/api_key_name.png diff --git a/docs/images/cloud_api_key.png b/docs/reference/images/cloud_api_key.png similarity index 100% rename from docs/images/cloud_api_key.png rename to docs/reference/images/cloud_api_key.png diff --git a/docs/images/cloud_id.png b/docs/reference/images/cloud_id.png similarity index 100% rename from docs/images/cloud_id.png rename to docs/reference/images/cloud_id.png diff --git a/docs/images/create_api_key.png b/docs/reference/images/create_api_key.png similarity index 100% rename from docs/images/create_api_key.png rename to docs/reference/images/create_api_key.png diff --git a/docs/images/es_endpoint.jpg b/docs/reference/images/es_endpoint.jpg similarity index 100% rename from docs/images/es_endpoint.jpg rename to docs/reference/images/es_endpoint.jpg diff --git a/docs/reference/index.md b/docs/reference/index.md new file mode 100644 index 000000000..1622f8fae --- /dev/null +++ b/docs/reference/index.md @@ -0,0 +1,37 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/overview.html +--- + +# PHP [overview] + +This is the official PHP client for {{es}}. It is designed to be a low-level client that does not stray from the REST API. + +All methods closely match the REST API, and furthermore, match the method structure of other language clients (Ruby, Python, and so on). We hope that this consistency makes it easy to get started with a client and to seamlessly switch from one language to the next with minimal effort. + +The client is designed to facilitate the API call using different way to read the results using associative array, object, string or [PSR-7](https://www.php-fig.org/psr/psr-7/). + +Refer to the [*Getting started*](/reference/getting-started.md) page for a step-by-step quick start with the PHP client. + + +## PSR 7 standard [psr-7-standard] + +The {{es}} PHP client uses the [PSR](https://www.php-fig.org/psr/) 7 standard. This standard is a community effort that contains a set of interfaces defined by the PHP Framework Interop Group. For more information, refer to the [PSR 7 standard documentation](https://www.php-fig.org/psr/psr-7/). + + +## {{es}} and PHP version Compatibility [version-compatibility] + +The {{es}} client is compatible with currently maintained PHP versions. + +Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of {{es}} without breaking. It does not mean that the client automatically supports new features of newer {{es}} versions; it is only possible after a release of a new client version. For example, a 8.12 client version won’t automatically support the new features of the 8.13 version of {{es}}, the 8.13 client version is required for that. {{es}} language clients are only backwards compatible with default distributions and without guarantees made. + +| Elasticsearch Version | Elasticsearch-PHP Branch | Supported | +| --- | --- | --- | +| main | main | | +| 8.x | 8.x | 8.x | +| 7.x | 7.x | 7.17 | + +* [Breaking changes from 7.x](https://www.elastic.co/guide/en/elasticsearch/client/php-api/7.17/breaking_changes.html) + + diff --git a/docs/index-operations.asciidoc b/docs/reference/index_management.md similarity index 71% rename from docs/index-operations.asciidoc rename to docs/reference/index_management.md index c40dba055..7fc6e165a 100644 --- a/docs/index-operations.asciidoc +++ b/docs/reference/index_management.md @@ -1,19 +1,18 @@ -[[index_management]] -=== Index management operations +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index_management.html +--- -Index management operations allow you to manage the indices in your {es} -cluster, such as creating, deleting and updating indices and their -mappings/settings. +# Index management operations [index_management] -[discrete] -==== Create an index +Index management operations allow you to manage the indices in your {{es}} cluster, such as creating, deleting and updating indices and their mappings/settings. -The index operations are all contained under a distinct namespace, separated -from other methods that are on the root client object. As an example, let's -create a new index: -[source,php] ----- +### Create an index [_create_an_index] + +The index operations are all contained under a distinct namespace, separated from other methods that are on the root client object. As an example, let’s create a new index: + +```php $client = ClientBuilder::create()->build(); $params = [ 'index' => 'my_index' @@ -21,15 +20,13 @@ $params = [ // Create the index $response = $client->indices()->create($params); ----- -{zwsp} + +``` + +​
-You can specify any parameters that would normally be included in a new index -creation API. All parameters that would normally go in the request body are -located in the 'body' parameter: +You can specify any parameters that would normally be included in a new index creation API. All parameters that would normally go in the request body are located in the *body* parameter: -[source,php] ----- +```php $client = ClientBuilder::create()->build(); $params = [ 'index' => 'my_index', @@ -57,19 +54,16 @@ $params = [ // Create the index with mappings and settings now $response = $client->indices()->create($params); ----- -{zwsp} + +``` + +​
+ -[discrete] -==== Create an index (advanced example) +### Create an index (advanced example) [_create_an_index_advanced_example] -This is a more complicated example of creating an index, showing how to define -analyzers, tokenizers, filters and index settings. Although essentially the same -as the previous example, the more complicated example can be helpful for "real -world" usage of the client since this particular syntax is easy to mess up. +This is a more complicated example of creating an index, showing how to define analyzers, tokenizers, filters and index settings. Although essentially the same as the previous example, the more complicated example can be helpful for "real world" usage of the client since this particular syntax is easy to mess up. -[source,php] ----- +```php $params = [ 'index' => 'reuters', 'body' => [ @@ -130,33 +124,31 @@ $params = [ ] ]; $client->indices()->create($params); ----- -<1> The top level `settings` contains config about the index (# of shards, etc) -as well as analyzers. -<2> `analysis` is nested inside of `settings`, and contains tokenizers, filters, -char filters and analyzers. -<3> `mappings` is another element nested inside of `settings`, and contains the -mappings for various types. +``` -[discrete] -==== Delete an index +1. The top level `settings` contains config about the index (# of shards, etc) as well as analyzers. +2. `analysis` is nested inside of `settings`, and contains tokenizers, filters, char filters and analyzers. +3. `mappings` is another element nested inside of `settings`, and contains the mappings for various types. + + + +### Delete an index [_delete_an_index] Deleting an index is very simple: -[source,php] ----- +```php $params = ['index' => 'my_index']; $response = $client->indices()->delete($params); ----- -{zwsp} + +``` + +​
+ -[discrete] -=== PUT Settings API +## PUT Settings API [_put_settings_api] The PUT Settings API allows you to modify any index setting that is dynamic: -[source,php] ----- +```php $params = [ 'index' => 'my_index', 'body' => [ @@ -168,17 +160,16 @@ $params = [ ]; $response = $client->indices()->putSettings($params); ----- -{zwsp} + +``` -[discrete] -==== GET Settings API +​
-The GET Settings API shows you the currently configured settings for one or more -indices: -[source,php] ----- +### GET Settings API [_get_settings_api] + +The GET Settings API shows you the currently configured settings for one or more indices: + +```php // Get settings for one index $params = ['index' => 'my_index']; $response = $client->indices()->getSettings($params); @@ -188,16 +179,16 @@ $params = [ 'index' => [ 'my_index', 'my_index2' ] ]; $response = $client->indices()->getSettings($params); ----- -{zwsp} + +``` + +​
-[discrete] -==== PUT Mappings API -The PUT Mappings API allows you to modify or add to an existing index's mapping. +### PUT Mappings API [_put_mappings_api] -[source,php] ----- +The PUT Mappings API allows you to modify or add to an existing index’s mapping. + +```php // Set the index and type $params = [ 'index' => 'my_index', @@ -219,17 +210,16 @@ $params = [ // Update the index mapping $client->indices()->putMapping($params); ----- -{zwsp} + +``` + +​
-[discrete] -==== GET Mappings API -The GET Mappings API returns the mapping details about your indices. Depending -on the mappings that you wish to retrieve, you can specify one of more indices: +### GET Mappings API [_get_mappings_api] -[source,php] ----- +The GET Mappings API returns the mapping details about your indices. Depending on the mappings that you wish to retrieve, you can specify one of more indices: + +```php // Get mappings for all indices $response = $client->indices()->getMapping(); @@ -242,25 +232,20 @@ $params = [ 'index' => [ 'my_index', 'my_index2' ] ]; $response = $client->indices()->getMapping($params); ----- -{zwsp} + +``` + +​
-[discrete] -==== Other APIs in the indices namespace -There are a number of other APIs in the indices namespace that allow you to -manage your {es} indices (add/remove templates, flush segments, close indices, -etc). +### Other APIs in the indices namespace [_other_apis_in_the_indices_namespace] -If you use an IDE with autocompletion, you should be able to easily explore the -indices namespace by typing: +There are a number of other APIs in the indices namespace that allow you to manage your {{es}} indices (add/remove templates, flush segments, close indices, etc). -[source,php] ----- +If you use an IDE with autocompletion, you should be able to easily explore the indices namespace by typing: + +```php $client->indices()-> ----- +``` + +And perusing the list of available methods. Alternatively, browsing the `\Elasticsearch\Namespaces\Indices.php` file shows you the full list of available method calls (as well as parameter lists in the comments for each method). -And perusing the list of available methods. Alternatively, browsing the -`\Elasticsearch\Namespaces\Indices.php` file shows you the full list of -available method calls (as well as parameter lists in the comments for each -method). diff --git a/docs/reference/indexing_documents.md b/docs/reference/indexing_documents.md new file mode 100644 index 000000000..210fd85de --- /dev/null +++ b/docs/reference/indexing_documents.md @@ -0,0 +1,118 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/indexing_documents.html +--- + +# Indexing documents [indexing_documents] + +When you add documents to {{es}}, you index JSON documents. This maps naturally to PHP associative arrays, since they can easily be encoded in JSON. Therefore, in Elasticsearch-PHP you create and pass associative arrays to the client for indexing. There are several methods of ingesting data into {{es}} which we cover here. + + +## Single document indexing [_single_document_indexing] + +When indexing a document, you can either provide an ID or let {{es}} generate one for you. + +​
+ +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id', + 'body' => [ 'testField' => 'abc'] +]; + +// Document will be indexed to my_index/_doc/my_id +$response = $client->index($params); +``` + +​
+ +```php +$params = [ + 'index' => 'my_index', + 'body' => [ 'testField' => 'abc'] +]; + +// Document will be indexed to my_index/_doc/ +$response = $client->index($params); +``` + +​
+ +If you need to set other parameters, such as a `routing` value, you specify those in the array alongside the `index`, and others. For example, let’s set the routing and timestamp of this new document: + +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id', + 'routing' => 'company_xyz', + 'timestamp' => strtotime("-1d"), + 'body' => [ 'testField' => 'abc'] +]; + + +$response = $client->index($params); +``` + +​
+ + +## Bulk Indexing [_bulk_indexing] + +{{es}} also supports bulk indexing of documents. The bulk API expects JSON action/metadata pairs, separated by newlines. When constructing your documents in PHP, the process is similar. You first create an action array object (for example, an `index` object), then you create a document body object. This process repeats for all your documents. + +A simple example might look like this: + +```php +for($i = 0; $i < 100; $i++) { + $params['body'][] = [ + 'index' => [ + '_index' => 'my_index', + ] + ]; + + $params['body'][] = [ + 'my_field' => 'my_value', + 'second_field' => 'some more values' + ]; +} + +$responses = $client->bulk($params); +``` + +In practice, you’ll likely have more documents than you want to send in a single bulk request. In that case, you need to batch up the requests and periodically send them: + +```php +$params = ['body' => []]; + +for ($i = 1; $i <= 1234567; $i++) { + $params['body'][] = [ + 'index' => [ + '_index' => 'my_index', + '_id' => $i + ] + ]; + + $params['body'][] = [ + 'my_field' => 'my_value', + 'second_field' => 'some more values' + ]; + + // Every 1000 documents stop and send the bulk request + if ($i % 1000 == 0) { + $responses = $client->bulk($params); + + // erase the old bulk request + $params = ['body' => []]; + + // unset the bulk response when you are done to save memory + unset($responses); + } +} + +// Send the last batch if it exists +if (!empty($params['body'])) { + $responses = $client->bulk($params); +} +``` + diff --git a/docs/reference/installation.md b/docs/reference/installation.md new file mode 100644 index 000000000..52962a9de --- /dev/null +++ b/docs/reference/installation.md @@ -0,0 +1,32 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/installation.html +--- + +# Installation [installation] + +Elasticsearch-php can be used starting from PHP 7.4. To install the library you need to use [composer](http://getcomposer.org) with the following command: + +```shell +composer require elasticsearch/elasticsearch +``` + +If you don’t have composer you can install it as follows: + +```shell +curl -s http://getcomposer.org/installer | php +php composer.phar install +``` + +More information about [Composer can be found at their website](https://getcomposer.org/). + +When you have installed elasticsearch-php you can start using it with the `Client` class. You can use the `ClientBuilder` class to create this object, as follows: + +```php +require 'vendor/autoload.php'; + +$client = Elastic\Elasticsearch\ClientBuilder::create()->build(); +``` + ++ Client instantiation is performed with a static helper function `create()`. This creates a ClientBuilder object, which helps you to set custom configurations. When you are done configuring, call the `build()` method to generate a `Client` object. For further info, consult the [*Configuration*](/reference/configuration.md) section. + diff --git a/docs/helpers/iterators.asciidoc b/docs/reference/iterators.md similarity index 76% rename from docs/helpers/iterators.asciidoc rename to docs/reference/iterators.md index 1af6ee902..22d7c8903 100644 --- a/docs/helpers/iterators.asciidoc +++ b/docs/reference/iterators.md @@ -1,19 +1,19 @@ -[[iterators]] -=== Iterators +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/iterators.html +--- + +# Iterators [iterators] The PHP client includes helpers for iterating through results by page or by hits. -[[search-response-iterator]] -==== Search response iterator +## Search response iterator [search-response-iterator] -Use the `SearchResponseIterator` to iterate page by page in a search -result using -https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#paginate-search-results[pagination]. +Use the `SearchResponseIterator` to iterate page by page in a search result using [pagination](elasticsearch://reference/elasticsearch/rest-apis/paginate-search-results.md). -Here's an example: +Here’s an example: -[source,php] ----- +```php use Elastic\Elasticsearch\Helper\Iterators\SearchResponseIterator; $search_params = [ @@ -35,21 +35,16 @@ foreach($pages as $page) { // e.g. prints the number of document per page (100) echo count($page['hits']['hits']), PHP_EOL; } ----- +``` -[discrete] -[[search-hit-iterator]] -==== Search hit iterator +### Search hit iterator [search-hit-iterator] -Use the `SearchHitIterator` to iterate in a `SearchResponseIterator` -without worrying about -https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#paginate-search-results[pagination]. +Use the `SearchHitIterator` to iterate in a `SearchResponseIterator` without worrying about [pagination](elasticsearch://reference/elasticsearch/rest-apis/paginate-search-results.md). -Here's an example: +Here’s an example: -[source,php] ----- +```php use Elastic\Elasticsearch\Helper\Iterators\SearchHitIterator; use Elastic\Elasticsearch\Helper\Iterators\SearchResponseIterator; @@ -73,4 +68,6 @@ foreach($hits as $hit) { // e.g. prints the document id echo $hit['_id'], PHP_EOL; } ----- +``` + + diff --git a/docs/reference/namespaces.md b/docs/reference/namespaces.md new file mode 100644 index 000000000..32d65e0cf --- /dev/null +++ b/docs/reference/namespaces.md @@ -0,0 +1,102 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/namespaces.html +--- + +# Namespaces [namespaces] + +The client has a number of "namespaces", which generally expose administrative functionality. The namespaces correspond to the various administrative endpoints in {{es}}. This is a complete list of namespaces: + +| Namespace | Functionality | +| --- | --- | +| `asyncSearch()` | Provide asyncronous search | +| `autoscaling()` | Autoscaling features | +| `cat()` | Compact and aligned text (CAT), mainly for terminal | +| `ccr()` | Cross-cluster replication operations | +| `cluster()` | Cluster-centric stats and info | +| `danglingIndices()` | Dangling indices management | +| `enrich()` | Enrich policy management | +| `eql()` | Event Query Language | +| `features()` | Manage features provided by Elasticsearch and plugins | +| `fleet()` | Fleet’s use of Elasticsearch (experimental) | +| `graph()` | Graph explore for documents and terms | +| `ilm()` | Index lifecycle management (ILM) | +| `indices()` | Index-centric stats and info | +| `ingest()` | Ingest pipelines and processors | +| `license()` | License management | +| `logStash()` | Manage pipelines used by Logstash Central Management | +| `migration()` | Designed for indirect use by Kibana’s Upgrade Assistant | +| `ml()` | Machine learning features | +| `monitoring()` | Monitoring features | +| `monitoring()` | Monitoring features | +| `nodes()` | Node-centric stats and info | +| `rollup()` | Rollup features | +| `searchableSnapshots()` | Searchable snapshots operations | +| `security()` | Security features | +| `shutdown()` | Prepare nodes for temporary or permanent shutdown | +| `slm()` | Snapshot lifecycle management (SLM) | +| `snapshot()` | Methods to snapshot/restore your cluster and indices | +| `sql()` | Run SQL queries on Elasticsearch indices and data streams | +| `ssl()` | SSL certificate management | +| `tasks()` | Task management | +| `textStructure()` | Finds the structure of text | +| `transform()` | Transform features | +| `watcher()` | Watcher create actions based on conditions | +| `xpack()` | Retrieves information about the installed X-Pack features | + +Some methods are available in several different namespaces, which give you the same information but grouped into different contexts. To see how these namespaces work, let’s look at the `_stats` output: + +```php +$client = ClientBuilder::create()->build(); + +// Index Stats +// Corresponds to curl -XGET localhost:9200/_stats +$response = $client->indices()->stats(); + +// Node Stats +// Corresponds to curl -XGET localhost:9200/_nodes/stats +$response = $client->nodes()->stats(); + +// Cluster Stats +// Corresponds to curl -XGET localhost:9200/_cluster/stats +$response = $client->cluster()->stats(); +``` + +​
+ +As you can see, the same `stats()` call is made through three different namespaces. Sometimes the methods require parameters. These parameters work just like any other method in the library. + +For example, we can requests index stats about a specific index, or multiple indices: + +```php +$client = ClientBuilder::create()->build(); + +// Corresponds to curl -XGET localhost:9200/my_index/_stats +$params['index'] = 'my_index'; +$response = $client->indices()->stats($params); + +// Corresponds to curl -XGET localhost:9200/my_index1,my_index2/_stats +$params['index'] = ['my_index1', 'my_index2']; +$response = $client->indices()->stats($params); +``` + +​
+ +The following example shows how you can add an alias to an existing index: + +```php +$params['body'] = [ + 'actions' => [ + [ + 'add' => [ + 'index' => 'myindex', + 'alias' => 'myalias' + ] + ] + ] +]; +$client->indices()->updateAliases($params); +``` + +Notice how both the `stats` calls and the `updateAliases` took a variety of parameters, each according to what the particular API requires. The `stats` API only requires an index name(s), while the `updateAliases` requires a body of actions. + diff --git a/docs/reference/node_pool.md b/docs/reference/node_pool.md new file mode 100644 index 000000000..7c53b6a1a --- /dev/null +++ b/docs/reference/node_pool.md @@ -0,0 +1,90 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/node_pool.html +--- + +# Node Pool [node_pool] + +The node pool is a component of [elastic-transport-php](https://github.com/elastic/elastic-transport-php) library used by elasticsearch-php. + +This component is responsible for maintaining the current list of nodes. Theoretically, nodes are either dead or alive. However, in the real world, things are never so clear. Nodes are sometimes in a gray-zone of *"probably dead but not confirmed"*, *"timed-out but unclear why"* or *"recently dead but now alive"*. The job of the node pool is to manage this set of unruly connections and try to provide the best behavior to the client. + +If a node pool is unable to find an alive node to query against, it returns a `NoNodeAvailableException`. + +By default, the number of retries is equal to the number of nodes in your cluster. For example, your cluster may have 10 nodes. You execute a request and 9 out of the 10 nodes fail due to connection timeouts. The tenth node succeeds and the query executes. The first nine nodes are marked dead and their "dead" timers begin ticking. + +When the next request is sent to the client, nodes 1-9 are still considered "dead", so they are skipped. The request is sent to the only known alive node (#10), if this node fails, a `NoNodesAvailableException` is returned. + +The `SimpleNodePool` is the default node pool algorithm. It uses the following default values: RoundRobin as `SelectorInterface` and NoResurrect as `ResurrectInterface`. + +The Round-robin algorithm select the nodes in order, from the first node in the array to the latest. When arrived to the latest nodes, it will start again from the first. + +::::{note} +The order of the nodes is randomized at runtime to maximize the usage of all the hosts. +:::: + + +The `NoResurrect` option does not try to resurrect the node that has been marked as dead. If you want, you can specify the `ElasticsearchResurrect` class to check if a node that was dead is online again (resurrected). + +You can use the following configuration to enable the `ElasticsearchResurrect` class: + +```php +use Elastic\Transport\NodePool\Resurrect\ElasticsearchResurrect; +use Elastic\Transport\NodePool\Selector\RoundRobin; +use Elastic\Transport\NodePool\SimpleNodePool; + +$nodePool = new SimpleNodePool( + new RoundRobin(), + new ElasticsearchResurrect() +); + +$transport = TransportBuilder::create() + ->setHosts(['localhost:9200']) + ->setNodePool($nodePool) + ->build(); +``` + + +### Using a custom NodePool, Selector and Resurrect [_using_a_custom_nodepool_selector_and_resurrect] + +If you want you can implement your custom node pool algorithm. We provided a [NodePoolInterface](https://github.com/elastic/elastic-transport-php/blob/master/src/NodePool/NodePoolInterface.php) + +You can also customize the Selector and the Resurrect components of the node pool. You can use the following interfaces for the implementation: + +* [SelectorInterface](https://github.com/elastic/elastic-transport-php/blob/master/src/NodePool/Selector/SelectorInterface.php) +* [ResurrectInterface](https://github.com/elastic/elastic-transport-php/blob/master/src/NodePool/Resurrect/ResurrectInterface.php) + +For more information about the Node Pool you can read the [elastic-transport-php documentation](https://github.com/elastic/elastic-transport-php/blob/master/README.md). + + +## Building the client from a configuration hash [config-hash] + +To help ease automated building of the client, all configurations can be provided in a setting hash instead of calling the individual methods directly. This functionality is exposed through the `ClientBuilder::fromConfig()` static method, which accepts an array of configurations and returns a fully built client. + +Array keys correspond to the method name, for example `retries` key corresponds to `setRetries()` method. + +```php +$params = [ + 'hosts' => [ + 'localhost:9200' + ], + 'retries' => 2 +]; +$client = ClientBuilder::fromConfig($params); +``` + +Unknown parameters throw an exception, to help the user find potential problems. If this behavior is not desired (for example, you are using the hash for other purposes), you can set `$quiet = true` in fromConfig() to silence the exceptions. + +```php +$params = [ + 'hosts' => [ + 'localhost:9200' + ], + 'retries' => 2, + 'imNotReal' => 5 +]; + +// Set $quiet to true to ignore the unknown `imNotReal` key +$client = ClientBuilder::fromConfig($params, true); +``` + diff --git a/docs/reference/operations.md b/docs/reference/operations.md new file mode 100644 index 000000000..1b8cb41dc --- /dev/null +++ b/docs/reference/operations.md @@ -0,0 +1,26 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/operations.html +--- + +# Operations [operations] + +This page contains the information you need to perform various {{es}} operations by using the Client. + +This section is a crash-course overview of the client and its syntax. If you are familiar with {{es}}, you’ll notice that the methods are named just like REST endpoints. + +You may also notice that the client is configured in a manner that facilitates easy discovery via your IDE. All core actions are available under the `$client` object (indexing, searching, getting, etc). Index and cluster management are located under the `$client->indices()` and `$client->cluster()` objects, respectively. + +* [Index management operations](/reference/index_management.md) +* [Search operations](/reference/search_operations.md) +* [Indexing documents](/reference/indexing_documents.md) +* [Getting documents](/reference/getting_documents.md) +* [Updating documents](/reference/updating_documents.md) +* [Deleting documents](/reference/deleting_documents.md) + + + + + + + diff --git a/docs/reference/php_json_objects.md b/docs/reference/php_json_objects.md new file mode 100644 index 000000000..be00a441a --- /dev/null +++ b/docs/reference/php_json_objects.md @@ -0,0 +1,160 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/php_json_objects.html +--- + +# Dealing with JSON arrays and objects in PHP [php_json_objects] + +A common source of confusion with the client revolves around JSON arrays and objects, and how to specify them in PHP. In particular, problems are caused by empty objects and arrays of objects. This page shows you some common patterns used in {{es}} JSON API and how to convert that to a PHP representation. + + +## Empty Objects [_empty_objects] + +The {{es}} API uses empty JSON objects in several locations which can cause problems for PHP. Unlike other languages, PHP does not have a "short" notation for empty objects and many developers are unaware how to specify an empty object. + +Consider adding a highlight to a query: + +```json +{ + "query" : { + "match" : { + "content" : "quick brown fox" + } + }, + "highlight" : { + "fields" : { + "content" : {} <1> + } + } +} +``` + +1. This empty JSON object is what causes problems. + + +The problem is that PHP will automatically convert `"content" : {}` into `"content" : []`, which is no longer valid {{es}} DSL. We need to tell PHP that the empty object is explicitly an object, not an array. To define this query in PHP, you would do: + +```json +$params['body'] = array( + 'query' => array( + 'match' => array( + 'content' => 'quick brown fox' + ) + ), + 'highlight' => array( + 'fields' => array( + 'content' => new \stdClass() <1> + ) + ) +); +$results = $client->search($params); +``` + +1. We use the generic PHP stdClass object to represent an empty object. The JSON now encodes correctly. + + +By using an explicit stdClass object, we can force the `json_encode` parser to correctly output an empty object, instead of an empty array. This verbose solution is the only way to acomplish the goal in PHP…​ there is no "short" version of an empty object. + + +## Arrays of Objects [_arrays_of_objects] + +Another common pattern in {{es}} DSL is an array of objects. For example, consider adding a sort to your query: + +```json +{ + "query" : { + "match" : { "content" : "quick brown fox" } + }, + "sort" : [ <1> + {"time" : {"order" : "desc"}}, + {"popularity" : {"order" : "desc"}} + ] +} +``` + +1. "sort" contains an array of JSON objects. + + +This arrangement is very common, but the construction in PHP can be tricky since it requires nesting arrays. The verbosity of PHP tends to obscure what is actually going on. To construct an array of objects, you actually need an array of arrays: + +```json +$params['body'] = array( + 'query' => array( + 'match' => array( + 'content' => 'quick brown fox' + ) + ), + 'sort' => array( <1> + array('time' => array('order' => 'desc')), <2> + array('popularity' => array('order' => 'desc')) <3> + ) +); +$results = $client->search($params); +``` + +1. This array encodes the `"sort" : []` array +2. This array encodes the `{"time" : {"order" : "desc"}}` object +3. This array encodes the `{"popularity" : {"order" : "desc"}}` object + + +If you are on PHP 5.4+, we strongly encourage you to use the short array syntax. It makes these nested arrays much simpler to read: + +```json +$params['body'] = [ + 'query' => [ + 'match' => [ + 'content' => 'quick brown fox' + ] + ], + 'sort' => [ + ['time' => ['order' => 'desc']], + ['popularity' => ['order' => 'desc']] + ] +]; +$results = $client->search($params); +``` + + +## Arrays of empty objects [_arrays_of_empty_objects] + +Occasionally, you’ll encounter DSL that requires both of the previous patterns. The function score query is a good example, it sometimes requires an array of objects, and some of those objects might be empty JSON objects. + +Given this query: + +```json +{ + "query":{ + "function_score":{ + "functions":[ + { + "random_score":{} + } + ], + "boost_mode":"replace" + } + } +} +``` + +We can build it using the following PHP code: + +```json +$params['body'] = array( + 'query' => array( + 'function_score' => array( + 'functions' => array( <1> + array( <2> + 'random_score' => new \stdClass() <3> + ) + ) + ) + ) +); +$results = $client->search($params); +``` + +1. This encodes the array of objects: `"functions" : []` +2. This encodes an object inside the array: `{ "random_score": {} }` +3. This encodes the empty JSON object: `"random_score": {}` + + diff --git a/docs/search-operations.asciidoc b/docs/reference/search_operations.md similarity index 62% rename from docs/search-operations.asciidoc rename to docs/reference/search_operations.md index 6b6226549..7f938e42a 100644 --- a/docs/search-operations.asciidoc +++ b/docs/reference/search_operations.md @@ -1,20 +1,20 @@ -[[search_operations]] -=== Search operations +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/search_operations.html +--- -Well...it isn't called {es} for nothing! Let's talk about search operations in -the client. +# Search operations [search_operations] -The client gives you full access to every query and parameter exposed by the -REST API, following the naming scheme as much as possible. Let's look at a few -examples so you can become familiar with the syntax. +Well…​it isn’t called {{es}} for nothing! Let’s talk about search operations in the client. -[discrete] -==== Match query +The client gives you full access to every query and parameter exposed by the REST API, following the naming scheme as much as possible. Let’s look at a few examples so you can become familiar with the syntax. + + +## Match query [_match_query] Here is a standard curl for a match query: -[source,shell] ----- +```shell curl -XGET 'localhost:9200/my_index/_search' -d '{ "query" : { "match" : { @@ -22,14 +22,13 @@ curl -XGET 'localhost:9200/my_index/_search' -d '{ } } }' ----- -{zwsp} + +``` +​
And here is the same query constructed in the client: -[source,php] ----- +```php $params = [ 'index' => 'my_index', 'body' => [ @@ -42,17 +41,13 @@ $params = [ ]; $results = $client->search($params); ----- -{zwsp} + +``` +​
-Notice how the structure and layout of the PHP array is identical to that of the -JSON request body. This makes it very simple to convert JSON examples into PHP. -A quick method to check your PHP array (for more complex examples) is to encode -it back to JSON and check it: +Notice how the structure and layout of the PHP array is identical to that of the JSON request body. This makes it very simple to convert JSON examples into PHP. A quick method to check your PHP array (for more complex examples) is to encode it back to JSON and check it: -[source,php] ----- +```php $params = [ 'index' => 'my_index', 'body' => [ @@ -68,18 +63,14 @@ print_r(json_encode($params['body'])); {"query":{"match":{"testField":"abc"}}} ----- -{zwsp} + +``` +​
-.Using Raw JSON -**** -Sometimes it is convenient to use raw JSON for testing purposes, or when -migrating from a different system. You can use raw JSON as a string in the body, -and the client detects this automatically: +::::{admonition} Using Raw JSON +Sometimes it is convenient to use raw JSON for testing purposes, or when migrating from a different system. You can use raw JSON as a string in the body, and the client detects this automatically: -[source,php] ----- +```php $json = '{ "query" : { "match" : { @@ -94,17 +85,16 @@ $params = [ ]; $results = $client->search($params); ----- -**** -{zwsp} + +``` + +:::: -Search results follow the same format as {es} search response, the only -difference is that the JSON response is serialized back into PHP arrays. Working -with the search results is as simple as iterating over the array values: +​
-[source,php] ----- +Search results follow the same format as {{es}} search response, the only difference is that the JSON response is serialized back into PHP arrays. Working with the search results is as simple as iterating over the array values: + +```php $params = [ 'index' => 'my_index', 'body' => [ @@ -123,17 +113,16 @@ $maxScore = $results['hits']['max_score']; $score = $results['hits']['hits'][0]['_score']; $doc = $results['hits']['hits'][0]['_source']; ----- -{zwsp} + +``` + +​
-[discrete] -==== Bool Queries -Bool queries can be easily constructed using the client. For example, this -query: +## Bool Queries [_bool_queries] -[source,shell] ----- +Bool queries can be easily constructed using the client. For example, this query: + +```shell curl -XGET 'localhost:9200/my_index/_search' -d '{ "query" : { "bool" : { @@ -148,14 +137,13 @@ curl -XGET 'localhost:9200/my_index/_search' -d '{ } } }' ----- -{zwsp} + +``` +​
Would be structured like this (note the position of the square brackets): -[source,php] ----- +```php $params = [ 'index' => 'my_index', 'body' => [ @@ -171,26 +159,20 @@ $params = [ ]; $results = $client->search($params); ----- -{zwsp} + +``` + +​
+Notice that the `must` clause accepts an array of arrays. This is serialized into an array of JSON objects internally, so the final resulting output is identical to the curl example. For more details about arrays and objects in PHP, see [Dealing with JSON Arrays and Objects in PHP](/reference/php_json_objects.md). -Notice that the `must` clause accepts an array of arrays. This is serialized -into an array of JSON objects internally, so the final resulting output is -identical to the curl example. For more details about arrays and objects in PHP, -see <>. -[discrete] -==== A more complicated example +## A more complicated example [_a_more_complicated_example] -Let's construct a slightly more complicated example: a boolean query that -contains both a filter and a query. This is a very common activity in {es} -queries, so it will be a good demonstration. +Let’s construct a slightly more complicated example: a boolean query that contains both a filter and a query. This is a very common activity in {{es}} queries, so it will be a good demonstration. The curl version of the query: -[source,shell] ----- +```shell curl -XGET 'localhost:9200/my_index/_search' -d '{ "query" : { "bool" : { @@ -203,14 +185,13 @@ curl -XGET 'localhost:9200/my_index/_search' -d '{ } } }' ----- -{zwsp} + +``` +​
And in PHP: -[source,php] ----- +```php $params = [ 'index' => 'my_index', 'body' => [ @@ -229,31 +210,22 @@ $params = [ $results = $client->search($params); ----- -{zwsp} + +``` +​
-[discrete] -==== Scrolling -The scrolling functionality of {es} is used to paginate over many documents in a -bulk manner, such as exporting all the documents belonging to a single user. It -is more efficient than regular search because it doesn't need to maintain an -expensive priority queue ordering the documents. +## Scrolling [_scrolling] -Scrolling works by maintaining a "point in time" snapshot of the index which is -then used to page over. This window allows consistent paging even if there is -background indexing/updating/deleting. First, you execute a search request with -`scroll` enabled. This returns a "page" of documents, and a `scroll_id` which is -used to continue paginating through the hits. +The scrolling functionality of {{es}} is used to paginate over many documents in a bulk manner, such as exporting all the documents belonging to a single user. It is more efficient than regular search because it doesn’t need to maintain an expensive priority queue ordering the documents. -More details about scrolling can be found in the -{ref-7x}/search-request-body.html#request-body-search-scroll[reference documentation]. +Scrolling works by maintaining a "point in time" snapshot of the index which is then used to page over. This window allows consistent paging even if there is background indexing/updating/deleting. First, you execute a search request with `scroll` enabled. This returns a "page" of documents, and a `scroll_id` which is used to continue paginating through the hits. + +More details about scrolling can be found in the [reference documentation](elasticsearch://reference/elasticsearch/rest-apis/paginate-search-results.md#scroll-search-results). This is an example which can be used as a template for more advanced operations: -[source,php] ----- +```php $client = ClientBuilder::create()->build(); $params = [ 'scroll' => '30s', // how long between scroll requests. should be small! @@ -261,7 +233,7 @@ $params = [ 'index' => 'my_index', 'body' => [ 'query' => [ - 'match_all' => new \stdClass() + 'match_all' => new \stdClass() ] ] ]; @@ -290,4 +262,5 @@ while (isset($response['hits']['hits']) && count($response['hits']['hits']) > 0) ] ]); } ----- +``` + diff --git a/docs/reference/set-retries.md b/docs/reference/set-retries.md new file mode 100644 index 000000000..df2d5bd5b --- /dev/null +++ b/docs/reference/set-retries.md @@ -0,0 +1,32 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/set-retries.html +--- + +# Set retries [set-retries] + +By default, the client will retry `n` times, where `n = number of nodes` in your cluster. A retry is only performed if the operation results in a "hard" exception: connection refusal, connection timeout, DNS lookup timeout, etc. 4xx and 5xx errors are not considered retriable events, since the node returns an operational response. + +If you would like to disable retries, or change the number, you can do so with the `setRetries()` method: + +```php +$client = ClientBuilder::create() + ->setRetries(2) + ->build(); +``` + +When the client runs out of retries, it will throw the last exception that it received. For example, if you have ten alive nodes, and `setRetries(5)`, the client attempts to execute the command up to five times. If all five nodes result in a connection timeout (for example), the client will throw an `NoNodeAvailableException`. + +```php +use Elastic\Transport\Exception\NoNodeAvailableException; + +$client = ClientBuilder::create() + ->build(); + +try { + $reponse = $client->info(); +} catch (NoNodeAvailableException $e) { + printf("No nodes alive: %s", $e->getMessage()); +} +``` + diff --git a/docs/reference/toc.yml b/docs/reference/toc.yml new file mode 100644 index 000000000..e58d0e544 --- /dev/null +++ b/docs/reference/toc.yml @@ -0,0 +1,27 @@ +toc: + - file: index.md + - file: getting-started.md + - file: installation.md + - file: connecting.md + - file: configuration.md + children: + - file: php_json_objects.md + - file: host-config.md + - file: set-retries.md + - file: http-meta-data.md + - file: enabling_logger.md + - file: http-client.md + - file: namespaces.md + - file: node_pool.md + - file: operations.md + children: + - file: index_management.md + - file: search_operations.md + - file: indexing_documents.md + - file: getting_documents.md + - file: updating_documents.md + - file: deleting_documents.md + - file: client-helpers.md + children: + - file: iterators.md + - file: esql.md \ No newline at end of file diff --git a/docs/reference/updating_documents.md b/docs/reference/updating_documents.md new file mode 100644 index 000000000..841abb1bc --- /dev/null +++ b/docs/reference/updating_documents.md @@ -0,0 +1,80 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/updating_documents.html +--- + +# Updating documents [updating_documents] + +Updating a document allows you to either completely replace the contents of the existing document, or perform a partial update to just some fields (either changing an existing field or adding new fields). + + +## Partial document update [_partial_document_update] + +If you want to partially update a document (for example, change an existing field or add a new one) you can do so by specifying the `doc` in the `body` parameter. This merges the fields in `doc` with the existing document. + +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id', + 'body' => [ + 'doc' => [ + 'new_field' => 'abc' + ] + ] +]; + +// Update doc at /my_index/_doc/my_id +$response = $client->update($params); +``` + +​
+ + +## Scripted document update [_scripted_document_update] + +Sometimes you need to perform a scripted update, such as incrementing a counter or appending a new value to an array. To perform a scripted update, you need to provide a script and usually a set of parameters: + +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id', + 'body' => [ + 'script' => 'ctx._source.counter += count', + 'params' => [ + 'count' => 4 + ] + ] +]; + +$response = $client->update($params); +``` + +​
+ + +## Upserts [_upserts] + +Upserts are "Update or Insert" operations. This means an upsert attempts to run your update script, but if the document does not exist (or the field you are trying to update doesn’t exist), default values are inserted instead. + +```php +$params = [ + 'index' => 'my_index', + 'id' => 'my_id', + 'body' => [ + 'script' => [ + 'source' => 'ctx._source.counter += params.count', + 'params' => [ + 'count' => 4 + ], + ], + 'upsert' => [ + 'counter' => 1 + ], + ] +]; + +$response = $client->update($params); +``` + +​
+ diff --git a/docs/release-notes.asciidoc b/docs/release-notes.asciidoc deleted file mode 100644 index 2bf712f57..000000000 --- a/docs/release-notes.asciidoc +++ /dev/null @@ -1,592 +0,0 @@ -[[release-notes]] -== Release notes - -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> - -[discrete] -[[rn-8-15-0]] -=== 8.15.0 - -* Updated the API endpoints to Elasticserach 8.15.0 -* Added the OpenTelemetry support, for more information - you can refer to the https://github.com/elastic/elastic-transport-php?tab=readme-ov-file#opentelemetry[elastic-transport-php] - documentation - -[discrete] -[[rn-8-14-0]] -=== 8.14.0 - -* Updated the API endpoints to Elasticserach 8.14.0 - -[discrete] -[[rn-8-13-0]] -=== 8.13.0 - -* Updated the API endpoints to Elasticserach 8.13.0 -* Added the Added the mapTo($class) function to Elasticsearch response for mapping the result - of https://www.elastic.co/guide/en/elasticsearch/reference/current/esql.html[ES|QL] - query to an object of stdClass or a specific class https://github.com/elastic/elasticsearch-php/issues/1398[#1398] - -[discrete] -[[rn-8-12-0]] -=== 8.12.0 - -* Updated the API endpoints to Elasticserach 8.12.0 -* Tested the library with PHP 8.3 - -[discrete] -[[rn-8-11-0]] -=== 8.11.0 - -* Updated the API endpoints to Elasticserach 8.11.0 -* Fixed path in hosts configuration is ignored - https://github.com/elastic/elasticsearch-php/issues/1377[#1377] - - -[discrete] -[[rn-8-10-0]] -=== 8.10.0 - -* Updated the API endpoints to Elasticserach 8.10.0 - -[discrete] -[[rn-8-9-0]] -=== 8.9.0 - -* Updated the API endpoints to Elasticserach 8.9.0 -* Fixed issue with psr/http-message, changed PSR-7 versions to 1.1 and 2.0 - https://github.com/elastic/elasticsearch-php/pull/1344[#1344] - -[discrete] -[[rn-8-8-0]] -=== 8.8.0 - -* Updated the API endpoints to Elasticserach 8.8.0 -* Added SearchHitIterators and SearchResponseIterator helpers revised with new version - https://github.com/elastic/elasticsearch-php/pull/1302[#1302] - -[discrete] -[[rn-8-7-0]] -=== 8.7.0 - -* Updated the API endpoints to Elasticserach 8.7.0 -* Allow plugin for `php-http/discovery` library - https://github.com/elastic/elasticsearch-php/pull/1294[#1294] - -[discrete] -[[rn-8-6-1]] -=== 8.6.1 - -* Updated the API endpoints to Elasticserach 8.6.0 - -[discrete] -[[rn-8-5-0]] -=== 8.5.0 - -* Updated the API endpoints to Elasticserach 8.5.0 - -[discrete] -[[rn-8-4-0]] -=== 8.4.0 - -* Added a `ClientInterface` to simplify the mock of the Client, - this is a fix for https://github.com/elastic/elasticsearch-php/issues/1227[#1227] - https://github.com/elastic/elasticsearch-php/pull/1249[#1249] -* Added the support of Symfony HTTP client, fixing the issue https://github.com/elastic/elasticsearch-php/issues/1241[#1241] - https://github.com/elastic/elasticsearch-php/pull/1243[#1243] -* Added the API compatibility header - https://github.com/elastic/elasticsearch-php/pull/1233[#1233] -* Updated the API endpoints to Elasticserach 8.4.0 - -[discrete] -[[rn-8-3-0]] -=== 8.3.0 - -* Updated the API endpoints to Elasticserach 8.3.0 - -[discrete] -[[rn-8-2-0]] -=== 8.2.0 - -* Updated the API endpoints to Elasticserach 8.2.0 -* Added the array support for `text/plain` - https://github.com/elastic/elasticsearch-php/pull/1220[#1220] - -[discrete] -[[rn-8-1-0]] -=== 8.1.0 - -* Updated the API endpoints to Elasticserach 8.1.0 - -[discrete] -[[rn-8-0-1]] -=== 8.0.1 - -* use of `NoNodeAvailableException` exception in endpoints, fixing - https://github.com/elastic/elasticsearch-php/issues/1209[#1209] - - -[discrete] -[[rn-8-0-0]] -=== 8.0.0 - -This new major version of elasticsearch-php contains a brand new implementation -compared with 7.x. It supports https://www.php-fig.org/psr/psr-7/[PSR-7] for HTTP -messages and https://www.php-fig.org/psr/psr-18/[PSR-18] for HTTP client -communications. We used the https://github.com/elastic/elastic-transport-php[elastic-transport-php] -library for HTTP communications. - -We tried to reduce the BC breaks as much as possible with 7.x but there are some -(big) differences: - -* we changed the namespace, now everything is under `Elastic\Elasticsearch`; -* we changed the Exception model, using the namespace `Elastic\Elasticsearch\Exception`. - All the exceptions extends the `ElasticsearchException` interface, as in 7.x; -* we changed the response type of each endpoints using an Elasticsearch response class. - This class wraps a a PSR-7 response allowing the access of the body response - as array or object. This means you can access the API response as in 7.x, no BC break here! - -You can have a look at the https://github.com/elastic/elasticsearch-php/blob/8.0/BREAKING_CHANGES.md[BREAKING_CHANGES] -online document for more information. - - -[discrete] -[[rn-7-17-0]] -=== 7.17.0 - -* Allow psr/log v3 - https://github.com/elastic/elasticsearch-php/pull/1184[#1184] - - -[discrete] -[[rn-7-16-0]] -=== 7.16.0 - -* Added support of includePortInHostHeader in ClientBuilder::fromConfig - https://github.com/elastic/elasticsearch-php/pull/1181[#1181] -* Fixed UTF-16 issue in SmartSerializer with single unpaired surrogate in unicode escape - https://github.com/elastic/elasticsearch-php/pull/1179[#1179] -* Replace trait with abstract class to avoid Deprecated Functionality issue in PHP 8.1 - https://github.com/elastic/elasticsearch-php/pull/1175[#1175] - - -[discrete] -[[rn-7-15-0]] -=== 7.15.0 - -* Updated endpoints for Elasticsearch 7.15.0 - https://github.com/elastic/elasticsearch-php/commit/995f6d4bde7de76004e95d7a434b1d59da7a7e75[995f6d4] - - -[discrete] -[[rn-7-14-0]] -=== 7.14.0 - -* Usage of psr/log version 2 - https://github.com/elastic/elasticsearch-php/pull/1154[#1154] -* Update search iterators to send `scroll_id` inside the request body - https://github.com/elastic/elasticsearch-php/pull/1134[#1134] -* Added the `ingest.geoip.downloader.enabled=false` setting for ES - https://github.com/elastic/elasticsearch-php/commit/586735109dc18f22bfdf3b73ab0621b37e857be1[5867351] -* Removed phpcs for autogenerated files (endpoints) - https://github.com/elastic/elasticsearch-php/commit/651c57b2e6bf98a0fd48220949966e630e5a804a[651c57b] - - -[discrete] -[[rn-7-13-1]] -=== 7.13.1 - -* Added port in url for trace and logger messages - https://github.com/elastic/elasticsearch-php/pull/1126[#1126] - - -[discrete] -[[rn-7-13-0]] -=== 7.13.0 - -* (DOCS) Added the HTTP meta data section - https://github.com/elastic/elasticsearch-php/pull/1143[#1143] -* Added support for API Compatibility Header - https://github.com/elastic/elasticsearch-php/pull/1142[#1142] -* (DOCS) Added Helpers section to PHP book - https://github.com/elastic/elasticsearch-php/pull/1129[#1129] -* Added the API description in phpdoc section for each endpoint - https://github.com/elastic/elasticsearch-php/commit/9e05c8108b638b60cc676b6a4f4be97c7df9eb64[9e05c81] -* Usage of PHPUnit 9 only + migrated xml configurations - https://github.com/elastic/elasticsearch-php/commit/038b5dd043dc76b20b9f5f265ea914a38d33568d[038b5dd] - - -[discrete] -[[rn-7-12-0]] -=== 7.12.0 - -* Updated the endpoints for ES 7.12 + removed `cpliakas/git-wrapper` in favor of - `symplify/git-wrapper` - https://github.com/elastic/elasticsearch-php/commit/136d5b9717b3806c6b34ef8a5076bfe7cee8b46e[136d5b9] -* Fixed warning header as array in YAML tests generator - https://github.com/elastic/elasticsearch-php/commit/0d81be131bfc7eff6ef82468e61c16077a892aab[0d81be1] -* Refactored TEST_SUITE with free, platinum + removed old YamlRunnerTest - https://github.com/elastic/elasticsearch-php/commit/f69d96fc283580177002b4088c279c3d0c07befe[f69d96f] - - -[discrete] -[[rn-7-11-0]] -=== 7.11.0 - -* Added the `X-Elastic-Client-Meta` header which is used by Elastic Cloud and - can be disabled with `ClientBuilder::setElasticMetaHeader(false)` - https://github.com/elastic/elasticsearch-php/pull/1089[#1089] -* Replaced `array_walk` with `array_map` in `Connection::getURI` for PHP 8 - compatibility - https://github.com/elastic/elasticsearch-php/pull/1075[#1075] -* Remove unnecessary `InvalidArgumentExceptions` - https://github.com/elastic/elasticsearch-php/pull/1069[#1069] -* Introducing PHP 8 compatibility - https://github.com/elastic/elasticsearch-php/pull/1063[#1063] -* Replace Sami by Doctum and fix `.gitignore` - https://github.com/elastic/elasticsearch-php/pull/1062[#1062] - - -[discrete] -[[rn-7-10-0]] -=== 7.10.0 - -* Updated endpoints and namespaces for {es} 7.10 - https://github.com/elastic/elasticsearch-php/commit/3ceb7484a111aa20126168460c79f098c4fe0792[3ceb748] -* Fixed ClientBuilder::fromConfig allowing multiple function parameters (for - example, `setApiKey`) - https://github.com/elastic/elasticsearch-php/pull/1076[#1076] -* Refactored the YAML tests using generated PHPUnit code - [85fadc2](https://github.com/elastic/elasticsearch-php/commit/85fadc2bd4b2b309b19761a50ff13010d43a524d) - - -[discrete] -[[rn-7-9-1]] -=== 7.9.1 - -* Fixed using object instead of array in onFailure transport event - https://github.com/elastic/elasticsearch-php/pull/1066[#1066] -* Fixed reset custom header after endpoint call - https://github.com/elastic/elasticsearch-php/pull/1065[#1065] -* Show generic error messages when server returns no response - https://github.com/elastic/elasticsearch-php/pull/1056[#1056] - - -[discrete] -[[rn-7-9-0]] -=== 7.9.0 - -* Updated endpoints and namespaces for {es} 7.9 - https://github.com/elastic/elasticsearch-php/commit/28bf0ed6df6bc95f83f369509431d97907bfdeb0[28bf0ed] -* Moved `scroll_id` into `body` for search operations in the documentation - https://github.com/elastic/elasticsearch-php/pull/1052[#1052] -* Fixed PHP 7.4 preloading feature for autoload.php - https://github.com/elastic/elasticsearch-php/pull/1051[#1051] -* Improved message of JSON errors using `json_last_error_msg()` - https://github.com/elastic/elasticsearch-php/pull/1045[#1045] - - -[discrete] -[[rn-7-8-0]] -=== 7.8.0 - -* Updated endpoints and namespaces for {es} 7.8 - https://github.com/elastic/elasticsearch-php/commit/f2a0828d5ee9d126ad63e2a1d43f70b4013845e2[f2a0828] -* Improved documentation - https://github.com/elastic/elasticsearch-php/pull/1038[#1038], - https://github.com/elastic/elasticsearch-php/pull/1027[#1027], - https://github.com/elastic/elasticsearch-php/pull/1025[#1025] - - -[discrete] -[[rn-7-7-0]] -=== 7.7.0 - -* Removed setId() into endpoints, fixed `util/GenerateEndpoints.php` - https://github.com/elastic/elasticsearch-php/pull/1026[#1026] -* Fixes JsonErrorException with code instead of message - https://github.com/elastic/elasticsearch-php/pull/1022[#1022] -* Better exception message for Could not parse URI - https://github.com/elastic/elasticsearch-php/pull/1016[#1016] -* Added JUnit log for PHPUnit - https://github.com/elastic/elasticsearch-php/commit/88b7e1ce80a5a52c1d64d00c55fef77097bbd8a9[88b7e1c] -* Added the XPack endpoints - https://github.com/elastic/elasticsearch-php/commit/763d91a3d506075316b84a38b2bed7a098da5028[763d91a] - - - -[discrete] -[[rn-7-6-1]] -=== 7.6.1 - -* Fixed issue with `guzzlehttp/ringphp` and `guzzle/streams` using forks - `ezimuel/ringphp` and `ezimuel/guzzlestreams` - https://github.com/elastic/elasticsearch-php/commit/92a6a4adda5eafd1823c7c9c386e2c7e5e75cd08[92a6a4a] - - -[discrete] -[[rn-7-6-0]] -=== 7.6.0 - -* Generated the new endpoints for {es} 7.6.0 - https://github.com/elastic/elasticsearch-php/commit/be31f317af704f333b43bbcc7c01ddc7c91ec6f8[be31f31] - - -[discrete] -[[rn-7-5-1]] -=== 7.5.1 - -* Fixes port missing in log https://github.com/elastic/elasticsearch-php/issues/925[#925] - https://github.com/elastic/elasticsearch-php/commit/125594b40d167ef1509b3ee49a3f93426390c426[75e0888] -* Added `ClientBuilder::includePortInHostHeader()` to add the `port` in the - `Host` header. This fixes https://github.com/elastic/elasticsearch-php/issues/993[#993]. - By default the `port` is not included in the `Host` header. - https://github.com/elastic/elasticsearch-php/pull/997[#997] -* Replace abandoned packages: ringphp, streams and phpstan-shim - https://github.com/elastic/elasticsearch-php/pull/996[#996] -* Fixed gzip compression when setting Cloud Id - https://github.com/elastic/elasticsearch-php/pull/986[#986] - - -[discrete] -[[rn-7-5-0]] -=== 7.5.0 - -* Fixed `Client::extractArgument` iterable casting to array; this allows passing - a `Traversable` body for some endpoints (for example, Bulk, Msearch, - MsearchTemplate) - https://github.com/elastic/elasticsearch-php/pull/983[#983] -* Fixed the Response Exception if the `reason` field is null - https://github.com/elastic/elasticsearch-php/pull/980[#980] -* Added support for PHP 7.4 - https://github.com/elastic/elasticsearch-php/pull/976[#976] - - -[discrete] -[[rn-7-4-1]] -=== 7.4.1 - -* We added the suppress operator `@` for the deprecation messages - `@trigger_error()`. With this approach, we don't break existing application - that convert PHP errors in Exception (for example, using Laravel with issue - https://github.com/babenkoivan/scout-elasticsearch-driver/issues/297[297]) - Using the `@` operator is still possible to intercept the deprecation message - using a custom error handler. - https://github.com/elastic/elasticsearch-php/pull/973[#973] -* Add missing leading slash in the URL of put mapping endpoint - https://github.com/elastic/elasticsearch-php/pull/970[#970] -* Fix pre 7.2 endpoint class name with aliases + reapply fix #947. This PR - solved the unexpected BC break introduce in 7.4.0 with the code - generation tool - https://github.com/elastic/elasticsearch-php/pull/968[#968] - - -[discrete] -[[rn-7-4-0]] -=== 7.4.0 - -* Added the code generation for endpoints and namespaces based on the - https://github.com/elastic/elasticsearch/tree/v7.4.2/rest-api-spec/src/main/resources/rest-api-spec/api[REST API specification] - of {es}. This tool is available in `util/GenerateEndpoints.php`. - https://github.com/elastic/elasticsearch-php/pull/966[#966] -* Fixed the asciidoc - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/ElasticsearchPHP_Endpoints.html[endpoints documentation] - based on the code generation using https://github.com/FriendsOfPHP/Sami[Sami] - project https://github.com/elastic/elasticsearch-php/pull/966[#966] -* All the `experimental` and `beta` APIs are now signed with a `@note` tag in - the phpdoc section (for example, - https://github.com/elastic/elasticsearch-php/blob/master/src/Elasticsearch/Client.php[$client->rankEval()]). - For more information read the - https://www.elastic.co/guide/en/elasticsearch/client/php-api/{branch}/experimental_and_beta_apis.html[experimental and beta APIs] - section in the documentation. - https://github.com/elastic/elasticsearch-php/pull/966[#966] -* Removed `AlreadyExpiredException` since it has been removed - from {es} with https://github.com/elastic/elasticsearch/pull/24857[#24857] - https://github.com/elastic/elasticsearch-php/pull/954[#954] - - -[discrete] -[[rn-7-3-0]] -=== 7.3.0 - -* Added support for simplified access to the `X-Opaque-Id` header - https://github.com/elastic/elasticsearch-php/pull/952[#952] -* Added the HTTP port in the log messages - https://github.com/elastic/elasticsearch-php/pull/950[#950] -* Fixed hostname with underscore (ClientBuilder::prependMissingScheme) - https://github.com/elastic/elasticsearch-php/pull/949[#949] -* Removed unused Monolog in ClientBuilder - https://github.com/elastic/elasticsearch-php/pull/948[#948] - - -[discrete] -[[rn-7-2-2]] -=== 7.2.2 - -* Reintroduced the optional parameter in - `Elasticsearch\Namespaces\IndicesNamespace::getAliases()`. - This fixes the BC break introduced in 7.2.0 and 7.2.1. - https://github.com/elastic/elasticsearch-php/pull/947[#947] - - -[discrete] -[[rn-7-2-1]] -=== 7.2.1 - -* Reintroduced `Elasticsearch\Namespaces\IndicesNamespace::getAliases()` as proxy - to `IndicesNamespace::getAlias()` to prevent BC breaks. The `getAliases()` is - marked as deprecated and it will be removed from `elasticsearch-php 8.0` - https://github.com/elastic/elasticsearch-php/pull/943[#943] - -[discrete] -==== Docs - -* Fixed missing put mapping code snippet in code examples - https://github.com/elastic/elasticsearch-php/pull/938[#938] - - -[discrete] -[[rn-7-2-0]] -=== 7.2.0 - -* Updated the API endpoints for working with {es} 7.2.0: - * added `wait_for_active_shards` parameter to `indices.close` API; - * added `expand_wildcards` parameter to `cluster.health` API; - * added include_unloaded_segments`, `expand_wildcards`, `forbid_closed_indices` - parameters to `indices.stats` API. - https://github.com/elastic/elasticsearch-php/pull/933/commits/27d721ba44b8c199388650c5a1c8bd69757229aa[27d721b] -* Updated the phpdoc parameters for all the API endpoints - https://github.com/elastic/elasticsearch-php/pull/933/commits/27d721ba44b8c199388650c5a1c8bd69757229aa[27d721b] -* Improved the Travis CI speed using cache feature with composer - https://github.com/elastic/elasticsearch-php/pull/929[#929] -* Fixed `php_uname()` usage checking if it is disabled - https://github.com/elastic/elasticsearch-php/pull/927[#927] -* Added support of Elastic Cloud ID and API key authentication - https://github.com/elastic/elasticsearch-php/pull/923[#923] - - -[discrete] -[[rn-7-1-1]] -=== 7.1.1 - -* Fixed `ClientBuilder::setSSLVerification()` to accept string or boolean - https://github.com/elastic/elasticsearch-php/pull/917[#917] -* Fix type hinting for `setBody` in - `Elasticsearch\Endpoints\Ingest\Pipeline\Put` - https://github.com/elastic/elasticsearch-php/pull/913[#913] - - -[discrete] -[[rn-7-1-0]] -=== 7.1.0 - -* Added warning log for {es} response containing the `Warning` header - https://github.com/elastic/elasticsearch-php/pull/911[#911] -* Fixed #838 hosting company is blocking ports because of `YamlRunnerTest.php` - https://github.com/elastic/elasticsearch-php/pull/844[#844] -* Specialized inheritance of `NoNodesAvailableException` to extend - `ServerErrorResponseException` instead of the generic `\Exception` - https://github.com/elastic/elasticsearch-php/pull/607[#607] -* Fixed scroll TTL is extracted but not set as a body param - https://github.com/elastic/elasticsearch-php/pull/907[#907] - -[discrete] -==== Testing - -* Improved the speed of integration tests removing snapshots delete from - `YamlRunnerTest::clean` - https://github.com/elastic/elasticsearch-php/pull/911[#911] -* Reduced the number of skipping YAML integration tests from 20 to 6 - https://github.com/elastic/elasticsearch-php/pull/911[#911] - -[discrete] -==== Docs - -* Documentation updated for {es} 7 - https://github.com/elastic/elasticsearch-php/pull/904[#904] - - -[discrete] -[[rn-7-0-2]] -=== 7.0.2 - -* Fixed incorrect return type hint when using async requests/futures - https://github.com/elastic/elasticsearch-php/pull/905[#905] - - -[discrete] -[[rn-7-0-1]] -=== 7.0.1 - -* Fixed SniffingConnectionPool removing the return type of Connection::sniff() - https://github.com/elastic/elasticsearch-php/pull/899[#899] - - -[discrete] -[[rn-7-0-0]] -=== 7.0.0 - -* Requirement of PHP 7.1 instead of 7.0 that is not supported since 1 Jan 2019. - https://github.com/elastic/elasticsearch-php/pull/897[#897] -* Code refactoring using type hints and return type declarations where possible - https://github.com/elastic/elasticsearch-php/pull/897[#897] -* Update vendor libraries (PHPUnit 7.5, Symfony YAML 4.3, and so on) - https://github.com/elastic/elasticsearch-php/pull/897[#897] -* Updated all the API endpoints using the - https://github.com/elastic/elasticsearch/tree/v7.0.0/rest-api-spec/src/main/resources/rest-api-spec/api[latest 7.0.0 specs] - of {es} https://github.com/elastic/elasticsearch-php/pull/897[#897] -* Added the `User-Agent` in each HTTP request - https://github.com/elastic/elasticsearch-php/pull/898[#898] -* Simplified the logging methods - `logRequestFail($request, $response, $exception)` and - `logRequestSuccess($request, $response)` in - `Elasticsearch\Connections\Connection` - https://github.com/elastic/elasticsearch-php/pull/876[#876] -* Fix `json_encode` for unicode(emoji) characters - https://github.com/elastic/elasticsearch-php/pull/856[#856] -* Fix HTTP port specification using CURLOPT_PORT, not anymore in the host - https://github.com/elastic/elasticsearch-php/pull/782[#782] diff --git a/docs/release-notes/breaking-changes.md b/docs/release-notes/breaking-changes.md new file mode 100644 index 000000000..aba176560 --- /dev/null +++ b/docs/release-notes/breaking-changes.md @@ -0,0 +1,28 @@ +--- +navigation_title: "Breaking changes" +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/breaking_changes.html +--- + +# Elasticsearch PHP Client breaking changes [elasticsearch-php-client-breaking-changes] +Breaking changes can impact your Elastic applications, potentially disrupting normal operations. Before you upgrade, carefully review the Elasticsearch PHP Client breaking changes and take the necessary steps to mitigate any issues. To learn how to upgrade, check [Upgrade](docs-content://deploy-manage/upgrade.md). + +% ## Next version [elasticsearch-php-client-nextversion-breaking-changes] + +% ::::{dropdown} Title of breaking change +% Description of the breaking change. +% For more information, check [PR #](PR link). +% **Impact**
Impact of the breaking change. +% **Action**
Steps for mitigating deprecation impact. +% :::: + +## 9.0.0 [elasticsearch-php-client-900-breaking-changes] + +- **Use of PHP 8.1+:** Starting from 9.0.0 the `elasticsearch-php` client requires PHP 8.1+. + +% ::::{dropdown} Title of breaking change +% Description of the breaking change. +% For more information, check [PR #](PR link). +% **Impact**
Impact of the breaking change. +% **Action**
Steps for mitigating deprecation impact. +% :::: \ No newline at end of file diff --git a/docs/release-notes/deprecations.md b/docs/release-notes/deprecations.md new file mode 100644 index 000000000..93d8a73fe --- /dev/null +++ b/docs/release-notes/deprecations.md @@ -0,0 +1,26 @@ +--- +navigation_title: "Deprecations" +--- + +# Elasticsearch PHP Client deprecations [elasticsearch-php-client-deprecations] +Over time, certain Elastic functionality becomes outdated and is replaced or removed. To help with the transition, Elastic deprecates functionality for a period before removal, giving you time to update your applications. + +Review the deprecated functionality for Elasticsearch PHP Client. While deprecations have no immediate impact, we strongly encourage you update your implementation after you upgrade. To learn how to upgrade, check out [Upgrade](docs-content://deploy-manage/upgrade.md). + +% ## Next version [elasticsearch-php-client-versionnext-deprecations] + +% ::::{dropdown} Deprecation title +% Description of the deprecation. +% For more information, check [PR #](PR link). +% **Impact**
Impact of deprecation. +% **Action**
Steps for mitigating deprecation impact. +% :::: + +## 9.0.0 [elasticsearch-php-client-900-deprecations] + +- **Utility::urlencode():** this function has been deprecated in favor of [rawurlencode()](https://www.php.net/manual/en/function.rawurlencode.php) of PHP (see [#1278](https://github.com/elastic/elasticsearch-php/issues/1278)). + +% Description of the deprecation and steps to update implementation. +% For more information, check [PR #](PR link). +% **Impact**
+% **Action**
\ No newline at end of file diff --git a/docs/release-notes/index.md b/docs/release-notes/index.md new file mode 100644 index 000000000..bf5928c7c --- /dev/null +++ b/docs/release-notes/index.md @@ -0,0 +1,37 @@ +--- +navigation_title: "Elasticsearch PHP Client" +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/release-notes.html +--- + +# Elasticsearch PHP Client release notes [elasticsearch-php-client-release-notes] + +Review the changes, fixes, and more in each version of Elasticsearch PHP Client. + +To check for security updates, go to [Security announcements for the Elastic stack](https://discuss.elastic.co/c/announcements/security-announcements/31). + +% Release notes include only features, enhancements, and fixes. Add breaking changes, deprecations, and known issues to the applicable release notes sections. + +% ## version.next [felasticsearch-php-client-next-release-notes] + +% ### Features and enhancements [elasticsearch-php-client-next-features-enhancements] +% * + +% ### Fixes [elasticsearch-php-client-next-fixes] +% * + +## 9.0.0 [elasticsearch-php-client-900-release-notes] + +### Features and enhancements [elasticsearch-php-client-900-features-enhancements] + +- **Compatibility with Elasticsearch 9.0:** All changes and additions to Elasticsearch APIs for its 9.0 release are reflected in this release. +- **Serverless client merged in:** the `elastic/elasticsearch-serverless` client is being deprecated, and its functionality has been merged back into this client. This should have zero impact on the way the client works by default. If an endpoint is available in serverless, the PHP function will contains a `@group serverless` phpdoc attribute. +If you try to use an endpoint that is not available in serverless you will get a `410` HTTP error with a message as follows: +"this endpoint exists but is not available when running in serverless mode". +The 9.0.0 client can recognize that it is communicating with a serverless instance if you are using a URL managed by Elastic (e.g. `*.elastic.cloud`). +If you are using a proxy, the client will be able to recognize that the host is serverless from the first response. Alternatively, you can explicitly indicate that the host is serverless using the `Client::setServerless(true)` function (`false` by default). +- **New transport library with PSR-18 cURL client as default:** we've removed the Guzzle dependency from the client. By default, the built-in cURL-based HTTP client will be used if no other PSR-18 compatible clients are detected. See release [9.0.0](https://github.com/elastic/elastic-transport-php/releases/tag/v9.0.0) of elastic-transport-php. + +### Fixes [elasticsearch-php-client-900-fixes] + +- **Fixed PHPStan array shape:** we fixed the array shape definition for all the endpoints, upgrading PHPStan to verion 2.1. See PR [#1439](https://github.com/elastic/elasticsearch-php/pull/1439) \ No newline at end of file diff --git a/docs/release-notes/known-issues.md b/docs/release-notes/known-issues.md new file mode 100644 index 000000000..8a6af7b29 --- /dev/null +++ b/docs/release-notes/known-issues.md @@ -0,0 +1,24 @@ +--- +navigation_title: "Known issues" + +--- + +# Elasticsearch PHP Client known issues [elasticsearch-php-client-known-issues] + +## 9.0.0 + +_No known issues_ + +% Use the following template to add entries to this page. + +% :::{dropdown} Title of known issue +% **Details** +% On [Month/Day/Year], a known issue was discovered that [description of known issue]. + +% **Workaround** +% Workaround description. + +% **Resolved** +% On [Month/Day/Year], this issue was resolved. + +::: \ No newline at end of file diff --git a/docs/release-notes/toc.yml b/docs/release-notes/toc.yml new file mode 100644 index 000000000..a41006794 --- /dev/null +++ b/docs/release-notes/toc.yml @@ -0,0 +1,5 @@ +toc: + - file: index.md + - file: known-issues.md + - file: breaking-changes.md + - file: deprecations.md \ No newline at end of file diff --git a/docs/set-retries.asciidoc b/docs/set-retries.asciidoc deleted file mode 100644 index fe809289a..000000000 --- a/docs/set-retries.asciidoc +++ /dev/null @@ -1,39 +0,0 @@ -[[set-retries]] -=== Set retries - -By default, the client will retry `n` times, where `n = number of nodes` in your -cluster. A retry is only performed if the operation results in a "hard" -exception: connection refusal, connection timeout, DNS lookup timeout, etc. 4xx -and 5xx errors are not considered retriable events, since the node returns an -operational response. - -If you would like to disable retries, or change the number, you can do so with -the `setRetries()` method: - -[source,php] ----------------------------- - -$client = ClientBuilder::create() - ->setRetries(2) - ->build(); ----------------------------- - -When the client runs out of retries, it will throw the last exception that it -received. For example, if you have ten alive nodes, and `setRetries(5)`, the -client attempts to execute the command up to five times. If all five nodes -result in a connection timeout (for example), the client will throw an -`NoNodeAvailableException`. - -[source,php] ----------------------------- -use Elastic\Transport\Exception\NoNodeAvailableException; - -$client = ClientBuilder::create() - ->build(); - -try { - $reponse = $client->info(); -} catch (NoNodeAvailableException $e) { - printf("No nodes alive: %s", $e->getMessage()); -} ----------------------------- \ No newline at end of file diff --git a/docs/usage.asciidoc b/docs/usage.asciidoc deleted file mode 100644 index d63f560cf..000000000 --- a/docs/usage.asciidoc +++ /dev/null @@ -1,312 +0,0 @@ -[discrete] -[[client-usage]] -=== Usage - -This section is a crash-course overview of the client and its syntax. If you -are familiar with {es}, you'll notice that the methods are named just like REST -endpoints. - -You may also notice that the client is configured in a manner that facilitates -easy discovery via your IDE. All core actions are available under the `$client` -object (indexing, searching, getting, etc). Index and cluster management are -located under the `$client->indices()` and `$client->cluster()` objects, -respectively. - -[discrete] -==== Info API - -You can get information about the {es} instance using the `info()` API, -as follows: - -[source,php] ----------------------------- -$response = $client->info(); ----------------------------- - -The response that you get back contains the information about {es}. -The `$response` is an object of `Elastic\Elasticsearch\Response\Elasticsearch` -class that implements `ElasticsearchInterface`, PSR-7 https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface[ResponseInterface] -and https://www.php.net/manual/en/class.arrayaccess.php[ArrayAccess]. - -This means the `$response` is a https://www.php-fig.org/psr/psr-7/[PSR-7] -object: - -[source,php] ----------------------------- -echo $response->getStatusCode(); // 200 -echo (string) $response->getBody(); // Response body in JSON ----------------------------- - -and also an "array", meaning you can access the response body as an -associative array, as follows: - -[source,php] ----------------------------- -echo $response['version']['number']; // 8.0.0 - -var_dump($response->asArray()); // response body content as array ----------------------------- - -Moreover, you can also access the response body as object, string or bool: - -[source,php] ----------------------------- -echo $response->version->number; // 8.0.0 - -var_dump($response->asObject()); // response body content as object -var_dump($response->asString()); // response body as string (JSON) -var_dump($response->asBool()); // true if HTTP response code between 200 and 300 ----------------------------- - -[discrete] -==== Indexing a document - -To index a document, we need to specify three pieces of information: index, id -and a document body. This is done by constructing an associative array of -key:value pairs. The request body is itself an associative array with key:value -pairs corresponding to the data in your document: - -[source,php] ----------------------------- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id', - 'body' => ['testField' => 'abc'] -]; - -$response = $client->index($params); -print_r($response->asArray()); ----------------------------- - -The response that you get back indicates that the document was created in the -index that you specified. The response can be rendered as associatve array -using the `asArray()` function. The array response contains a -decoded version of the JSON that Elasticsearch returns: - -[source,php] ----------------------------- -Array -( - [_index] => my_index - [_type] => _doc - [_id] => my_id - [_version] => 1 - [created] => 1 -) ----------------------------- - -[discrete] -==== Set the body as JSON string - -If you want you can specify the `body`parameter as JSON string. This can be -useful for testing (eg. copy & paste from online code examples) or if you -have already some JSON documents to be stored in Elasticsearch. - -For instance, the previous index example can be re-written as follows: - -[source,php] ----------------------------- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id', - 'body' => '{"testField" : "abc"}' -]; - -$response = $client->index($params); -print_r($response->asArray()); ----------------------------- - -[discrete] -==== Getting a document - -Let's get the document that we just indexed. This returns the document: - -[source,php] ----------------------------- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id' -]; - -$response = $client->get($params); -print_r($response->asArray()); ----------------------------- - -The response contains metadata such as index, version, and so on as well as a -`_source` field, which is the original document you sent to {es}. - -[source,php] ----------------------------- -Array -( - [_index] => my_index - [_type] => _doc - [_id] => my_id - [_version] => 1 - [found] => 1 - [_source] => Array - ( - [testField] => abc - ) - -) ----------------------------- - - -[discrete] -==== Searching for a document - -Searching is a hallmark of {es}, so let's perform a search. We are going to use -the `match` query as a demonstration: - -[source,php] ----------------------------- -$params = [ - 'index' => 'my_index', - 'body' => [ - 'query' => [ - 'match' => [ - 'testField' => 'abc' - ] - ] - ] -]; - -$response = $client->search($params); -print_r($response->asArray()); ----------------------------- - -The response here is different from the previous ones. You can see metadata -(`took`, `timed_out`, etc.) and an array named `hits`. This represents your -search results. Inside of `hits` is another array named `hits`, which contains -individual search results: - -[source,php] ----------------------------- -Array -( - [took] => 1 - [timed_out] => - [_shards] => Array - ( - [total] => 5 - [successful] => 5 - [failed] => 0 - ) - - [hits] => Array - ( - [total] => 1 - [max_score] => 0.30685282 - [hits] => Array - ( - [0] => Array - ( - [_index] => my_index - [_type] => _doc - [_id] => my_id - [_score] => 0.30685282 - [_source] => Array - ( - [testField] => abc - ) - ) - ) - ) -) ----------------------------- - - -[discrete] -==== Deleting a document - -Alright, let's go ahead and delete the document that we added previously: - -[source,php] ----------------------------- -$params = [ - 'index' => 'my_index', - 'id' => 'my_id' -]; - -$response = $client->delete($params); -print_r($response->asArray()); ----------------------------- - -This syntax is identical to the `get` syntax. The only difference is the -operation: `delete` instead of `get`. The response confirms the document is -deleted: - -[source,php] ----------------------------- -Array -( - [found] => 1 - [_index] => my_index - [_type] => _doc - [_id] => my_id - [_version] => 2 -) ----------------------------- - - -[discrete] -==== Deleting an index - -Due to the dynamic nature of {es}, the first document you added automatically -built an index with some default settings. Delete that index and specify your -own settings later: - -[source,php] ----------------------------- -$deleteParams = [ - 'index' => 'my_index' -]; -$response = $client->indices()->delete($deleteParams); -print_r($response->asArray()); ----------------------------- - -The response: - - -[source,php] ----------------------------- -Array -( - [acknowledged] => 1 -) ----------------------------- - - -[discrete] -==== Creating an index - -Now that you are starting fresh (no data or index), add a new index with custom -settings: - -[source,php] ----------------------------- -$params = [ - 'index' => 'my_index', - 'body' => [ - 'settings' => [ - 'number_of_shards' => 2, - 'number_of_replicas' => 0 - ] - ] -]; - -$response = $client->indices()->create($params); -print_r($response->asArray()); ----------------------------- - -{es} now creates that index with your chosen settings and return an -acknowledgement: - -[source,php] ----------------------------- -Array -( - [acknowledged] => 1 -) ----------------------------- diff --git a/phpstan.neon b/phpstan.neon index 8e7aa19ae..76e5fed53 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,3 +1,8 @@ parameters: + level: 5 + paths: + - src + reportUnmatchedIgnoredErrors: false ignoreErrors: - - '#PHPDoc tag @param has invalid value#' + - '#Offset ''body'' on array\{\}\|array\{#' + - '#Access to an undefined property Elastic\\Elasticsearch\\Client::\$client.#' \ No newline at end of file diff --git a/phpunit-yaml-free-tests.xml b/phpunit-yaml-free-tests.xml deleted file mode 100644 index efb0dc28c..000000000 --- a/phpunit-yaml-free-tests.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - src - - - - - - - - tests/Yaml/Free - - - - - free - - - - - - diff --git a/phpunit-yaml-platinum-tests.xml b/phpunit-yaml-platinum-tests.xml deleted file mode 100644 index 307602b9d..000000000 --- a/phpunit-yaml-platinum-tests.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - src - - - - - - - - tests/Yaml/Platinum - - - - - platinum - - - - - - diff --git a/phpunit-yaml-serverless-tests.xml b/phpunit-yaml-serverless-tests.xml new file mode 100644 index 000000000..5041e9a5f --- /dev/null +++ b/phpunit-yaml-serverless-tests.xml @@ -0,0 +1,24 @@ + + + + + + + + tests/Yaml + + + + + serverless + + + + + + + + src + + + diff --git a/phpunit-yaml-stack-tests.xml b/phpunit-yaml-stack-tests.xml new file mode 100644 index 000000000..d18293b9d --- /dev/null +++ b/phpunit-yaml-stack-tests.xml @@ -0,0 +1,24 @@ + + + + + + + + tests/Yaml + + + + + stack + + + + + + + + src + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1172040f9..f96539a3b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,5 @@ - - - - src - - + tests @@ -18,4 +13,9 @@ cloud + + + src + + diff --git a/src/Client.php b/src/Client.php index 64d2608dc..9388061a1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -23,13 +23,16 @@ use Elastic\Transport\Transport; use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerInterface; final class Client implements ClientInterface { const CLIENT_NAME = 'es'; - const VERSION = '8.15.0'; - const API_COMPATIBILITY_HEADER = '%s/vnd.elasticsearch+%s; compatible-with=8'; + const VERSION = '9.0.0'; + const API_COMPATIBILITY_HEADER = '%s/vnd.elasticsearch+%s; compatible-with=9'; + const API_VERSION_HEADER = 'elastic-api-version'; + const API_VERSION = '2023-10-31'; const SEARCH_ENDPOINTS = [ 'search', @@ -50,6 +53,7 @@ final class Client implements ClientInterface protected Transport $transport; protected LoggerInterface $logger; + protected bool $serverless = false; /** * Specify is the request is asyncronous @@ -156,6 +160,23 @@ public function getResponseException(): bool return $this->responseException; } + /** + * @inheritdoc + */ + public function setServerless(bool $value): self + { + $this->serverless = $value; + return $this; + } + + /** + * @inheritdoc + */ + public function getServerless(): bool + { + return $this->serverless; + } + /** * @inheritdoc */ @@ -168,8 +189,8 @@ public function sendRequest(RequestInterface $request) } $this->transport->setAsyncOnSuccess( $request->getMethod() === 'HEAD' - ? new AsyncOnSuccessNoException - : ($this->getResponseException() ? new AsyncOnSuccess : new AsyncOnSuccessNoException) + ? new AsyncOnSuccessNoException($this) + : ($this->getResponseException() ? new AsyncOnSuccess($this) : new AsyncOnSuccessNoException($this)) ); return $this->transport->sendAsyncRequest($request); } @@ -183,6 +204,7 @@ public function sendRequest(RequestInterface $request) $result = new Elasticsearch; $result->setResponse($response, $request->getMethod() === 'HEAD' ? false : $this->getResponseException()); + $this->serverless = $result->isServerless(); return $result; } } \ No newline at end of file diff --git a/src/ClientBuilder.php b/src/ClientBuilder.php index 0d05e1bdf..128ca398f 100644 --- a/src/ClientBuilder.php +++ b/src/ClientBuilder.php @@ -25,7 +25,6 @@ use Elastic\Transport\NodePool\NodePoolInterface; use Elastic\Transport\Transport; use Elastic\Transport\TransportBuilder; -use GuzzleHttp\Client as GuzzleHttpClient; use Http\Client\HttpAsyncClient; use Psr\Http\Client\ClientInterface; use Psr\Log\LoggerInterface; @@ -226,7 +225,7 @@ public function setHosts(array $hosts): ClientBuilder * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html */ - public function setApiKey(string $apiKey, string $id = null): ClientBuilder + public function setApiKey(string $apiKey, ?string $id = null): ClientBuilder { if (empty($id)) { $this->apiKey = $apiKey; @@ -272,7 +271,7 @@ public function setRetries(int $retries): ClientBuilder * @param string $cert The name of a file containing a PEM formatted certificate * @param string $password if the certificate requires a password */ - public function setSSLCert(string $cert, string $password = null): ClientBuilder + public function setSSLCert(string $cert, ?string $password = null): ClientBuilder { $this->sslCert = [$cert, $password]; return $this; @@ -295,7 +294,7 @@ public function setCABundle(string $cert): ClientBuilder * @param string $key The name of a file containing a private SSL key * @param string $password if the private key requires a password */ - public function setSSLKey(string $key, string $password = null): ClientBuilder + public function setSSLKey(string $key, ?string $password = null): ClientBuilder { $this->sslKey = [$key, $password]; return $this; @@ -390,10 +389,10 @@ public function build(): Client } /** - * Elastic cloud optimized with gzip + * Elastic cloud or serverless optimized with gzip * @see https://github.com/elastic/elasticsearch-php/issues/1241 omit for Symfony HTTP Client */ - if (!empty($this->cloudId) && !$this->isSymfonyHttpClient($transport)) { + if ((!empty($this->cloudId) || $this->isCloud($this->hosts) || $this->isServerless($this->hosts)) && !$this->isSymfonyHttpClient($transport)) { $transport->setHeader('Accept-Encoding', 'gzip'); } @@ -401,9 +400,47 @@ public function build(): Client // Enable or disable the x-elastic-client-meta header $client->setElasticMetaHeader($this->elasticMetaHeader); + if ($this->isServerless($this->hosts)) { + $client->setServerless(true); + } return $client; } + /** + * Check if the hosts contains an Elastic Cloud url + */ + protected function isCloud(array $hosts): bool + { + if (empty($hosts) || count($hosts)>1) { + return false; + } + $url = $hosts[0]; + // Elastic Cloud gcp + if (preg_match('/\.cloud\.es\.io/i', $url)) { + return true; + } + // Elastic Cloud aws or azure + if (preg_match('/\.elastic-cloud\.com/i', $url)) { + return true; + } + return false; + } + + /** + * Check if the hosts contains an Elastic Serverless url + */ + protected function isServerless(array $hosts): bool + { + if (empty($hosts) || count($hosts)>1) { + return false; + } + $url = $hosts[0]; + if (preg_match('/\.elastic\.cloud/i', $url)) { + return true; + } + return false; + } + /** * Returns true if the transport HTTP client is Symfony */ @@ -469,4 +506,4 @@ protected function setOptions(ClientInterface $client, array $config, array $cli $adapter = new $adapterClass; return $adapter->setConfig($client, $config, $clientOptions); } -} \ No newline at end of file +} diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 04b982c85..b71eaf560 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -62,6 +62,16 @@ public function setResponseException(bool $active): self; */ public function getResponseException(): bool; + /** + * Set Elastic Serverless to true or false + */ + public function setServerless(bool $value): self; + + /** + * Returns true if the client is set (or connected) to Serverless + */ + public function getServerless(): bool; + /** * Send the HTTP request using the Elastic Transport. * It manages syncronous and asyncronus requests using Client::getAsync() diff --git a/src/Endpoints/AsyncSearch.php b/src/Endpoints/AsyncSearch.php index a1a0cee41..9433d2a56 100644 --- a/src/Endpoints/AsyncSearch.php +++ b/src/Endpoints/AsyncSearch.php @@ -31,15 +31,16 @@ class AsyncSearch extends AbstractEndpoint /** * Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The async search ID - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -49,8 +50,9 @@ class AsyncSearch extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function delete(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_async_search/' . $this->encode($params['id']); $method = 'DELETE'; @@ -68,18 +70,19 @@ public function delete(array $params = []) /** * Retrieves the results of a previously submitted async search request given its ID. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The async search ID - * wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response - * keep_alive: time, // Specify the time interval in which the results (partial or final) for this search will be available - * typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * wait_for_completion_timeout?: int|string, // Specify the time that the request should block waiting for the final response + * keep_alive?: int|string, // Specify the time interval in which the results (partial or final) for this search will be available + * typed_keys?: bool, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -89,8 +92,9 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function get(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_async_search/' . $this->encode($params['id']); $method = 'GET'; @@ -108,16 +112,17 @@ public function get(array $params = []) /** * Retrieves the status of a previously submitted async search request given its ID. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The async search ID - * keep_alive: time, // Specify the time interval in which the results (partial or final) for this search will be available - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * keep_alive?: int|string, // Specify the time interval in which the results (partial or final) for this search will be available + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -127,8 +132,9 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function status(array $params = []) + public function status(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_async_search/status/' . $this->encode($params['id']); $method = 'GET'; @@ -146,57 +152,60 @@ public function status(array $params = []) /** * Executes a search request asynchronously. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response - * keep_on_completion: boolean, // Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) - * keep_alive: time, // Update the time interval in which the results (partial or final) for this search will be available - * batched_reduce_size: number, // The number of shard results that should be reduced at once on the coordinating node. This value should be used as the granularity at which progress results will be made available. - * request_cache: boolean, // Specify if request cache should be used for this request or not, defaults to true - * analyzer: string, // The analyzer to use for the query string - * analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false) - * default_operator: enum, // The default operator for query string query (AND or OR) - * df: string, // The field to use as default where no field prefix is given in the query string - * explain: boolean, // Specify whether to return detailed information about score computation as part of a hit - * stored_fields: list, // A comma-separated list of stored fields to return as part of a hit - * docvalue_fields: list, // A comma-separated list of fields to return as the docvalue representation of a field for each hit - * from: number, // Starting offset (default: 0) - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * ignore_throttled: boolean, // Whether specified concrete, expanded or aliased indices should be ignored when throttled - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * q: string, // Query in the Lucene query string syntax - * routing: list, // A comma-separated list of specific routing values - * search_type: enum, // Search operation type - * size: number, // Number of hits to return (default: 10) - * sort: list, // A comma-separated list of : pairs - * _source: list, // True or false to return the _source field or not, or a list of fields to return - * _source_excludes: list, // A list of fields to exclude from the returned _source field - * _source_includes: list, // A list of fields to extract and return from the _source field - * terminate_after: number, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - * stats: list, // Specific 'tag' of the request for logging and statistical purposes - * suggest_field: string, // Specify which field to use for suggestions - * suggest_mode: enum, // Specify suggest mode - * suggest_size: number, // How many suggestions to return in response - * suggest_text: string, // The source text for which the suggestions should be returned - * timeout: time, // Explicit operation timeout - * track_scores: boolean, // Whether to calculate and return scores even if they are not used for sorting - * track_total_hits: boolean|long, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. - * allow_partial_search_results: boolean, // Indicate if an error should be returned if there is a partial search failure or timeout - * typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response - * version: boolean, // Specify whether to return document version as part of a hit - * seq_no_primary_term: boolean, // Specify whether to return sequence number and primary term of the last modification of each hit - * max_concurrent_shard_requests: number, // The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The search definition using the Query DSL + * index?: string|array, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * wait_for_completion_timeout?: int|string, // Specify the time that the request should block waiting for the final response + * keep_on_completion?: bool, // Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) + * keep_alive?: int|string, // Update the time interval in which the results (partial or final) for this search will be available + * batched_reduce_size?: int, // The number of shard results that should be reduced at once on the coordinating node. This value should be used as the granularity at which progress results will be made available. + * request_cache?: bool, // Specify if request cache should be used for this request or not, defaults to true + * analyzer?: string, // The analyzer to use for the query string + * analyze_wildcard?: bool, // Specify whether wildcard and prefix queries should be analyzed (default: false) + * ccs_minimize_roundtrips?: bool, // When doing a cross-cluster search, setting it to true may improve overall search latency, particularly when searching clusters with a large number of shards. However, when set to true, the progress of searches on the remote clusters will not be received until the search finishes on all clusters. + * default_operator?: string, // The default operator for query string query (AND or OR) + * df?: string, // The field to use as default where no field prefix is given in the query string + * explain?: bool, // Specify whether to return detailed information about score computation as part of a hit + * stored_fields?: string|array, // A comma-separated list of stored fields to return as part of a hit + * docvalue_fields?: string|array, // A comma-separated list of fields to return as the docvalue representation of a field for each hit + * from?: int, // Starting offset (default: 0) + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * ignore_throttled?: bool, // Whether specified concrete, expanded or aliased indices should be ignored when throttled + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * lenient?: bool, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * rest_total_hits_as_int?: bool, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * q?: string, // Query in the Lucene query string syntax + * routing?: string|array, // A comma-separated list of specific routing values + * search_type?: string, // Search operation type + * size?: int, // Number of hits to return (default: 10) + * sort?: string|array, // A comma-separated list of : pairs + * _source?: string|array, // True or false to return the _source field or not, or a list of fields to return + * _source_excludes?: string|array, // A list of fields to exclude from the returned _source field + * _source_includes?: string|array, // A list of fields to extract and return from the _source field + * terminate_after?: int, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * stats?: string|array, // Specific 'tag' of the request for logging and statistical purposes + * suggest_field?: string, // Specify which field to use for suggestions + * suggest_mode?: string, // Specify suggest mode + * suggest_size?: int, // How many suggestions to return in response + * suggest_text?: string, // The source text for which the suggestions should be returned + * timeout?: int|string, // Explicit operation timeout + * track_scores?: bool, // Whether to calculate and return scores even if they are not used for sorting + * track_total_hits?: bool|int, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. + * allow_partial_search_results?: bool, // Indicate if an error should be returned if there is a partial search failure or timeout + * typed_keys?: bool, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * version?: bool, // Specify whether to return document version as part of a hit + * seq_no_primary_term?: bool, // Specify whether to return sequence number and primary term of the last modification of each hit + * max_concurrent_shard_requests?: int, // The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The search definition using the Query DSL. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -205,16 +214,17 @@ public function status(array $params = []) * * @return Elasticsearch|Promise */ - public function submit(array $params = []) + public function submit(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_async_search'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_async_search'; $method = 'POST'; } else { $url = '/_async_search'; $method = 'POST'; } - $url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_on_completion','keep_alive','batched_reduce_size','request_cache','analyzer','analyze_wildcard','default_operator','df','explain','stored_fields','docvalue_fields','from','ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','lenient','preference','q','routing','search_type','size','sort','_source','_source_excludes','_source_includes','terminate_after','stats','suggest_field','suggest_mode','suggest_size','suggest_text','timeout','track_scores','track_total_hits','allow_partial_search_results','typed_keys','version','seq_no_primary_term','max_concurrent_shard_requests','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_on_completion','keep_alive','batched_reduce_size','request_cache','analyzer','analyze_wildcard','ccs_minimize_roundtrips','default_operator','df','explain','stored_fields','docvalue_fields','from','ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','lenient','preference','rest_total_hits_as_int','q','routing','search_type','size','sort','_source','_source_excludes','_source_includes','terminate_after','stats','suggest_field','suggest_mode','suggest_size','suggest_text','timeout','track_scores','track_total_hits','allow_partial_search_results','typed_keys','version','seq_no_primary_term','max_concurrent_shard_requests','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Endpoints/Autoscaling.php b/src/Endpoints/Autoscaling.php index 75481fc88..41f0a5299 100644 --- a/src/Endpoints/Autoscaling.php +++ b/src/Endpoints/Autoscaling.php @@ -31,17 +31,17 @@ class Autoscaling extends AbstractEndpoint /** * Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-delete-autoscaling-policy.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-delete-autoscaling-policy.html * * @param array{ * name: string, // (REQUIRED) the name of the autoscaling policy - * master_timeout: time, // Timeout for processing on master node - * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Timeout for processing on master node + * timeout?: int|string, // Timeout for acknowledgement of update from all nodes in cluster + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -51,8 +51,9 @@ class Autoscaling extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteAutoscalingPolicy(array $params = []) + public function deleteAutoscalingPolicy(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_autoscaling/policy/' . $this->encode($params['name']); $method = 'DELETE'; @@ -70,15 +71,15 @@ public function deleteAutoscalingPolicy(array $params = []) /** * 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 https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-capacity.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-capacity.html * * @param array{ - * master_timeout: time, // Timeout for processing on master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Timeout for processing on master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -87,8 +88,9 @@ public function deleteAutoscalingPolicy(array $params = []) * * @return Elasticsearch|Promise */ - public function getAutoscalingCapacity(array $params = []) + public function getAutoscalingCapacity(?array $params = null) { + $params = $params ?? []; $url = '/_autoscaling/capacity'; $method = 'GET'; @@ -105,16 +107,16 @@ public function getAutoscalingCapacity(array $params = []) /** * Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-policy.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-policy.html * * @param array{ * name: string, // (REQUIRED) the name of the autoscaling policy - * master_timeout: time, // Timeout for processing on master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Timeout for processing on master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -124,8 +126,9 @@ public function getAutoscalingCapacity(array $params = []) * * @return Elasticsearch|Promise */ - public function getAutoscalingPolicy(array $params = []) + public function getAutoscalingPolicy(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_autoscaling/policy/' . $this->encode($params['name']); $method = 'GET'; @@ -143,18 +146,18 @@ public function getAutoscalingPolicy(array $params = []) /** * Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-put-autoscaling-policy.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-put-autoscaling-policy.html * * @param array{ * name: string, // (REQUIRED) the name of the autoscaling policy - * master_timeout: time, // Timeout for processing on master node - * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) the specification of the autoscaling policy + * master_timeout?: int|string, // Timeout for processing on master node + * timeout?: int|string, // Timeout for acknowledgement of update from all nodes in cluster + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) the specification of the autoscaling policy. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -164,8 +167,9 @@ public function getAutoscalingPolicy(array $params = []) * * @return Elasticsearch|Promise */ - public function putAutoscalingPolicy(array $params = []) + public function putAutoscalingPolicy(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name','body'], $params); $url = '/_autoscaling/policy/' . $this->encode($params['name']); $method = 'PUT'; diff --git a/src/Endpoints/Cat.php b/src/Endpoints/Cat.php index 026f7ba32..5411ebac7 100644 --- a/src/Endpoints/Cat.php +++ b/src/Endpoints/Cat.php @@ -31,22 +31,23 @@ class Cat extends AbstractEndpoint /** * Shows information about currently configured aliases to indices including filter and routing infos. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html + * @group serverless * * @param array{ - * name: list, // A comma-separated list of alias names to return - * format: string, // a short version of the Accept header, e.g. json, yaml - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // A comma-separated list of alias names to return + * format?: string, // a short version of the Accept header, e.g. json, yaml + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * master_timeout?: int|string, // Timeout for waiting for new cluster state in case it is blocked + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -55,16 +56,17 @@ class Cat extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function aliases(array $params = []) + public function aliases(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { - $url = '/_cat/aliases/' . $this->encode($params['name']); + $url = '/_cat/aliases/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } else { $url = '/_cat/aliases'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['format','local','h','help','s','v','expand_wildcards','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['format','h','help','s','v','expand_wildcards','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'text/plain,application/json', ]; @@ -77,23 +79,23 @@ public function aliases(array $params = []) /** * Provides a snapshot of how many shards are allocated to each data node and how much disk space they are using. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html * * @param array{ - * node_id: list, // A comma-separated list of node IDs or names to limit the returned information - * format: string, // a short version of the Accept header, e.g. json, yaml - * bytes: enum, // The unit in which to display byte values - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id?: string|array, // A comma-separated list of node IDs or names to limit the returned information + * format?: string, // a short version of the Accept header, e.g. json, yaml + * bytes?: string, // The unit in which to display byte values + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -102,10 +104,11 @@ public function aliases(array $params = []) * * @return Elasticsearch|Promise */ - public function allocation(array $params = []) + public function allocation(?array $params = null) { + $params = $params ?? []; if (isset($params['node_id'])) { - $url = '/_cat/allocation/' . $this->encode($params['node_id']); + $url = '/_cat/allocation/' . $this->encode($this->convertValue($params['node_id'])); $method = 'GET'; } else { $url = '/_cat/allocation'; @@ -124,22 +127,23 @@ public function allocation(array $params = []) /** * Returns information about existing component_templates templates. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-component-templates.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-component-templates.html + * @group serverless * * @param array{ - * name: string, // A pattern that returned component template names must match - * format: string, // a short version of the Accept header, e.g. json, yaml - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string, // A pattern that returned component template names must match + * format?: string, // a short version of the Accept header, e.g. json, yaml + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -148,8 +152,9 @@ public function allocation(array $params = []) * * @return Elasticsearch|Promise */ - public function componentTemplates(array $params = []) + public function componentTemplates(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { $url = '/_cat/component_templates/' . $this->encode($params['name']); $method = 'GET'; @@ -170,20 +175,21 @@ public function componentTemplates(array $params = []) /** * Provides quick access to the document count of the entire cluster, or individual indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names to limit the returned information - * format: string, // a short version of the Accept header, e.g. json, yaml - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names to limit the returned information + * format?: string, // a short version of the Accept header, e.g. json, yaml + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -192,10 +198,11 @@ public function componentTemplates(array $params = []) * * @return Elasticsearch|Promise */ - public function count(array $params = []) + public function count(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/_cat/count/' . $this->encode($params['index']); + $url = '/_cat/count/' . $this->encode($this->convertValue($params['index'])); $method = 'GET'; } else { $url = '/_cat/count'; @@ -214,21 +221,21 @@ public function count(array $params = []) /** * Shows how much heap memory is currently being used by fielddata on every data node in the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html * * @param array{ - * fields: list, // A comma-separated list of fields to return the fielddata size - * format: string, // a short version of the Accept header, e.g. json, yaml - * bytes: enum, // The unit in which to display byte values - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * fields?: string|array, // A comma-separated list of fields to return the fielddata size + * format?: string, // a short version of the Accept header, e.g. json, yaml + * bytes?: string, // The unit in which to display byte values + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -237,10 +244,11 @@ public function count(array $params = []) * * @return Elasticsearch|Promise */ - public function fielddata(array $params = []) + public function fielddata(?array $params = null) { + $params = $params ?? []; if (isset($params['fields'])) { - $url = '/_cat/fielddata/' . $this->encode($params['fields']); + $url = '/_cat/fielddata/' . $this->encode($this->convertValue($params['fields'])); $method = 'GET'; } else { $url = '/_cat/fielddata'; @@ -259,21 +267,21 @@ public function fielddata(array $params = []) /** * Returns a concise representation of the cluster health. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html * * @param array{ - * format: string, // a short version of the Accept header, e.g. json, yaml - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * ts: boolean, // Set to false to disable timestamping - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * format?: string, // a short version of the Accept header, e.g. json, yaml + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * ts?: bool, // Set to false to disable timestamping + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -282,8 +290,9 @@ public function fielddata(array $params = []) * * @return Elasticsearch|Promise */ - public function health(array $params = []) + public function health(?array $params = null) { + $params = $params ?? []; $url = '/_cat/health'; $method = 'GET'; @@ -300,16 +309,15 @@ public function health(array $params = []) /** * Returns help for the Cat APIs. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html + * @group serverless * * @param array{ - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -318,12 +326,13 @@ public function health(array $params = []) * * @return Elasticsearch|Promise */ - public function help(array $params = []) + public function help(?array $params = null) { + $params = $params ?? []; $url = '/_cat'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['help','s','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'text/plain', ]; @@ -336,27 +345,28 @@ public function help(array $params = []) /** * Returns information about indices: number of primaries and replicas, document counts, disk size, ... * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names to limit the returned information - * format: string, // a short version of the Accept header, e.g. json, yaml - * bytes: enum, // The unit in which to display byte values - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * health: enum, // A health status ("green", "yellow", or "red" to filter only indices matching the specified health status - * help: boolean, // Return help information - * pri: boolean, // Set to true to return stats only for primary shards - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * include_unloaded_segments: boolean, // If set to true segment stats will include stats for segments that are not currently loaded into memory - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names to limit the returned information + * format?: string, // a short version of the Accept header, e.g. json, yaml + * bytes?: string, // The unit in which to display byte values + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * health?: string, // A health status ("green", "yellow", or "red" to filter only indices matching the specified health status + * help?: bool, // Return help information + * pri?: bool, // Set to true to return stats only for primary shards + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * include_unloaded_segments?: bool, // If set to true segment stats will include stats for segments that are not currently loaded into memory + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -365,10 +375,11 @@ public function help(array $params = []) * * @return Elasticsearch|Promise */ - public function indices(array $params = []) + public function indices(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/_cat/indices/' . $this->encode($params['index']); + $url = '/_cat/indices/' . $this->encode($this->convertValue($params['index'])); $method = 'GET'; } else { $url = '/_cat/indices'; @@ -387,21 +398,21 @@ public function indices(array $params = []) /** * Returns information about the master node. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html * * @param array{ - * format: string, // a short version of the Accept header, e.g. json, yaml - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * format?: string, // a short version of the Accept header, e.g. json, yaml + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -410,8 +421,9 @@ public function indices(array $params = []) * * @return Elasticsearch|Promise */ - public function master(array $params = []) + public function master(?array $params = null) { + $params = $params ?? []; $url = '/_cat/master'; $method = 'GET'; @@ -428,23 +440,24 @@ public function master(array $params = []) /** * Gets configuration and usage information about data frame analytics jobs. * - * @see http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-dfanalytics.html + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-dfanalytics.html + * @group serverless * * @param array{ - * id: string, // The ID of the data frame analytics to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no configs. (This includes `_all` string or when no configs have been specified) - * bytes: enum, // The unit in which to display byte values - * format: string, // a short version of the Accept header, e.g. json, yaml - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * id?: string, // The ID of the data frame analytics to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no configs. (This includes `_all` string or when no configs have been specified) + * bytes?: string, // The unit in which to display byte values + * format?: string, // a short version of the Accept header, e.g. json, yaml + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -453,8 +466,9 @@ public function master(array $params = []) * * @return Elasticsearch|Promise */ - public function mlDataFrameAnalytics(array $params = []) + public function mlDataFrameAnalytics(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_cat/ml/data_frame/analytics/' . $this->encode($params['id']); $method = 'GET'; @@ -475,22 +489,23 @@ public function mlDataFrameAnalytics(array $params = []) /** * Gets configuration and usage information about datafeeds. * - * @see http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html + * @group serverless * * @param array{ - * datafeed_id: string, // The ID of the datafeeds stats to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - * format: string, // a short version of the Accept header, e.g. json, yaml - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * datafeed_id?: string, // The ID of the datafeeds stats to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + * format?: string, // a short version of the Accept header, e.g. json, yaml + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -499,8 +514,9 @@ public function mlDataFrameAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function mlDatafeeds(array $params = []) + public function mlDatafeeds(?array $params = null) { + $params = $params ?? []; if (isset($params['datafeed_id'])) { $url = '/_cat/ml/datafeeds/' . $this->encode($params['datafeed_id']); $method = 'GET'; @@ -521,23 +537,24 @@ public function mlDatafeeds(array $params = []) /** * Gets configuration and usage information about anomaly detection jobs. * - * @see http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html + * @group serverless * * @param array{ - * job_id: string, // The ID of the jobs stats to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - * bytes: enum, // The unit in which to display byte values - * format: string, // a short version of the Accept header, e.g. json, yaml - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * job_id?: string, // The ID of the jobs stats to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + * bytes?: string, // The unit in which to display byte values + * format?: string, // a short version of the Accept header, e.g. json, yaml + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -546,8 +563,9 @@ public function mlDatafeeds(array $params = []) * * @return Elasticsearch|Promise */ - public function mlJobs(array $params = []) + public function mlJobs(?array $params = null) { + $params = $params ?? []; if (isset($params['job_id'])) { $url = '/_cat/ml/anomaly_detectors/' . $this->encode($params['job_id']); $method = 'GET'; @@ -568,25 +586,26 @@ public function mlJobs(array $params = []) /** * Gets configuration and usage information about inference trained models. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html + * @group serverless * * @param array{ - * model_id: string, // The ID of the trained models stats to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) - * from: int, // skips a number of trained models - * size: int, // specifies a max number of trained models to get - * bytes: enum, // The unit in which to display byte values - * format: string, // a short version of the Accept header, e.g. json, yaml - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * model_id?: string, // The ID of the trained models stats to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + * from?: int, // skips a number of trained models + * size?: int, // specifies a max number of trained models to get + * bytes?: string, // The unit in which to display byte values + * format?: string, // a short version of the Accept header, e.g. json, yaml + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -595,8 +614,9 @@ public function mlJobs(array $params = []) * * @return Elasticsearch|Promise */ - public function mlTrainedModels(array $params = []) + public function mlTrainedModels(?array $params = null) { + $params = $params ?? []; if (isset($params['model_id'])) { $url = '/_cat/ml/trained_models/' . $this->encode($params['model_id']); $method = 'GET'; @@ -617,21 +637,21 @@ public function mlTrainedModels(array $params = []) /** * Returns information about custom node attributes. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html * * @param array{ - * format: string, // a short version of the Accept header, e.g. json, yaml - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * format?: string, // a short version of the Accept header, e.g. json, yaml + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -640,8 +660,9 @@ public function mlTrainedModels(array $params = []) * * @return Elasticsearch|Promise */ - public function nodeattrs(array $params = []) + public function nodeattrs(?array $params = null) { + $params = $params ?? []; $url = '/_cat/nodeattrs'; $method = 'GET'; @@ -658,24 +679,24 @@ public function nodeattrs(array $params = []) /** * Returns basic statistics about performance of cluster nodes. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html * * @param array{ - * bytes: enum, // The unit in which to display byte values - * format: string, // a short version of the Accept header, e.g. json, yaml - * full_id: boolean, // Return the full node ID instead of the shortened version (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * include_unloaded_segments: boolean, // If set to true segment stats will include stats for segments that are not currently loaded into memory - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * bytes?: string, // The unit in which to display byte values + * format?: string, // a short version of the Accept header, e.g. json, yaml + * full_id?: bool, // Return the full node ID instead of the shortened version (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * include_unloaded_segments?: bool, // If set to true segment stats will include stats for segments that are not currently loaded into memory + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -684,8 +705,9 @@ public function nodeattrs(array $params = []) * * @return Elasticsearch|Promise */ - public function nodes(array $params = []) + public function nodes(?array $params = null) { + $params = $params ?? []; $url = '/_cat/nodes'; $method = 'GET'; @@ -702,22 +724,22 @@ public function nodes(array $params = []) /** * Returns a concise representation of the cluster pending tasks. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html * * @param array{ - * format: string, // a short version of the Accept header, e.g. json, yaml - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * format?: string, // a short version of the Accept header, e.g. json, yaml + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -726,8 +748,9 @@ public function nodes(array $params = []) * * @return Elasticsearch|Promise */ - public function pendingTasks(array $params = []) + public function pendingTasks(?array $params = null) { + $params = $params ?? []; $url = '/_cat/pending_tasks'; $method = 'GET'; @@ -744,22 +767,22 @@ public function pendingTasks(array $params = []) /** * Returns information about installed plugins across nodes node. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html * * @param array{ - * format: string, // a short version of the Accept header, e.g. json, yaml - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * include_bootstrap: boolean, // Include bootstrap plugins in the response - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * format?: string, // a short version of the Accept header, e.g. json, yaml + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * include_bootstrap?: bool, // Include bootstrap plugins in the response + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -768,8 +791,9 @@ public function pendingTasks(array $params = []) * * @return Elasticsearch|Promise */ - public function plugins(array $params = []) + public function plugins(?array $params = null) { + $params = $params ?? []; $url = '/_cat/plugins'; $method = 'GET'; @@ -786,24 +810,24 @@ public function plugins(array $params = []) /** * Returns information about index shard recoveries, both on-going completed. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html * * @param array{ - * index: list, // Comma-separated list or wildcard expression of index names to limit the returned information - * format: string, // a short version of the Accept header, e.g. json, yaml - * active_only: boolean, // If `true`, the response only includes ongoing shard recoveries - * bytes: enum, // The unit in which to display byte values - * detailed: boolean, // If `true`, the response includes detailed information about shard recoveries - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // Comma-separated list or wildcard expression of index names to limit the returned information + * format?: string, // a short version of the Accept header, e.g. json, yaml + * active_only?: bool, // If `true`, the response only includes ongoing shard recoveries + * bytes?: string, // The unit in which to display byte values + * detailed?: bool, // If `true`, the response includes detailed information about shard recoveries + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -812,10 +836,11 @@ public function plugins(array $params = []) * * @return Elasticsearch|Promise */ - public function recovery(array $params = []) + public function recovery(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/_cat/recovery/' . $this->encode($params['index']); + $url = '/_cat/recovery/' . $this->encode($this->convertValue($params['index'])); $method = 'GET'; } else { $url = '/_cat/recovery'; @@ -834,21 +859,21 @@ public function recovery(array $params = []) /** * Returns information about snapshot repositories registered in the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html * * @param array{ - * format: string, // a short version of the Accept header, e.g. json, yaml - * local: boolean, // Return local information, do not retrieve the state from master node - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * format?: string, // a short version of the Accept header, e.g. json, yaml + * local?: bool, // Return local information, do not retrieve the state from master node + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -857,8 +882,9 @@ public function recovery(array $params = []) * * @return Elasticsearch|Promise */ - public function repositories(array $params = []) + public function repositories(?array $params = null) { + $params = $params ?? []; $url = '/_cat/repositories'; $method = 'GET'; @@ -875,21 +901,23 @@ public function repositories(array $params = []) /** * Provides low-level information about the segments in the shards of an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html * * @param array{ - * index: list, // A comma-separated list of index names to limit the returned information - * format: string, // a short version of the Accept header, e.g. json, yaml - * bytes: enum, // The unit in which to display byte values - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names to limit the returned information + * format?: string, // a short version of the Accept header, e.g. json, yaml + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * bytes?: string, // The unit in which to display byte values + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -898,16 +926,17 @@ public function repositories(array $params = []) * * @return Elasticsearch|Promise */ - public function segments(array $params = []) + public function segments(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/_cat/segments/' . $this->encode($params['index']); + $url = '/_cat/segments/' . $this->encode($this->convertValue($params['index'])); $method = 'GET'; } else { $url = '/_cat/segments'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['format','bytes','h','help','s','v','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['format','local','master_timeout','bytes','h','help','s','v','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'text/plain,application/json', ]; @@ -920,23 +949,23 @@ public function segments(array $params = []) /** * Provides a detailed view of shard allocation on nodes. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html * * @param array{ - * index: list, // A comma-separated list of index names to limit the returned information - * format: string, // a short version of the Accept header, e.g. json, yaml - * bytes: enum, // The unit in which to display byte values - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names to limit the returned information + * format?: string, // a short version of the Accept header, e.g. json, yaml + * bytes?: string, // The unit in which to display byte values + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -945,10 +974,11 @@ public function segments(array $params = []) * * @return Elasticsearch|Promise */ - public function shards(array $params = []) + public function shards(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/_cat/shards/' . $this->encode($params['index']); + $url = '/_cat/shards/' . $this->encode($this->convertValue($params['index'])); $method = 'GET'; } else { $url = '/_cat/shards'; @@ -967,23 +997,23 @@ public function shards(array $params = []) /** * Returns all snapshots in a specific repository. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html * * @param array{ - * repository: list, // Name of repository from which to fetch the snapshot information - * format: string, // a short version of the Accept header, e.g. json, yaml - * ignore_unavailable: boolean, // Set to true to ignore unavailable snapshots - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * repository?: string|array, // Name of repository from which to fetch the snapshot information + * format?: string, // a short version of the Accept header, e.g. json, yaml + * ignore_unavailable?: bool, // Set to true to ignore unavailable snapshots + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -992,10 +1022,11 @@ public function shards(array $params = []) * * @return Elasticsearch|Promise */ - public function snapshots(array $params = []) + public function snapshots(?array $params = null) { + $params = $params ?? []; if (isset($params['repository'])) { - $url = '/_cat/snapshots/' . $this->encode($params['repository']); + $url = '/_cat/snapshots/' . $this->encode($this->convertValue($params['repository'])); $method = 'GET'; } else { $url = '/_cat/snapshots'; @@ -1014,25 +1045,27 @@ public function snapshots(array $params = []) /** * Returns information about the tasks currently executing on one or more nodes in the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * format: string, // a short version of the Accept header, e.g. json, yaml - * nodes: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - * actions: list, // A comma-separated list of actions that should be returned. Leave empty to return all. - * detailed: boolean, // Return detailed task information (default: false) - * parent_task_id: string, // Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * format?: string, // a short version of the Accept header, e.g. json, yaml + * nodes?: string|array, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * actions?: string|array, // A comma-separated list of actions that should be returned. Leave empty to return all. + * detailed?: bool, // Return detailed task information (default: false) + * parent_task_id?: string, // Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * timeout?: int|string, // Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + * wait_for_completion?: bool, // If `true`, the request blocks until the task has completed. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1041,12 +1074,13 @@ public function snapshots(array $params = []) * * @return Elasticsearch|Promise */ - public function tasks(array $params = []) + public function tasks(?array $params = null) { + $params = $params ?? []; $url = '/_cat/tasks'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['format','nodes','actions','detailed','parent_task_id','h','help','s','time','v','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['format','nodes','actions','detailed','parent_task_id','h','help','s','time','v','timeout','wait_for_completion','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'text/plain,application/json', ]; @@ -1059,22 +1093,22 @@ public function tasks(array $params = []) /** * Returns information about existing templates. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html * * @param array{ - * name: string, // A pattern that returned template names must match - * format: string, // a short version of the Accept header, e.g. json, yaml - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string, // A pattern that returned template names must match + * format?: string, // a short version of the Accept header, e.g. json, yaml + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1083,8 +1117,9 @@ public function tasks(array $params = []) * * @return Elasticsearch|Promise */ - public function templates(array $params = []) + public function templates(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { $url = '/_cat/templates/' . $this->encode($params['name']); $method = 'GET'; @@ -1106,23 +1141,23 @@ public function templates(array $params = []) * Returns cluster-wide thread pool statistics per node. * By default the active, queue and rejected statistics are returned for all thread pools. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html * * @param array{ - * thread_pool_patterns: list, // A comma-separated list of regular-expressions to filter the thread pools in the output - * format: string, // a short version of the Accept header, e.g. json, yaml - * time: enum, // The unit in which to display time values - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * thread_pool_patterns?: string|array, // A comma-separated list of regular-expressions to filter the thread pools in the output + * format?: string, // a short version of the Accept header, e.g. json, yaml + * time?: string, // The unit in which to display time values + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1131,10 +1166,11 @@ public function templates(array $params = []) * * @return Elasticsearch|Promise */ - public function threadPool(array $params = []) + public function threadPool(?array $params = null) { + $params = $params ?? []; if (isset($params['thread_pool_patterns'])) { - $url = '/_cat/thread_pool/' . $this->encode($params['thread_pool_patterns']); + $url = '/_cat/thread_pool/' . $this->encode($this->convertValue($params['thread_pool_patterns'])); $method = 'GET'; } else { $url = '/_cat/thread_pool'; @@ -1153,24 +1189,25 @@ public function threadPool(array $params = []) /** * Gets configuration and usage information about transforms. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html + * @group serverless * * @param array{ - * transform_id: string, // The id of the transform for which to get stats. '_all' or '*' implies all transforms - * from: int, // skips a number of transform configs, defaults to 0 - * size: int, // specifies a max number of transforms to get, defaults to 100 - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - * format: string, // a short version of the Accept header, e.g. json, yaml - * h: list, // Comma-separated list of column names to display - * help: boolean, // Return help information - * s: list, // Comma-separated list of column names or column aliases to sort by - * time: enum, // The unit in which to display time values - * v: boolean, // Verbose mode. Display column headers - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * transform_id?: string, // The id of the transform for which to get stats. '_all' or '*' implies all transforms + * from?: int, // skips a number of transform configs, defaults to 0 + * size?: int, // specifies a max number of transforms to get, defaults to 100 + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) + * format?: string, // a short version of the Accept header, e.g. json, yaml + * h?: string|array, // Comma-separated list of column names to display + * help?: bool, // Return help information + * s?: string|array, // Comma-separated list of column names or column aliases to sort by + * time?: string, // The unit in which to display time values + * v?: bool, // Verbose mode. Display column headers + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1179,8 +1216,9 @@ public function threadPool(array $params = []) * * @return Elasticsearch|Promise */ - public function transforms(array $params = []) + public function transforms(?array $params = null) { + $params = $params ?? []; if (isset($params['transform_id'])) { $url = '/_cat/transforms/' . $this->encode($params['transform_id']); $method = 'GET'; diff --git a/src/Endpoints/Ccr.php b/src/Endpoints/Ccr.php index 9a14314c4..218fb9efa 100644 --- a/src/Endpoints/Ccr.php +++ b/src/Endpoints/Ccr.php @@ -31,16 +31,16 @@ class Ccr extends AbstractEndpoint /** * Deletes auto-follow patterns. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html * * @param array{ * name: string, // (REQUIRED) The name of the auto follow pattern. - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -50,8 +50,9 @@ class Ccr extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteAutoFollowPattern(array $params = []) + public function deleteAutoFollowPattern(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_ccr/auto_follow/' . $this->encode($params['name']); $method = 'DELETE'; @@ -69,18 +70,18 @@ public function deleteAutoFollowPattern(array $params = []) /** * Creates a new follower index configured to follow the referenced leader index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html * * @param array{ * index: string, // (REQUIRED) The name of the follower index - * wait_for_active_shards: string, // Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The name of the leader index and other optional ccr related parameters + * wait_for_active_shards?: string, // Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The name of the leader index and other optional ccr related parameters. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -90,8 +91,9 @@ public function deleteAutoFollowPattern(array $params = []) * * @return Elasticsearch|Promise */ - public function follow(array $params = []) + public function follow(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','body'], $params); $url = '/' . $this->encode($params['index']) . '/_ccr/follow'; $method = 'PUT'; @@ -110,16 +112,16 @@ public function follow(array $params = []) /** * Retrieves information about all follower indices, including parameters and status for each follower index * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index patterns; use `_all` to perform the operation on all indices - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index: string|array, // (REQUIRED) A comma-separated list of index patterns; use `_all` to perform the operation on all indices + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -129,10 +131,11 @@ public function follow(array $params = []) * * @return Elasticsearch|Promise */ - public function followInfo(array $params = []) + public function followInfo(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']) . '/_ccr/info'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_ccr/info'; $method = 'GET'; $url = $this->addQueryString($url, $params, ['master_timeout','pretty','human','error_trace','source','filter_path']); @@ -148,16 +151,16 @@ public function followInfo(array $params = []) /** * Retrieves follower stats. return shard-level stats about the following tasks associated with each shard for the specified indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index patterns; use `_all` to perform the operation on all indices - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index: string|array, // (REQUIRED) A comma-separated list of index patterns; use `_all` to perform the operation on all indices + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -167,10 +170,11 @@ public function followInfo(array $params = []) * * @return Elasticsearch|Promise */ - public function followStats(array $params = []) + public function followStats(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']) . '/_ccr/stats'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_ccr/stats'; $method = 'GET'; $url = $this->addQueryString($url, $params, ['timeout','pretty','human','error_trace','source','filter_path']); @@ -186,17 +190,17 @@ public function followStats(array $params = []) /** * Removes the follower retention leases from the leader. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-forget-follower.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-forget-follower.html * * @param array{ * index: string, // (REQUIRED) the name of the leader index for which specified follower retention leases should be removed - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -206,8 +210,9 @@ public function followStats(array $params = []) * * @return Elasticsearch|Promise */ - public function forgetFollower(array $params = []) + public function forgetFollower(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','body'], $params); $url = '/' . $this->encode($params['index']) . '/_ccr/forget_follower'; $method = 'POST'; @@ -226,16 +231,16 @@ public function forgetFollower(array $params = []) /** * Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html * * @param array{ - * name: string, // The name of the auto follow pattern. - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string, // The name of the auto follow pattern. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -244,8 +249,9 @@ public function forgetFollower(array $params = []) * * @return Elasticsearch|Promise */ - public function getAutoFollowPattern(array $params = []) + public function getAutoFollowPattern(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { $url = '/_ccr/auto_follow/' . $this->encode($params['name']); $method = 'GET'; @@ -266,16 +272,16 @@ public function getAutoFollowPattern(array $params = []) /** * Pauses an auto-follow pattern * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-auto-follow-pattern.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-auto-follow-pattern.html * * @param array{ * name: string, // (REQUIRED) The name of the auto follow pattern that should pause discovering new indices to follow. - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -285,8 +291,9 @@ public function getAutoFollowPattern(array $params = []) * * @return Elasticsearch|Promise */ - public function pauseAutoFollowPattern(array $params = []) + public function pauseAutoFollowPattern(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_ccr/auto_follow/' . $this->encode($params['name']) . '/pause'; $method = 'POST'; @@ -304,16 +311,16 @@ public function pauseAutoFollowPattern(array $params = []) /** * Pauses a follower index. The follower index will not fetch any additional operations from the leader index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html * * @param array{ * index: string, // (REQUIRED) The name of the follower index that should pause following its leader index. - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -323,8 +330,9 @@ public function pauseAutoFollowPattern(array $params = []) * * @return Elasticsearch|Promise */ - public function pauseFollow(array $params = []) + public function pauseFollow(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_ccr/pause_follow'; $method = 'POST'; @@ -342,17 +350,17 @@ public function pauseFollow(array $params = []) /** * 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 https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html * * @param array{ * name: string, // (REQUIRED) The name of the auto follow pattern. - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The specification of the auto follow pattern + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The specification of the auto follow pattern. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -362,8 +370,9 @@ public function pauseFollow(array $params = []) * * @return Elasticsearch|Promise */ - public function putAutoFollowPattern(array $params = []) + public function putAutoFollowPattern(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name','body'], $params); $url = '/_ccr/auto_follow/' . $this->encode($params['name']); $method = 'PUT'; @@ -382,16 +391,16 @@ public function putAutoFollowPattern(array $params = []) /** * Resumes an auto-follow pattern that has been paused * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-auto-follow-pattern.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-auto-follow-pattern.html * * @param array{ * name: string, // (REQUIRED) The name of the auto follow pattern to resume discovering new indices to follow. - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -401,8 +410,9 @@ public function putAutoFollowPattern(array $params = []) * * @return Elasticsearch|Promise */ - public function resumeAutoFollowPattern(array $params = []) + public function resumeAutoFollowPattern(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_ccr/auto_follow/' . $this->encode($params['name']) . '/resume'; $method = 'POST'; @@ -420,17 +430,17 @@ public function resumeAutoFollowPattern(array $params = []) /** * Resumes a follower index that has been paused * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html * * @param array{ * index: string, // (REQUIRED) The name of the follow index to resume following. - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The name of the leader index and other optional ccr related parameters + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The name of the leader index and other optional ccr related parameters. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -440,8 +450,9 @@ public function resumeAutoFollowPattern(array $params = []) * * @return Elasticsearch|Promise */ - public function resumeFollow(array $params = []) + public function resumeFollow(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_ccr/resume_follow'; $method = 'POST'; @@ -460,16 +471,16 @@ public function resumeFollow(array $params = []) /** * Gets all stats related to cross-cluster replication. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html * * @param array{ - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -478,8 +489,9 @@ public function resumeFollow(array $params = []) * * @return Elasticsearch|Promise */ - public function stats(array $params = []) + public function stats(?array $params = null) { + $params = $params ?? []; $url = '/_ccr/stats'; $method = 'GET'; @@ -496,16 +508,16 @@ public function stats(array $params = []) /** * Stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-unfollow.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-unfollow.html * * @param array{ * index: string, // (REQUIRED) The name of the follower index that should be turned into a regular index. - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -515,8 +527,9 @@ public function stats(array $params = []) * * @return Elasticsearch|Promise */ - public function unfollow(array $params = []) + public function unfollow(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_ccr/unfollow'; $method = 'POST'; diff --git a/src/Endpoints/Cluster.php b/src/Endpoints/Cluster.php index 203fcaf5b..4ddc638db 100644 --- a/src/Endpoints/Cluster.php +++ b/src/Endpoints/Cluster.php @@ -31,18 +31,18 @@ class Cluster extends AbstractEndpoint /** * Provides explanations for shard allocations in the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html * * @param array{ - * master_timeout: time, // Timeout for connection to master node - * include_yes_decisions: boolean, // Return 'YES' decisions in explanation (default: false) - * include_disk_info: boolean, // Return information about disk usage and shard sizes (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The index, shard, and primary flag to explain. Empty means 'explain a randomly-chosen unassigned shard' + * master_timeout?: int|string, // Timeout for connection to master node + * include_yes_decisions?: bool, // Return 'YES' decisions in explanation (default: false) + * include_disk_info?: bool, // Return information about disk usage and shard sizes (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The index, shard, and primary flag to explain. Empty means 'explain a randomly-chosen unassigned shard'. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -51,8 +51,9 @@ class Cluster extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function allocationExplain(array $params = []) + public function allocationExplain(?array $params = null) { + $params = $params ?? []; $url = '/_cluster/allocation/explain'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -70,17 +71,18 @@ public function allocationExplain(array $params = []) /** * Deletes a component template * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the template - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -90,8 +92,9 @@ public function allocationExplain(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteComponentTemplate(array $params = []) + public function deleteComponentTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_component_template/' . $this->encode($params['name']); $method = 'DELETE'; @@ -109,16 +112,16 @@ public function deleteComponentTemplate(array $params = []) /** * Clears cluster voting config exclusions. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html * * @param array{ - * wait_for_removal: boolean, // Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list. - * master_timeout: time, // Timeout for submitting request to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * wait_for_removal?: bool, // Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list. + * master_timeout?: int|string, // Timeout for submitting request to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -127,8 +130,9 @@ public function deleteComponentTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteVotingConfigExclusions(array $params = []) + public function deleteVotingConfigExclusions(?array $params = null) { + $params = $params ?? []; $url = '/_cluster/voting_config_exclusions'; $method = 'DELETE'; @@ -145,17 +149,18 @@ public function deleteVotingConfigExclusions(array $params = []) /** * Returns information about whether a particular component template exist * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the template - * master_timeout: time, // Explicit operation timeout for connection to master node - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Timeout for waiting for new cluster state in case it is blocked + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -165,8 +170,9 @@ public function deleteVotingConfigExclusions(array $params = []) * * @return Elasticsearch|Promise */ - public function existsComponentTemplate(array $params = []) + public function existsComponentTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_component_template/' . $this->encode($params['name']); $method = 'HEAD'; @@ -184,18 +190,19 @@ public function existsComponentTemplate(array $params = []) /** * Returns one or more component templates * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html + * @group serverless * * @param array{ - * name: list, // The comma separated names of the component templates - * master_timeout: time, // Explicit operation timeout for connection to master node - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * include_defaults: boolean, // Return all default configurations for the component template (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // The comma separated names of the component templates + * master_timeout?: int|string, // Timeout for waiting for new cluster state in case it is blocked + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * include_defaults?: bool, // Return all default configurations for the component template (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -204,10 +211,11 @@ public function existsComponentTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function getComponentTemplate(array $params = []) + public function getComponentTemplate(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { - $url = '/_component_template/' . $this->encode($params['name']); + $url = '/_component_template/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } else { $url = '/_component_template'; @@ -226,18 +234,18 @@ public function getComponentTemplate(array $params = []) /** * Returns cluster settings. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-get-settings.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-get-settings.html * * @param array{ - * flat_settings: boolean, // Return settings in flat format (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * include_defaults: boolean, // Whether to return all default clusters setting. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * flat_settings?: bool, // Return settings in flat format (default: false) + * master_timeout?: int|string, // Timeout for waiting for new cluster state in case it is blocked + * timeout?: int|string, // Explicit operation timeout + * include_defaults?: bool, // Whether to return all default clusters setting. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -246,8 +254,9 @@ public function getComponentTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function getSettings(array $params = []) + public function getSettings(?array $params = null) { + $params = $params ?? []; $url = '/_cluster/settings'; $method = 'GET'; @@ -264,26 +273,26 @@ public function getSettings(array $params = []) /** * Returns basic information about the health of the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html * * @param array{ - * index: list, // Limit the information returned to a specific index - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * level: enum, // Specify the level of detail for returned information - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * wait_for_active_shards: string, // Wait until the specified number of shards is active - * wait_for_nodes: string, // Wait until the specified number of nodes is available - * wait_for_events: enum, // Wait until all currently queued events with the given priority are processed - * wait_for_no_relocating_shards: boolean, // Whether to wait until there are no relocating shards in the cluster - * wait_for_no_initializing_shards: boolean, // Whether to wait until there are no initializing shards in the cluster - * wait_for_status: enum, // Wait until cluster is in a specific state - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // Limit the information returned to a specific index + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * level?: string, // Specify the level of detail for returned information + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * wait_for_active_shards?: string, // Wait until the specified number of shards is active + * wait_for_nodes?: string, // Wait until the specified number of nodes is available + * wait_for_events?: string, // Wait until all currently queued events with the given priority are processed + * wait_for_no_relocating_shards?: bool, // Whether to wait until there are no relocating shards in the cluster + * wait_for_no_initializing_shards?: bool, // Whether to wait until there are no initializing shards in the cluster + * wait_for_status?: string, // Wait until cluster is in a specific state + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -292,10 +301,11 @@ public function getSettings(array $params = []) * * @return Elasticsearch|Promise */ - public function health(array $params = []) + public function health(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/_cluster/health/' . $this->encode($params['index']); + $url = '/_cluster/health/' . $this->encode($this->convertValue($params['index'])); $method = 'GET'; } else { $url = '/_cluster/health'; @@ -314,15 +324,16 @@ public function health(array $params = []) /** * Returns different information about the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-info.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-info.html + * @group serverless * * @param array{ - * target: list, // (REQUIRED) Limit the information returned to the specified target. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * target: string|array, // (REQUIRED) Limit the information returned to the specified target. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -332,10 +343,11 @@ public function health(array $params = []) * * @return Elasticsearch|Promise */ - public function info(array $params = []) + public function info(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['target'], $params); - $url = '/_info/' . $this->encode($params['target']); + $url = '/_info/' . $this->encode($this->convertValue($params['target'])); $method = 'GET'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); @@ -352,16 +364,16 @@ public function info(array $params = []) * Returns a list of any cluster-level changes (e.g. create index, update mapping, * allocate or fail shard) which have not yet been executed. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html * * @param array{ - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -370,8 +382,9 @@ public function info(array $params = []) * * @return Elasticsearch|Promise */ - public function pendingTasks(array $params = []) + public function pendingTasks(?array $params = null) { + $params = $params ?? []; $url = '/_cluster/pending_tasks'; $method = 'GET'; @@ -388,18 +401,18 @@ public function pendingTasks(array $params = []) /** * Updates the cluster voting config exclusions by node ids or node names. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html * * @param array{ - * node_ids: string, // A comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_names. - * node_names: string, // A comma-separated list of the names of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_ids. - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Timeout for submitting request to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_ids?: string, // A comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_names. + * node_names?: string, // A comma-separated list of the names of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_ids. + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Timeout for submitting request to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -408,8 +421,9 @@ public function pendingTasks(array $params = []) * * @return Elasticsearch|Promise */ - public function postVotingConfigExclusions(array $params = []) + public function postVotingConfigExclusions(?array $params = null) { + $params = $params ?? []; $url = '/_cluster/voting_config_exclusions'; $method = 'POST'; @@ -426,19 +440,20 @@ public function postVotingConfigExclusions(array $params = []) /** * Creates or updates a component template * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the template - * create: boolean, // Whether the index template should only be added if new or can also replace an existing one - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The template definition + * create?: bool, // Whether the index template should only be added if new or can also replace an existing one + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The template definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -448,8 +463,9 @@ public function postVotingConfigExclusions(array $params = []) * * @return Elasticsearch|Promise */ - public function putComponentTemplate(array $params = []) + public function putComponentTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name','body'], $params); $url = '/_component_template/' . $this->encode($params['name']); $method = 'PUT'; @@ -468,18 +484,18 @@ public function putComponentTemplate(array $params = []) /** * Updates the cluster settings. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html * * @param array{ - * flat_settings: boolean, // Return settings in flat format (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). + * flat_settings?: bool, // Return settings in flat format (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart).. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -488,8 +504,9 @@ public function putComponentTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function putSettings(array $params = []) + public function putSettings(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_cluster/settings'; $method = 'PUT'; @@ -508,14 +525,14 @@ public function putSettings(array $params = []) /** * Returns the information about configured remote clusters. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -524,8 +541,9 @@ public function putSettings(array $params = []) * * @return Elasticsearch|Promise */ - public function remoteInfo(array $params = []) + public function remoteInfo(?array $params = null) { + $params = $params ?? []; $url = '/_remote/info'; $method = 'GET'; @@ -542,21 +560,21 @@ public function remoteInfo(array $params = []) /** * Allows to manually change the allocation of individual shards in the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html * * @param array{ - * dry_run: boolean, // Simulate the operation only and return the resulting state - * explain: boolean, // Return an explanation of why the commands can or cannot be executed - * retry_failed: boolean, // Retries allocation of shards that are blocked due to too many subsequent allocation failures - * metric: list, // Limit the information returned to the specified metrics. Defaults to all but metadata - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The definition of `commands` to perform (`move`, `cancel`, `allocate`) + * dry_run?: bool, // Simulate the operation only and return the resulting state + * explain?: bool, // Return an explanation of why the commands can or cannot be executed + * retry_failed?: bool, // Retries allocation of shards that are blocked due to too many subsequent allocation failures + * metric?: string|array, // Limit the information returned to the specified metrics. Defaults to all but metadata + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The definition of `commands` to perform (`move`, `cancel`, `allocate`). If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -565,8 +583,9 @@ public function remoteInfo(array $params = []) * * @return Elasticsearch|Promise */ - public function reroute(array $params = []) + public function reroute(?array $params = null) { + $params = $params ?? []; $url = '/_cluster/reroute'; $method = 'POST'; @@ -584,24 +603,24 @@ public function reroute(array $params = []) /** * Returns a comprehensive information about the state of the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html * * @param array{ - * metric: list, // Limit the information returned to the specified metrics - * index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * master_timeout: time, // Specify timeout for connection to master - * flat_settings: boolean, // Return settings in flat format (default: false) - * wait_for_metadata_version: number, // Wait for the metadata version to be equal or greater than the specified metadata version - * wait_for_timeout: time, // The maximum time to wait for wait_for_metadata_version before timing out - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * metric?: string|array, // Limit the information returned to the specified metrics + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * master_timeout?: int|string, // Specify timeout for connection to master + * flat_settings?: bool, // Return settings in flat format (default: false) + * wait_for_metadata_version?: int, // Wait for the metadata version to be equal or greater than the specified metadata version + * wait_for_timeout?: int|string, // The maximum time to wait for wait_for_metadata_version before timing out + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -610,13 +629,14 @@ public function reroute(array $params = []) * * @return Elasticsearch|Promise */ - public function state(array $params = []) + public function state(?array $params = null) { + $params = $params ?? []; if (isset($params['index']) && isset($params['metric'])) { - $url = '/_cluster/state/' . $this->encode($params['metric']) . '/' . $this->encode($params['index']); + $url = '/_cluster/state/' . $this->encode($this->convertValue($params['metric'])) . '/' . $this->encode($this->convertValue($params['index'])); $method = 'GET'; } elseif (isset($params['metric'])) { - $url = '/_cluster/state/' . $this->encode($params['metric']); + $url = '/_cluster/state/' . $this->encode($this->convertValue($params['metric'])); $method = 'GET'; } else { $url = '/_cluster/state'; @@ -635,17 +655,17 @@ public function state(array $params = []) /** * Returns high-level overview of cluster statistics. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html * * @param array{ - * node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - * flat_settings: boolean, // Return settings in flat format (default: false) - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id?: string|array, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * include_remotes?: bool, // Include remote cluster data into the response (default: false) + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -654,16 +674,17 @@ public function state(array $params = []) * * @return Elasticsearch|Promise */ - public function stats(array $params = []) + public function stats(?array $params = null) { + $params = $params ?? []; if (isset($params['node_id'])) { - $url = '/_cluster/stats/nodes/' . $this->encode($params['node_id']); + $url = '/_cluster/stats/nodes/' . $this->encode($this->convertValue($params['node_id'])); $method = 'GET'; } else { $url = '/_cluster/stats'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['flat_settings','timeout','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['include_remotes','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; diff --git a/src/Endpoints/Connector.php b/src/Endpoints/Connector.php index 98ab0ec59..be7c9c10f 100644 --- a/src/Endpoints/Connector.php +++ b/src/Endpoints/Connector.php @@ -31,16 +31,17 @@ class Connector extends AbstractEndpoint /** * Updates the last_seen timestamp in the connector document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/check-in-connector-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/check-in-connector-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -50,8 +51,9 @@ class Connector extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function checkIn(array $params = []) + public function checkIn(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_check_in'; $method = 'PUT'; @@ -69,17 +71,19 @@ public function checkIn(array $params = []) /** * Deletes a connector. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-connector-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-connector-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be deleted. - * delete_sync_jobs: boolean, // Determines whether associated sync jobs are also deleted. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * hard?: bool, // If true, the connector doc is deleted. If false, connector doc is marked as deleted (soft-deleted). + * delete_sync_jobs?: bool, // Determines whether associated sync jobs are also deleted. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -89,13 +93,14 @@ public function checkIn(array $params = []) * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function delete(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id'], $params); $url = '/_connector/' . $this->encode($params['connector_id']); $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['delete_sync_jobs','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['hard','delete_sync_jobs','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -108,16 +113,18 @@ public function delete(array $params = []) /** * Returns the details about a connector. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-connector-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-connector-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be returned. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * include_deleted?: bool, // A flag indicating whether to return connectors that have been soft-deleted. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -127,13 +134,14 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function get(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id'], $params); $url = '/_connector/' . $this->encode($params['connector_id']); $method = 'GET'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['include_deleted','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -146,17 +154,17 @@ public function get(array $params = []) /** * Updates the stats of last sync in the connector document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-last-sync-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-last-sync-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Object with stats related to the last connector sync run. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Object with stats related to the last connector sync run.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -166,8 +174,9 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function lastSync(array $params = []) + public function lastSync(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_last_sync'; $method = 'PUT'; @@ -186,21 +195,23 @@ public function lastSync(array $params = []) /** * Lists all connectors. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-connector-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/list-connector-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * from: int, // Starting offset (default: 0) - * size: int, // Specifies a max number of results to get (default: 100) - * index_name: list, // A comma-separated list of connector index names to fetch connector documents for - * connector_name: list, // A comma-separated list of connector names to fetch connector documents for - * service_type: list, // A comma-separated list of connector service types to fetch connector documents for - * query: string, // A search string for querying connectors, filtering results by matching against connector names, descriptions, and index names - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * from?: int, // Starting offset (default: 0) + * size?: int, // Specifies a max number of results to get (default: 100) + * index_name?: string|array, // A comma-separated list of connector index names to fetch connector documents for + * connector_name?: string|array, // A comma-separated list of connector names to fetch connector documents for + * service_type?: string|array, // A comma-separated list of connector service types to fetch connector documents for + * query?: string, // A search string for querying connectors, filtering results by matching against connector names, descriptions, and index names + * include_deleted?: bool, // A flag indicating whether to return connectors that have been soft-deleted. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -209,12 +220,13 @@ public function lastSync(array $params = []) * * @return Elasticsearch|Promise */ - public function list(array $params = []) + public function list(?array $params = null) { + $params = $params ?? []; $url = '/_connector'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['from','size','index_name','connector_name','service_type','query','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['from','size','index_name','connector_name','service_type','query','include_deleted','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -227,16 +239,17 @@ public function list(array $params = []) /** * Creates a connector. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/create-connector-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/create-connector-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The connector configuration. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The connector configuration.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -245,8 +258,9 @@ public function list(array $params = []) * * @return Elasticsearch|Promise */ - public function post(array $params = []) + public function post(?array $params = null) { + $params = $params ?? []; $url = '/_connector'; $method = 'POST'; @@ -264,17 +278,18 @@ public function post(array $params = []) /** * Creates or updates a connector. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/create-connector-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/create-connector-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * connector_id: string, // The unique identifier of the connector to be created or updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The connector configuration. + * connector_id?: string, // The unique identifier of the connector to be created or updated. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The connector configuration.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -283,8 +298,9 @@ public function post(array $params = []) * * @return Elasticsearch|Promise */ - public function put(array $params = []) + public function put(?array $params = null) { + $params = $params ?? []; if (isset($params['connector_id'])) { $url = '/_connector/' . $this->encode($params['connector_id']); $method = 'PUT'; @@ -306,16 +322,17 @@ public function put(array $params = []) /** * Cancels a connector sync job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cancel-connector-sync-job-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cancel-connector-sync-job-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_sync_job_id: string, // (REQUIRED) The unique identifier of the connector sync job to be canceled - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -325,8 +342,9 @@ public function put(array $params = []) * * @return Elasticsearch|Promise */ - public function syncJobCancel(array $params = []) + public function syncJobCancel(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_sync_job_id'], $params); $url = '/_connector/_sync_job/' . $this->encode($params['connector_sync_job_id']) . '/_cancel'; $method = 'PUT'; @@ -344,16 +362,16 @@ public function syncJobCancel(array $params = []) /** * Checks in a connector sync job (refreshes 'last_seen'). * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/check-in-connector-sync-job-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/check-in-connector-sync-job-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_sync_job_id: string, // (REQUIRED) The unique identifier of the connector sync job to be checked in - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -363,8 +381,9 @@ public function syncJobCancel(array $params = []) * * @return Elasticsearch|Promise */ - public function syncJobCheckIn(array $params = []) + public function syncJobCheckIn(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_sync_job_id'], $params); $url = '/_connector/_sync_job/' . $this->encode($params['connector_sync_job_id']) . '/_check_in'; $method = 'PUT'; @@ -382,17 +401,17 @@ public function syncJobCheckIn(array $params = []) /** * Claims a connector sync job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/claim-connector-sync-job-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/claim-connector-sync-job-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_sync_job_id: string, // (REQUIRED) The unique identifier of the connector sync job to be claimed. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Data to claim a sync job. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Data to claim a sync job.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -402,8 +421,9 @@ public function syncJobCheckIn(array $params = []) * * @return Elasticsearch|Promise */ - public function syncJobClaim(array $params = []) + public function syncJobClaim(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_sync_job_id','body'], $params); $url = '/_connector/_sync_job/' . $this->encode($params['connector_sync_job_id']) . '/_claim'; $method = 'PUT'; @@ -422,16 +442,17 @@ public function syncJobClaim(array $params = []) /** * Deletes a connector sync job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-connector-sync-job-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-connector-sync-job-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_sync_job_id: string, // (REQUIRED) The unique identifier of the connector sync job to be deleted. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -441,8 +462,9 @@ public function syncJobClaim(array $params = []) * * @return Elasticsearch|Promise */ - public function syncJobDelete(array $params = []) + public function syncJobDelete(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_sync_job_id'], $params); $url = '/_connector/_sync_job/' . $this->encode($params['connector_sync_job_id']); $method = 'DELETE'; @@ -460,17 +482,17 @@ public function syncJobDelete(array $params = []) /** * Sets an error for a connector sync job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/set-connector-sync-job-error-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/set-connector-sync-job-error-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_sync_job_id: string, // (REQUIRED) The unique identifier of the connector sync job to set an error for. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The error to set in the connector sync job. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The error to set in the connector sync job.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -480,8 +502,9 @@ public function syncJobDelete(array $params = []) * * @return Elasticsearch|Promise */ - public function syncJobError(array $params = []) + public function syncJobError(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_sync_job_id','body'], $params); $url = '/_connector/_sync_job/' . $this->encode($params['connector_sync_job_id']) . '/_error'; $method = 'PUT'; @@ -500,16 +523,17 @@ public function syncJobError(array $params = []) /** * Returns the details about a connector sync job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-connector-sync-job-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-connector-sync-job-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_sync_job_id: string, // (REQUIRED) The unique identifier of the connector sync job to be returned. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -519,8 +543,9 @@ public function syncJobError(array $params = []) * * @return Elasticsearch|Promise */ - public function syncJobGet(array $params = []) + public function syncJobGet(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_sync_job_id'], $params); $url = '/_connector/_sync_job/' . $this->encode($params['connector_sync_job_id']); $method = 'GET'; @@ -538,20 +563,21 @@ public function syncJobGet(array $params = []) /** * Lists all connector sync jobs. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-connector-sync-jobs-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/list-connector-sync-jobs-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * from: int, // Starting offset (default: 0) - * size: int, // specifies a max number of results to get (default: 100) - * status: string, // Sync job status, which sync jobs are fetched for - * connector_id: string, // Id of the connector to fetch the sync jobs for - * job_type: list, // A comma-separated list of job types - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * from?: int, // Starting offset (default: 0) + * size?: int, // specifies a max number of results to get (default: 100) + * status?: string, // Sync job status, which sync jobs are fetched for + * connector_id?: string, // Id of the connector to fetch the sync jobs for + * job_type?: string|array, // A comma-separated list of job types + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -560,8 +586,9 @@ public function syncJobGet(array $params = []) * * @return Elasticsearch|Promise */ - public function syncJobList(array $params = []) + public function syncJobList(?array $params = null) { + $params = $params ?? []; $url = '/_connector/_sync_job'; $method = 'GET'; @@ -578,16 +605,17 @@ public function syncJobList(array $params = []) /** * Creates a connector sync job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/create-connector-sync-job-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/create-connector-sync-job-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The connector sync job data. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The connector sync job data.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -596,8 +624,9 @@ public function syncJobList(array $params = []) * * @return Elasticsearch|Promise */ - public function syncJobPost(array $params = []) + public function syncJobPost(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_connector/_sync_job'; $method = 'POST'; @@ -616,17 +645,17 @@ public function syncJobPost(array $params = []) /** * Updates the stats fields in the connector sync job document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/set-connector-sync-job-stats-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/set-connector-sync-job-stats-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_sync_job_id: string, // (REQUIRED) The unique identifier of the connector sync job to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The stats to update for the connector sync job. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The stats to update for the connector sync job.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -636,8 +665,9 @@ public function syncJobPost(array $params = []) * * @return Elasticsearch|Promise */ - public function syncJobUpdateStats(array $params = []) + public function syncJobUpdateStats(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_sync_job_id','body'], $params); $url = '/_connector/_sync_job/' . $this->encode($params['connector_sync_job_id']) . '/_stats'; $method = 'PUT'; @@ -656,16 +686,17 @@ public function syncJobUpdateStats(array $params = []) /** * Activates the draft filtering rules if they are in a validated state. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-filtering-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-filtering-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -675,8 +706,9 @@ public function syncJobUpdateStats(array $params = []) * * @return Elasticsearch|Promise */ - public function updateActiveFiltering(array $params = []) + public function updateActiveFiltering(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_filtering/_activate'; $method = 'PUT'; @@ -695,17 +727,18 @@ public function updateActiveFiltering(array $params = []) /** * Updates the API key id and/or API key secret id fields in the connector document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-api-key-id-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-api-key-id-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object containing the connector's API key id and/or Connector Secret document id for that API key. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object containing the connector's API key id and/or Connector Secret document id for that API key.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -715,8 +748,9 @@ public function updateActiveFiltering(array $params = []) * * @return Elasticsearch|Promise */ - public function updateApiKeyId(array $params = []) + public function updateApiKeyId(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_api_key_id'; $method = 'PUT'; @@ -735,17 +769,18 @@ public function updateApiKeyId(array $params = []) /** * Updates the connector configuration. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-configuration-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-configuration-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Mapping between field names to configuration. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Mapping between field names to configuration.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -755,8 +790,9 @@ public function updateApiKeyId(array $params = []) * * @return Elasticsearch|Promise */ - public function updateConfiguration(array $params = []) + public function updateConfiguration(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_configuration'; $method = 'PUT'; @@ -775,17 +811,18 @@ public function updateConfiguration(array $params = []) /** * Updates the error field in the connector document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-error-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-error-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object containing the connector's error. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object containing the connector's error.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -795,8 +832,9 @@ public function updateConfiguration(array $params = []) * * @return Elasticsearch|Promise */ - public function updateError(array $params = []) + public function updateError(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_error'; $method = 'PUT'; @@ -815,17 +853,17 @@ public function updateError(array $params = []) /** * Updates the connector features in the connector document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-features-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-features-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object containing the connector's features definition. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object containing the connector's features definition.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -835,8 +873,9 @@ public function updateError(array $params = []) * * @return Elasticsearch|Promise */ - public function updateFeatures(array $params = []) + public function updateFeatures(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_features'; $method = 'PUT'; @@ -855,17 +894,18 @@ public function updateFeatures(array $params = []) /** * Updates the filtering field in the connector document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-filtering-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-filtering-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) A list of connector filtering configurations. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) A list of connector filtering configurations.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -875,8 +915,9 @@ public function updateFeatures(array $params = []) * * @return Elasticsearch|Promise */ - public function updateFiltering(array $params = []) + public function updateFiltering(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_filtering'; $method = 'PUT'; @@ -895,17 +936,18 @@ public function updateFiltering(array $params = []) /** * Updates the validation info of the draft filtering rules. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-filtering-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-filtering-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Validation info for the draft filtering rules + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Validation info for the draft filtering rules. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -915,8 +957,9 @@ public function updateFiltering(array $params = []) * * @return Elasticsearch|Promise */ - public function updateFilteringValidation(array $params = []) + public function updateFilteringValidation(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_filtering/_validation'; $method = 'PUT'; @@ -935,17 +978,18 @@ public function updateFilteringValidation(array $params = []) /** * Updates the index name of the connector. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-index-name-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-index-name-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object containing the connector's index name. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object containing the connector's index name.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -955,8 +999,9 @@ public function updateFilteringValidation(array $params = []) * * @return Elasticsearch|Promise */ - public function updateIndexName(array $params = []) + public function updateIndexName(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_index_name'; $method = 'PUT'; @@ -975,17 +1020,18 @@ public function updateIndexName(array $params = []) /** * Updates the name and/or description fields in the connector document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-name-description-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-name-description-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object containing the connector's name and/or description. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object containing the connector's name and/or description.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -995,8 +1041,9 @@ public function updateIndexName(array $params = []) * * @return Elasticsearch|Promise */ - public function updateName(array $params = []) + public function updateName(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_name'; $method = 'PUT'; @@ -1015,17 +1062,18 @@ public function updateName(array $params = []) /** * Updates the is_native flag of the connector. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/connector-apis.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/connector-apis.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object containing the connector's is_native flag + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object containing the connector's is_native flag. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1035,8 +1083,9 @@ public function updateName(array $params = []) * * @return Elasticsearch|Promise */ - public function updateNative(array $params = []) + public function updateNative(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_native'; $method = 'PUT'; @@ -1055,17 +1104,18 @@ public function updateNative(array $params = []) /** * Updates the pipeline field in the connector document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-pipeline-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-pipeline-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object with connector ingest pipeline configuration. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object with connector ingest pipeline configuration.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1075,8 +1125,9 @@ public function updateNative(array $params = []) * * @return Elasticsearch|Promise */ - public function updatePipeline(array $params = []) + public function updatePipeline(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_pipeline'; $method = 'PUT'; @@ -1095,17 +1146,18 @@ public function updatePipeline(array $params = []) /** * Updates the scheduling field in the connector document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-scheduling-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-scheduling-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object containing the connector's scheduling configuration. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object containing the connector's scheduling configuration.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1115,8 +1167,9 @@ public function updatePipeline(array $params = []) * * @return Elasticsearch|Promise */ - public function updateScheduling(array $params = []) + public function updateScheduling(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_scheduling'; $method = 'PUT'; @@ -1135,17 +1188,18 @@ public function updateScheduling(array $params = []) /** * Updates the service type of the connector. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-service-type-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-service-type-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object containing the connector's service type. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object containing the connector's service type.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1155,8 +1209,9 @@ public function updateScheduling(array $params = []) * * @return Elasticsearch|Promise */ - public function updateServiceType(array $params = []) + public function updateServiceType(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_service_type'; $method = 'PUT'; @@ -1175,17 +1230,18 @@ public function updateServiceType(array $params = []) /** * Updates the status of the connector. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-status-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-status-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * connector_id: string, // (REQUIRED) The unique identifier of the connector to be updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object containing the connector's status. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object containing the connector's status.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1195,8 +1251,9 @@ public function updateServiceType(array $params = []) * * @return Elasticsearch|Promise */ - public function updateStatus(array $params = []) + public function updateStatus(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['connector_id','body'], $params); $url = '/_connector/' . $this->encode($params['connector_id']) . '/_status'; $method = 'PUT'; diff --git a/src/Endpoints/DanglingIndices.php b/src/Endpoints/DanglingIndices.php index b75c77635..e5e87e720 100644 --- a/src/Endpoints/DanglingIndices.php +++ b/src/Endpoints/DanglingIndices.php @@ -31,18 +31,18 @@ class DanglingIndices extends AbstractEndpoint /** * Deletes the specified dangling index * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html * * @param array{ * index_uuid: string, // (REQUIRED) The UUID of the dangling index - * accept_data_loss: boolean, // Must be set to true in order to delete the dangling index - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * accept_data_loss?: bool, // Must be set to true in order to delete the dangling index + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -52,8 +52,9 @@ class DanglingIndices extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteDanglingIndex(array $params = []) + public function deleteDanglingIndex(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index_uuid'], $params); $url = '/_dangling/' . $this->encode($params['index_uuid']); $method = 'DELETE'; @@ -71,18 +72,18 @@ public function deleteDanglingIndex(array $params = []) /** * Imports the specified dangling index * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html * * @param array{ * index_uuid: string, // (REQUIRED) The UUID of the dangling index - * accept_data_loss: boolean, // Must be set to true in order to import the dangling index - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * accept_data_loss?: bool, // Must be set to true in order to import the dangling index + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -92,8 +93,9 @@ public function deleteDanglingIndex(array $params = []) * * @return Elasticsearch|Promise */ - public function importDanglingIndex(array $params = []) + public function importDanglingIndex(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index_uuid'], $params); $url = '/_dangling/' . $this->encode($params['index_uuid']); $method = 'POST'; @@ -111,14 +113,14 @@ public function importDanglingIndex(array $params = []) /** * Returns all dangling indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -127,8 +129,9 @@ public function importDanglingIndex(array $params = []) * * @return Elasticsearch|Promise */ - public function listDanglingIndices(array $params = []) + public function listDanglingIndices(?array $params = null) { + $params = $params ?? []; $url = '/_dangling'; $method = 'GET'; diff --git a/src/Endpoints/Enrich.php b/src/Endpoints/Enrich.php index b2f893962..dc68b159e 100644 --- a/src/Endpoints/Enrich.php +++ b/src/Endpoints/Enrich.php @@ -31,16 +31,17 @@ class Enrich extends AbstractEndpoint /** * Deletes an existing enrich policy and its enrich index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-enrich-policy-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-enrich-policy-api.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the enrich policy - * master_timeout: time, // Timeout for processing on master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Timeout for processing on master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -50,8 +51,9 @@ class Enrich extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deletePolicy(array $params = []) + public function deletePolicy(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_enrich/policy/' . $this->encode($params['name']); $method = 'DELETE'; @@ -69,17 +71,18 @@ public function deletePolicy(array $params = []) /** * Creates the enrich index for an existing enrich policy. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/execute-enrich-policy-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/execute-enrich-policy-api.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the enrich policy - * wait_for_completion: boolean, // Should the request should block until the execution is complete. - * master_timeout: time, // Timeout for processing on master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * wait_for_completion?: bool, // Should the request should block until the execution is complete. + * master_timeout?: int|string, // Timeout for processing on master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -89,8 +92,9 @@ public function deletePolicy(array $params = []) * * @return Elasticsearch|Promise */ - public function executePolicy(array $params = []) + public function executePolicy(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_enrich/policy/' . $this->encode($params['name']) . '/_execute'; $method = 'PUT'; @@ -108,16 +112,17 @@ public function executePolicy(array $params = []) /** * Gets information about an enrich policy. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-enrich-policy-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-enrich-policy-api.html + * @group serverless * * @param array{ - * name: list, // A comma-separated list of enrich policy names - * master_timeout: time, // Timeout for processing on master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // A comma-separated list of enrich policy names + * master_timeout?: int|string, // Timeout for waiting for new cluster state in case it is blocked + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -126,10 +131,11 @@ public function executePolicy(array $params = []) * * @return Elasticsearch|Promise */ - public function getPolicy(array $params = []) + public function getPolicy(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { - $url = '/_enrich/policy/' . $this->encode($params['name']); + $url = '/_enrich/policy/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } else { $url = '/_enrich/policy'; @@ -148,17 +154,18 @@ public function getPolicy(array $params = []) /** * Creates a new enrich policy. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-enrich-policy-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/put-enrich-policy-api.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the enrich policy - * master_timeout: time, // Timeout for processing on master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The enrich policy to register + * master_timeout?: int|string, // Timeout for processing on master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The enrich policy to register. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -168,8 +175,9 @@ public function getPolicy(array $params = []) * * @return Elasticsearch|Promise */ - public function putPolicy(array $params = []) + public function putPolicy(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name','body'], $params); $url = '/_enrich/policy/' . $this->encode($params['name']); $method = 'PUT'; @@ -188,15 +196,15 @@ public function putPolicy(array $params = []) /** * Gets enrich coordinator statistics and information about enrich policies that are currently executing. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats-api.html * * @param array{ - * master_timeout: time, // Timeout for processing on master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Timeout for processing on master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -205,8 +213,9 @@ public function putPolicy(array $params = []) * * @return Elasticsearch|Promise */ - public function stats(array $params = []) + public function stats(?array $params = null) { + $params = $params ?? []; $url = '/_enrich/_stats'; $method = 'GET'; diff --git a/src/Endpoints/Eql.php b/src/Endpoints/Eql.php index 4a10691c4..bed135f66 100644 --- a/src/Endpoints/Eql.php +++ b/src/Endpoints/Eql.php @@ -31,15 +31,16 @@ class Eql extends AbstractEndpoint /** * Deletes an async EQL search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The async search ID - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -49,8 +50,9 @@ class Eql extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function delete(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_eql/search/' . $this->encode($params['id']); $method = 'DELETE'; @@ -68,17 +70,18 @@ public function delete(array $params = []) /** * Returns async results from previously executed Event Query Language (EQL) search * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The async search ID - * wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response - * keep_alive: time, // Update the time interval in which the results (partial or final) for this search will be available - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * wait_for_completion_timeout?: int|string, // Specify the time that the request should block waiting for the final response + * keep_alive?: int|string, // Update the time interval in which the results (partial or final) for this search will be available + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -88,8 +91,9 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function get(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_eql/search/' . $this->encode($params['id']); $method = 'GET'; @@ -107,15 +111,16 @@ public function get(array $params = []) /** * Returns the status of a previously submitted async or stored Event Query Language (EQL) search * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The async search ID - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -125,8 +130,9 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function getStatus(array $params = []) + public function getStatus(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_eql/search/status/' . $this->encode($params['id']); $method = 'GET'; @@ -144,19 +150,22 @@ public function getStatus(array $params = []) /** * Returns results matching a query expressed in Event Query Language (EQL) * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + * @group serverless * * @param array{ * index: string, // (REQUIRED) The name of the index to scope the operation - * wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response - * keep_on_completion: boolean, // Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) - * keep_alive: time, // Update the time interval in which the results (partial or final) for this search will be available - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Eql request body. Use the `query` to limit the query scope. + * wait_for_completion_timeout?: int|string, // Specify the time that the request should block waiting for the final response + * keep_on_completion?: bool, // Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) + * keep_alive?: int|string, // Update the time interval in which the results (partial or final) for this search will be available + * allow_partial_search_results?: bool, // Control whether the query should keep running in case of shard failures, and return partial results + * allow_partial_sequence_results?: bool, // Control whether a sequence query should return partial results or no results at all in case of shard failures. This option has effect only if [allow_partial_search_results] is true. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Eql request body. Use the `query` to limit the query scope.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -166,13 +175,14 @@ public function getStatus(array $params = []) * * @return Elasticsearch|Promise */ - public function search(array $params = []) + public function search(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','body'], $params); $url = '/' . $this->encode($params['index']) . '/_eql/search'; $method = empty($params['body']) ? 'GET' : 'POST'; - $url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_on_completion','keep_alive','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_on_completion','keep_alive','allow_partial_search_results','allow_partial_sequence_results','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Endpoints/Esql.php b/src/Endpoints/Esql.php index 0e7388fa0..871002835 100644 --- a/src/Endpoints/Esql.php +++ b/src/Endpoints/Esql.php @@ -31,18 +31,18 @@ class Esql extends AbstractEndpoint /** * Executes an ESQL request asynchronously * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-api.html * * @param array{ - * format: string, // a short version of the Accept header, e.g. json, yaml - * delimiter: string, // The character to use between values within a CSV row. Only valid for the csv format. - * drop_null_columns: boolean, // Should entirely null columns be removed from the results? Their name and type will be returning in a new `all_columns` section. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Use the `query` element to start a query. Use `columnar` to format the answer. + * format?: string, // a short version of the Accept header, e.g. json, yaml + * delimiter?: string, // The character to use between values within a CSV row. Only valid for the csv format. + * drop_null_columns?: bool, // Should entirely null columns be removed from the results? Their name and type will be returning in a new `all_columns` section. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Use the `query` element to start a query. Use `columnar` to format the answer.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -51,8 +51,9 @@ class Esql extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function asyncQuery(array $params = []) + public function asyncQuery(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_query/async'; $method = 'POST'; @@ -68,21 +69,59 @@ public function asyncQuery(array $params = []) } + /** + * Delete an async query request given its ID. + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-delete-api.html + * + * @param array{ + * id: string, // (REQUIRED) The async query ID + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function asyncQueryDelete(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['id'], $params); + $url = '/_query/async/' . $this->encode($params['id']); + $method = 'DELETE'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'esql.async_query_delete'); + return $this->client->sendRequest($request); + } + + /** * Retrieves the results of a previously submitted async query request given its ID. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-get-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-get-api.html * * @param array{ * id: string, // (REQUIRED) The async query ID - * wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response - * keep_alive: time, // Specify the time interval in which the results (partial or final) for this search will be available - * drop_null_columns: boolean, // Should entirely null columns be removed from the results? Their name and type will be returning in a new `all_columns` section. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * wait_for_completion_timeout?: int|string, // Specify the time that the request should block waiting for the final response + * keep_alive?: int|string, // Specify the time interval in which the results (partial or final) for this search will be available + * drop_null_columns?: bool, // Should entirely null columns be removed from the results? Their name and type will be returning in a new `all_columns` section. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -92,8 +131,9 @@ public function asyncQuery(array $params = []) * * @return Elasticsearch|Promise */ - public function asyncQueryGet(array $params = []) + public function asyncQueryGet(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_query/async/' . $this->encode($params['id']); $method = 'GET'; @@ -108,21 +148,60 @@ public function asyncQueryGet(array $params = []) } + /** + * Stops a previously submitted async query request given its ID and collects the results. + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-stop-api.html + * + * @param array{ + * id: string, // (REQUIRED) The async query ID + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function asyncQueryStop(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['id'], $params); + $url = '/_query/async/' . $this->encode($params['id']) . '/stop'; + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'esql.async_query_stop'); + return $this->client->sendRequest($request); + } + + /** * Executes an ESQL request * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-query-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-query-api.html + * @group serverless * * @param array{ - * format: string, // a short version of the Accept header, e.g. json, yaml - * delimiter: string, // The character to use between values within a CSV row. Only valid for the csv format. - * drop_null_columns: boolean, // Should entirely null columns be removed from the results? Their name and type will be returning in a new `all_columns` section. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Use the `query` element to start a query. Use `columnar` to format the answer. + * format?: string, // a short version of the Accept header, e.g. json, yaml + * delimiter?: string, // The character to use between values within a CSV row. Only valid for the csv format. + * drop_null_columns?: bool, // Should entirely null columns be removed from the results? Their name and type will be returning in a new `all_columns` section. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Use the `query` element to start a query. Use `columnar` to format the answer.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -131,8 +210,9 @@ public function asyncQueryGet(array $params = []) * * @return Elasticsearch|Promise */ - public function query(array $params = []) + public function query(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_query'; $method = 'POST'; diff --git a/src/Endpoints/Features.php b/src/Endpoints/Features.php index 2cb21fa0e..f574c4682 100644 --- a/src/Endpoints/Features.php +++ b/src/Endpoints/Features.php @@ -31,15 +31,15 @@ class Features extends AbstractEndpoint /** * Gets a list of features which can be included in snapshots using the feature_states field when creating a snapshot * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-features-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-features-api.html * * @param array{ - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -48,8 +48,9 @@ class Features extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function getFeatures(array $params = []) + public function getFeatures(?array $params = null) { + $params = $params ?? []; $url = '/_features'; $method = 'GET'; @@ -66,16 +67,16 @@ public function getFeatures(array $params = []) /** * Resets the internal state of features, usually by deleting system indices * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -84,8 +85,9 @@ public function getFeatures(array $params = []) * * @return Elasticsearch|Promise */ - public function resetFeatures(array $params = []) + public function resetFeatures(?array $params = null) { + $params = $params ?? []; $url = '/_features/_reset'; $method = 'POST'; diff --git a/src/Endpoints/Fleet.php b/src/Endpoints/Fleet.php index bb0e9e209..41e11c156 100644 --- a/src/Endpoints/Fleet.php +++ b/src/Endpoints/Fleet.php @@ -31,19 +31,19 @@ class Fleet extends AbstractEndpoint /** * Returns the current global checkpoints for an index. This API is design for internal use by the fleet server project. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-global-checkpoints.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-global-checkpoints.html * * @param array{ * index: string, // (REQUIRED) The name of the index. - * wait_for_advance: boolean, // Whether to wait for the global checkpoint to advance past the specified current checkpoints - * wait_for_index: boolean, // Whether to wait for the target index to exist and all primary shards be active - * checkpoints: list, // Comma separated list of checkpoints - * timeout: time, // Timeout to wait for global checkpoint to advance - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * wait_for_advance?: bool, // Whether to wait for the global checkpoint to advance past the specified current checkpoints + * wait_for_index?: bool, // Whether to wait for the target index to exist and all primary shards be active + * checkpoints?: string|array, // Comma separated list of checkpoints + * timeout?: int|string, // Timeout to wait for global checkpoint to advance + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -53,8 +53,9 @@ class Fleet extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function globalCheckpoints(array $params = []) + public function globalCheckpoints(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_fleet/global_checkpoints'; $method = 'GET'; @@ -76,13 +77,13 @@ public function globalCheckpoints(array $params = []) * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * index: string, // The index name to use as the default - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The request definitions (metadata-fleet search request definition pairs), separated by newlines + * index?: string, // The index name to use as the default + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The request definitions (metadata-fleet search request definition pairs), separated by newlines. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -91,8 +92,9 @@ public function globalCheckpoints(array $params = []) * * @return Elasticsearch|Promise */ - public function msearch(array $params = []) + public function msearch(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['index'])) { $url = '/' . $this->encode($params['index']) . '/_fleet/_fleet_msearch'; @@ -119,15 +121,15 @@ public function msearch(array $params = []) * * @param array{ * index: string, // (REQUIRED) The index name to search. - * wait_for_checkpoints: list, // Comma separated list of checkpoints, one per shard - * wait_for_checkpoints_timeout: time, // Explicit wait_for_checkpoints timeout - * allow_partial_search_results: boolean, // Indicate if an error should be returned if there is a partial search failure or timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The search definition using the Query DSL + * wait_for_checkpoints?: string|array, // Comma separated list of checkpoints, one per shard + * wait_for_checkpoints_timeout?: int|string, // Explicit wait_for_checkpoints timeout + * allow_partial_search_results?: bool, // Indicate if an error should be returned if there is a partial search failure or timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The search definition using the Query DSL. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -137,8 +139,9 @@ public function msearch(array $params = []) * * @return Elasticsearch|Promise */ - public function search(array $params = []) + public function search(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_fleet/_fleet_search'; $method = empty($params['body']) ? 'GET' : 'POST'; diff --git a/src/Endpoints/Graph.php b/src/Endpoints/Graph.php index 416585654..8b53672dd 100644 --- a/src/Endpoints/Graph.php +++ b/src/Endpoints/Graph.php @@ -31,18 +31,19 @@ class Graph extends AbstractEndpoint /** * Explore extracted and summarized information about the documents and terms in an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * routing: string, // Specific routing value - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Graph Query DSL + * index: string|array, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * routing?: string, // Specific routing value + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Graph Query DSL. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -52,10 +53,11 @@ class Graph extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function explore(array $params = []) + public function explore(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']) . '/_graph/explore'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_graph/explore'; $method = empty($params['body']) ? 'GET' : 'POST'; $url = $this->addQueryString($url, $params, ['routing','timeout','pretty','human','error_trace','source','filter_path']); diff --git a/src/Endpoints/Ilm.php b/src/Endpoints/Ilm.php index 1fce30391..b83b6c55d 100644 --- a/src/Endpoints/Ilm.php +++ b/src/Endpoints/Ilm.php @@ -31,15 +31,17 @@ class Ilm extends AbstractEndpoint /** * Deletes the specified lifecycle policy definition. A currently used policy cannot be deleted. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html * * @param array{ * policy: string, // (REQUIRED) The name of the index lifecycle policy - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -49,13 +51,14 @@ class Ilm extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteLifecycle(array $params = []) + public function deleteLifecycle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['policy'], $params); $url = '/_ilm/policy/' . $this->encode($params['policy']); $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -68,17 +71,18 @@ public function deleteLifecycle(array $params = []) /** * Retrieves information about the index's current lifecycle state, such as the currently executing phase, action, and step. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html * * @param array{ * index: string, // (REQUIRED) The name of the index to explain - * only_managed: boolean, // filters the indices included in the response to ones managed by ILM - * only_errors: boolean, // filters the indices included in the response to ones in an ILM error state, implies only_managed - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * only_managed?: bool, // filters the indices included in the response to ones managed by ILM + * only_errors?: bool, // filters the indices included in the response to ones in an ILM error state, implies only_managed + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -88,13 +92,14 @@ public function deleteLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function explainLifecycle(array $params = []) + public function explainLifecycle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_ilm/explain'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['only_managed','only_errors','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['only_managed','only_errors','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -107,15 +112,17 @@ public function explainLifecycle(array $params = []) /** * Returns the specified policy definition. Includes the policy version and last modified date. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html * * @param array{ - * policy: string, // The name of the index lifecycle policy - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * policy?: string, // The name of the index lifecycle policy + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -124,8 +131,9 @@ public function explainLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function getLifecycle(array $params = []) + public function getLifecycle(?array $params = null) { + $params = $params ?? []; if (isset($params['policy'])) { $url = '/_ilm/policy/' . $this->encode($params['policy']); $method = 'GET'; @@ -133,7 +141,7 @@ public function getLifecycle(array $params = []) $url = '/_ilm/policy'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -146,14 +154,14 @@ public function getLifecycle(array $params = []) /** * Retrieves the current index lifecycle management (ILM) status. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -162,8 +170,9 @@ public function getLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function getStatus(array $params = []) + public function getStatus(?array $params = null) { + $params = $params ?? []; $url = '/_ilm/status'; $method = 'GET'; @@ -180,16 +189,17 @@ public function getStatus(array $params = []) /** * Migrates the indices and ILM policies away from custom node attribute allocation routing to data tiers routing * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-migrate-to-data-tiers.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-migrate-to-data-tiers.html * * @param array{ - * dry_run: boolean, // If set to true it will simulate the migration, providing a way to retrieve the ILM policies and indices that need to be migrated. The default is false - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Optionally specify a legacy index template name to delete and optionally specify a node attribute name used for index shard routing (defaults to "data") + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * dry_run?: bool, // If set to true it will simulate the migration, providing a way to retrieve the ILM policies and indices that need to be migrated. The default is false + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Optionally specify a legacy index template name to delete and optionally specify a node attribute name used for index shard routing (defaults to "data"). If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -198,12 +208,13 @@ public function getStatus(array $params = []) * * @return Elasticsearch|Promise */ - public function migrateToDataTiers(array $params = []) + public function migrateToDataTiers(?array $params = null) { + $params = $params ?? []; $url = '/_ilm/migrate_to_data_tiers'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['dry_run','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','dry_run','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -217,16 +228,16 @@ public function migrateToDataTiers(array $params = []) /** * Manually moves an index into the specified step and executes that step. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html * * @param array{ * index: string, // (REQUIRED) The name of the index whose lifecycle step is to change - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The new lifecycle step to move to + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The new lifecycle step to move to. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -236,8 +247,9 @@ public function migrateToDataTiers(array $params = []) * * @return Elasticsearch|Promise */ - public function moveToStep(array $params = []) + public function moveToStep(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/_ilm/move/' . $this->encode($params['index']); $method = 'POST'; @@ -256,16 +268,18 @@ public function moveToStep(array $params = []) /** * Creates a lifecycle policy * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html * * @param array{ * policy: string, // (REQUIRED) The name of the index lifecycle policy - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The lifecycle policy definition to register + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The lifecycle policy definition to register. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -275,13 +289,14 @@ public function moveToStep(array $params = []) * * @return Elasticsearch|Promise */ - public function putLifecycle(array $params = []) + public function putLifecycle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['policy'], $params); $url = '/_ilm/policy/' . $this->encode($params['policy']); $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -295,15 +310,15 @@ public function putLifecycle(array $params = []) /** * Removes the assigned lifecycle policy and stops managing the specified index * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html * * @param array{ * index: string, // (REQUIRED) The name of the index to remove policy on - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -313,8 +328,9 @@ public function putLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function removePolicy(array $params = []) + public function removePolicy(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_ilm/remove'; $method = 'POST'; @@ -332,15 +348,15 @@ public function removePolicy(array $params = []) /** * Retries executing the policy for an index that is in the ERROR step. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html * * @param array{ * index: string, // (REQUIRED) The name of the indices (comma-separated) whose failed lifecycle step is to be retry - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -350,8 +366,9 @@ public function removePolicy(array $params = []) * * @return Elasticsearch|Promise */ - public function retry(array $params = []) + public function retry(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_ilm/retry'; $method = 'POST'; @@ -369,14 +386,16 @@ public function retry(array $params = []) /** * Start the index lifecycle management (ILM) plugin. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -385,12 +404,13 @@ public function retry(array $params = []) * * @return Elasticsearch|Promise */ - public function start(array $params = []) + public function start(?array $params = null) { + $params = $params ?? []; $url = '/_ilm/start'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -403,14 +423,16 @@ public function start(array $params = []) /** * Halts all lifecycle management operations and stops the index lifecycle management (ILM) plugin * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -419,12 +441,13 @@ public function start(array $params = []) * * @return Elasticsearch|Promise */ - public function stop(array $params = []) + public function stop(?array $params = null) { + $params = $params ?? []; $url = '/_ilm/stop'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; diff --git a/src/Endpoints/Indices.php b/src/Endpoints/Indices.php index 9ab3c7df0..ef70683bb 100644 --- a/src/Endpoints/Indices.php +++ b/src/Endpoints/Indices.php @@ -31,21 +31,22 @@ class Indices extends AbstractEndpoint /** * Adds a block to an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/index-modules-blocks.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/index-modules-blocks.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma separated list of indices to add a block to + * index: string|array, // (REQUIRED) A comma separated list of indices to add a block to * block: string, // (REQUIRED) The block to add (one of read, write, read_only or metadata) - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -55,10 +56,11 @@ class Indices extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function addBlock(array $params = []) + public function addBlock(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','block'], $params); - $url = '/' . $this->encode($params['index']) . '/_block/' . $this->encode($params['block']); + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_block/' . $this->encode($params['block']); $method = 'PUT'; $url = $this->addQueryString($url, $params, ['timeout','master_timeout','ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); @@ -74,16 +76,17 @@ public function addBlock(array $params = []) /** * Performs the analysis process on a text and return the tokens breakdown of the text. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html + * @group serverless * * @param array{ - * index: string, // The name of the index to scope the operation - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Define analyzer/tokenizer parameters and the text on which the analysis should be performed + * index?: string, // The name of the index to scope the operation + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Define analyzer/tokenizer parameters and the text on which the analysis should be performed. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -92,8 +95,9 @@ public function addBlock(array $params = []) * * @return Elasticsearch|Promise */ - public function analyze(array $params = []) + public function analyze(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { $url = '/' . $this->encode($params['index']) . '/_analyze'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -115,22 +119,22 @@ public function analyze(array $params = []) /** * Clears all or specific caches for one or more indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html * * @param array{ - * index: list, // A comma-separated list of index name to limit the operation - * fielddata: boolean, // Clear field data - * fields: list, // A comma-separated list of fields to clear when using the `fielddata` parameter (default: all) - * query: boolean, // Clear query caches - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * request: boolean, // Clear request cache - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index name to limit the operation + * fielddata?: bool, // Clear field data + * fields?: string|array, // A comma-separated list of fields to clear when using the `fielddata` parameter (default: all) + * query?: bool, // Clear query caches + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * request?: bool, // Clear request cache + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -139,10 +143,11 @@ public function analyze(array $params = []) * * @return Elasticsearch|Promise */ - public function clearCache(array $params = []) + public function clearCache(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_cache/clear'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_cache/clear'; $method = 'POST'; } else { $url = '/_cache/clear'; @@ -161,20 +166,20 @@ public function clearCache(array $params = []) /** * Clones an index * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clone-index.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clone-index.html * * @param array{ * index: string, // (REQUIRED) The name of the source index to clone * target: string, // (REQUIRED) The name of the target index to clone into - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * wait_for_active_shards: string, // Set the number of active shards to wait for on the cloned index before the operation returns. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The configuration for the target index (`settings` and `aliases`) + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * wait_for_active_shards?: string, // Set the number of active shards to wait for on the cloned index before the operation returns. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The configuration for the target index (`settings` and `aliases`). If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -184,8 +189,9 @@ public function clearCache(array $params = []) * * @return Elasticsearch|Promise */ - public function clone(array $params = []) + public function clone(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','target'], $params); $url = '/' . $this->encode($params['index']) . '/_clone/' . $this->encode($params['target']); $method = 'PUT'; @@ -204,21 +210,21 @@ public function clone(array $params = []) /** * Closes an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html * * @param array{ - * index: list, // (REQUIRED) A comma separated list of indices to close - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * wait_for_active_shards: string, // Sets the number of active shards to wait for before the operation returns. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index: string|array, // (REQUIRED) A comma separated list of indices to close + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * wait_for_active_shards?: string, // Sets the number of active shards to wait for before the operation returns. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -228,10 +234,11 @@ public function clone(array $params = []) * * @return Elasticsearch|Promise */ - public function close(array $params = []) + public function close(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']) . '/_close'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_close'; $method = 'POST'; $url = $this->addQueryString($url, $params, ['timeout','master_timeout','ignore_unavailable','allow_no_indices','expand_wildcards','wait_for_active_shards','pretty','human','error_trace','source','filter_path']); @@ -247,19 +254,20 @@ public function close(array $params = []) /** * Creates an index with optional settings and mappings. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html + * @group serverless * * @param array{ * index: string, // (REQUIRED) The name of the index - * wait_for_active_shards: string, // Set the number of active shards to wait for before the operation returns. - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The configuration for the index (`settings` and `mappings`) + * wait_for_active_shards?: string, // Set the number of active shards to wait for before the operation returns. + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The configuration for the index (`settings` and `mappings`). If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -269,8 +277,9 @@ public function close(array $params = []) * * @return Elasticsearch|Promise */ - public function create(array $params = []) + public function create(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']); $method = 'PUT'; @@ -289,15 +298,18 @@ public function create(array $params = []) /** * Creates a data stream * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the data stream - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // Specify timeout for acknowledging the cluster state update + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -307,13 +319,14 @@ public function create(array $params = []) * * @return Elasticsearch|Promise */ - public function createDataStream(array $params = []) + public function createDataStream(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_data_stream/' . $this->encode($params['name']); $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['timeout','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -326,15 +339,15 @@ public function createDataStream(array $params = []) /** * Provides statistics on operations happening in a data stream. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html * * @param array{ - * name: list, // A comma-separated list of data stream names; use `_all` or empty string to perform the operation on all data streams - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // A comma-separated list of data stream names; use `_all` or empty string to perform the operation on all data streams + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -343,10 +356,11 @@ public function createDataStream(array $params = []) * * @return Elasticsearch|Promise */ - public function dataStreamsStats(array $params = []) + public function dataStreamsStats(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { - $url = '/_data_stream/' . $this->encode($params['name']) . '/_stats'; + $url = '/_data_stream/' . $this->encode($this->convertValue($params['name'])) . '/_stats'; $method = 'GET'; } else { $url = '/_data_stream/_stats'; @@ -365,20 +379,21 @@ public function dataStreamsStats(array $params = []) /** * Deletes an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * ignore_unavailable: boolean, // Ignore unavailable indexes (default: false) - * allow_no_indices: boolean, // Ignore if a wildcard expression resolves to no concrete indices (default: false) - * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open, closed, or hidden indices - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index: string|array, // (REQUIRED) A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * ignore_unavailable?: bool, // Ignore unavailable indexes (default: false) + * allow_no_indices?: bool, // Ignore if a wildcard expression resolves to no concrete indices (default: false) + * expand_wildcards?: string, // Whether wildcard expressions should get expanded to open, closed, or hidden indices + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -388,10 +403,11 @@ public function dataStreamsStats(array $params = []) * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function delete(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']); + $url = '/' . $this->encode($this->convertValue($params['index'])); $method = 'DELETE'; $url = $this->addQueryString($url, $params, ['timeout','master_timeout','ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); @@ -407,18 +423,19 @@ public function delete(array $params = []) /** * Deletes an alias. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names (supports wildcards); use `_all` for all indices - * name: list, // (REQUIRED) A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. - * timeout: time, // Explicit timestamp for the document - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index: string|array, // (REQUIRED) A comma-separated list of index names (supports wildcards); use `_all` for all indices + * name: string|array, // (REQUIRED) A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. + * timeout?: int|string, // Explicit timestamp for the document + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -428,10 +445,11 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteAlias(array $params = []) + public function deleteAlias(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','name'], $params); - $url = '/' . $this->encode($params['index']) . '/_alias/' . $this->encode($params['name']); + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_alias/' . $this->encode($this->convertValue($params['name'])); $method = 'DELETE'; $url = $this->addQueryString($url, $params, ['timeout','master_timeout','pretty','human','error_trace','source','filter_path']); @@ -447,19 +465,18 @@ public function deleteAlias(array $params = []) /** * Deletes the data stream lifecycle of the selected data streams. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-delete-lifecycle.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-delete-lifecycle.html * * @param array{ - * name: list, // (REQUIRED) A comma-separated list of data streams of which the data stream lifecycle will be deleted; use `*` to get all data streams - * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) - * timeout: time, // Explicit timestamp for the document - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name: string|array, // (REQUIRED) A comma-separated list of data streams of which the data stream lifecycle will be deleted; use `*` to get all data streams + * expand_wildcards?: string, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * timeout?: int|string, // Explicit timestamp for the document + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -469,10 +486,11 @@ public function deleteAlias(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteDataLifecycle(array $params = []) + public function deleteDataLifecycle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); - $url = '/_data_stream/' . $this->encode($params['name']) . '/_lifecycle'; + $url = '/_data_stream/' . $this->encode($this->convertValue($params['name'])) . '/_lifecycle'; $method = 'DELETE'; $url = $this->addQueryString($url, $params, ['expand_wildcards','timeout','master_timeout','pretty','human','error_trace','source','filter_path']); @@ -488,16 +506,18 @@ public function deleteDataLifecycle(array $params = []) /** * Deletes a data stream. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @group serverless * * @param array{ - * name: list, // (REQUIRED) A comma-separated list of data streams to delete; use `*` to delete all data streams - * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name: string|array, // (REQUIRED) A comma-separated list of data streams to delete; use `*` to delete all data streams + * expand_wildcards?: string, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -507,13 +527,14 @@ public function deleteDataLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteDataStream(array $params = []) + public function deleteDataStream(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); - $url = '/_data_stream/' . $this->encode($params['name']); + $url = '/_data_stream/' . $this->encode($this->convertValue($params['name'])); $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['expand_wildcards','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['expand_wildcards','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -526,17 +547,18 @@ public function deleteDataStream(array $params = []) /** * Deletes an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-template.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-template.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the template - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -546,8 +568,9 @@ public function deleteDataStream(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteIndexTemplate(array $params = []) + public function deleteIndexTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_index_template/' . $this->encode($params['name']); $method = 'DELETE'; @@ -565,17 +588,17 @@ public function deleteIndexTemplate(array $params = []) /** * Deletes an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-template-v1.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-template-v1.html * * @param array{ * name: string, // (REQUIRED) The name of the template - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -585,8 +608,9 @@ public function deleteIndexTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteTemplate(array $params = []) + public function deleteTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_template/' . $this->encode($params['name']); $method = 'DELETE'; @@ -604,21 +628,21 @@ public function deleteTemplate(array $params = []) /** * Analyzes the disk usage of each field of an index or data stream * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-disk-usage.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-disk-usage.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * index: string, // (REQUIRED) Comma-separated list of indices or data streams to analyze the disk usage - * run_expensive_tasks: boolean, // Must be set to [true] in order for the task to be performed. Defaults to false. - * flush: boolean, // Whether flush or not before analyzing the index disk usage. Defaults to true - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * run_expensive_tasks?: bool, // Must be set to [true] in order for the task to be performed. Defaults to false. + * flush?: bool, // Whether flush or not before analyzing the index disk usage. Defaults to true + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -628,8 +652,9 @@ public function deleteTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function diskUsage(array $params = []) + public function diskUsage(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_disk_usage'; $method = 'POST'; @@ -647,18 +672,18 @@ public function diskUsage(array $params = []) /** * Downsample an index * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-rollup.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-rollup.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * index: string, // (REQUIRED) The index to downsample * target_index: string, // (REQUIRED) The name of the target index to store downsampled data - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The downsampling configuration + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The downsampling configuration. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -668,8 +693,9 @@ public function diskUsage(array $params = []) * * @return Elasticsearch|Promise */ - public function downsample(array $params = []) + public function downsample(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','target_index','body'], $params); $url = '/' . $this->encode($params['index']) . '/_downsample/' . $this->encode($params['target_index']); $method = 'POST'; @@ -688,21 +714,22 @@ public function downsample(array $params = []) /** * Returns information about whether a particular index exists. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * ignore_unavailable: boolean, // Ignore unavailable indexes (default: false) - * allow_no_indices: boolean, // Ignore if a wildcard expression resolves to no concrete indices (default: false) - * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) - * flat_settings: boolean, // Return settings in flat format (default: false) - * include_defaults: boolean, // Whether to return all default setting for each of the indices. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index: string|array, // (REQUIRED) A comma-separated list of index names + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * ignore_unavailable?: bool, // Ignore unavailable indexes (default: false) + * allow_no_indices?: bool, // Ignore if a wildcard expression resolves to no concrete indices (default: false) + * expand_wildcards?: string, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * flat_settings?: bool, // Return settings in flat format (default: false) + * include_defaults?: bool, // Whether to return all default setting for each of the indices. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -712,10 +739,11 @@ public function downsample(array $params = []) * * @return Elasticsearch|Promise */ - public function exists(array $params = []) + public function exists(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']); + $url = '/' . $this->encode($this->convertValue($params['index'])); $method = 'HEAD'; $url = $this->addQueryString($url, $params, ['local','ignore_unavailable','allow_no_indices','expand_wildcards','flat_settings','include_defaults','pretty','human','error_trace','source','filter_path']); @@ -731,20 +759,21 @@ public function exists(array $params = []) /** * Returns information about whether a particular alias exists. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html + * @group serverless * * @param array{ - * name: list, // (REQUIRED) A comma-separated list of alias names to return - * index: list, // A comma-separated list of index names to filter aliases - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name: string|array, // (REQUIRED) A comma-separated list of alias names to return + * index?: string|array, // A comma-separated list of index names to filter aliases + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * master_timeout?: int|string, // Timeout for waiting for new cluster state in case it is blocked + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -754,17 +783,18 @@ public function exists(array $params = []) * * @return Elasticsearch|Promise */ - public function existsAlias(array $params = []) + public function existsAlias(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_alias/' . $this->encode($params['name']); + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_alias/' . $this->encode($this->convertValue($params['name'])); $method = 'HEAD'; } else { - $url = '/_alias/' . $this->encode($params['name']); + $url = '/_alias/' . $this->encode($this->convertValue($params['name'])); $method = 'HEAD'; } - $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','local','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -777,18 +807,19 @@ public function existsAlias(array $params = []) /** * Returns information about whether a particular index template exists. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/index-templates.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/index-templates.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the template - * flat_settings: boolean, // Return settings in flat format (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * flat_settings?: bool, // Return settings in flat format (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -798,8 +829,9 @@ public function existsAlias(array $params = []) * * @return Elasticsearch|Promise */ - public function existsIndexTemplate(array $params = []) + public function existsIndexTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_index_template/' . $this->encode($params['name']); $method = 'HEAD'; @@ -817,18 +849,18 @@ public function existsIndexTemplate(array $params = []) /** * Returns information about whether a particular index template exists. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-template-exists-v1.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-template-exists-v1.html * * @param array{ - * name: list, // (REQUIRED) The comma separated names of the index templates - * flat_settings: boolean, // Return settings in flat format (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name: string|array, // (REQUIRED) The comma separated names of the index templates + * flat_settings?: bool, // Return settings in flat format (default: false) + * master_timeout?: int|string, // Timeout for waiting for new cluster state in case it is blocked + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -838,10 +870,11 @@ public function existsIndexTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function existsTemplate(array $params = []) + public function existsTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); - $url = '/_template/' . $this->encode($params['name']); + $url = '/_template/' . $this->encode($this->convertValue($params['name'])); $method = 'HEAD'; $url = $this->addQueryString($url, $params, ['flat_settings','master_timeout','local','pretty','human','error_trace','source','filter_path']); @@ -857,18 +890,18 @@ public function existsTemplate(array $params = []) /** * Retrieves information about the index's current data stream lifecycle, such as any potential encountered error, time since creation etc. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams-explain-lifecycle.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams-explain-lifecycle.html + * @group serverless * * @param array{ * index: string, // (REQUIRED) The name of the index to explain - * include_defaults: boolean, // indicates if the API should return the default values the system uses for the index's lifecycle - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * include_defaults?: bool, // indicates if the API should return the default values the system uses for the index's lifecycle + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -878,8 +911,9 @@ public function existsTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function explainDataLifecycle(array $params = []) + public function explainDataLifecycle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_lifecycle/explain'; $method = 'GET'; @@ -897,20 +931,20 @@ public function explainDataLifecycle(array $params = []) /** * Returns the field usage stats for each field of an index * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/field-usage-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/field-usage-stats.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * index: string, // (REQUIRED) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * fields: list, // A comma-separated list of fields to include in the stats if only a subset of fields should be returned (supports wildcards) - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * fields?: string|array, // A comma-separated list of fields to include in the stats if only a subset of fields should be returned (supports wildcards) + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -920,8 +954,9 @@ public function explainDataLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function fieldUsageStats(array $params = []) + public function fieldUsageStats(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_field_usage_stats'; $method = 'GET'; @@ -939,20 +974,20 @@ public function fieldUsageStats(array $params = []) /** * Performs the flush operation on one or more indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html * * @param array{ - * index: list, // A comma-separated list of index names; use `_all` or empty string for all indices - * force: boolean, // Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) - * wait_if_ongoing: boolean, // If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string for all indices + * force?: bool, // Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) + * wait_if_ongoing?: bool, // If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -961,14 +996,15 @@ public function fieldUsageStats(array $params = []) * * @return Elasticsearch|Promise */ - public function flush(array $params = []) + public function flush(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_flush'; - $method = empty($params['body']) ? 'GET' : 'POST'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_flush'; + $method = 'POST'; } else { $url = '/_flush'; - $method = empty($params['body']) ? 'GET' : 'POST'; + $method = 'POST'; } $url = $this->addQueryString($url, $params, ['force','wait_if_ongoing','ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); $headers = [ @@ -983,22 +1019,22 @@ public function flush(array $params = []) /** * Performs the force merge operation on one or more indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html * * @param array{ - * index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * flush: boolean, // Specify whether the index should be flushed after performing the operation (default: true) - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * max_num_segments: number, // The number of segments the index should be merged into (default: dynamic) - * only_expunge_deletes: boolean, // Specify whether the operation should only expunge deleted documents - * wait_for_completion: boolean, // Should the request wait until the force merge is completed. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * flush?: bool, // Specify whether the index should be flushed after performing the operation (default: true) + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * max_num_segments?: int, // The number of segments the index should be merged into (default: dynamic) + * only_expunge_deletes?: bool, // Specify whether the operation should only expunge deleted documents + * wait_for_completion?: bool, // Should the request wait until the force merge is completed. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1007,10 +1043,11 @@ public function flush(array $params = []) * * @return Elasticsearch|Promise */ - public function forcemerge(array $params = []) + public function forcemerge(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_forcemerge'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_forcemerge'; $method = 'POST'; } else { $url = '/_forcemerge'; @@ -1029,23 +1066,24 @@ public function forcemerge(array $params = []) /** * Returns information about one or more indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * ignore_unavailable: boolean, // Ignore unavailable indexes (default: false) - * allow_no_indices: boolean, // Ignore if a wildcard expression resolves to no concrete indices (default: false) - * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) - * features: enum, // Return only information on specified index features - * flat_settings: boolean, // Return settings in flat format (default: false) - * include_defaults: boolean, // Whether to return all default setting for each of the indices. - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index: string|array, // (REQUIRED) A comma-separated list of index names + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * ignore_unavailable?: bool, // Ignore unavailable indexes (default: false) + * allow_no_indices?: bool, // Ignore if a wildcard expression resolves to no concrete indices (default: false) + * expand_wildcards?: string, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * features?: string, // Return only information on specified index features + * flat_settings?: bool, // Return settings in flat format (default: false) + * include_defaults?: bool, // Whether to return all default setting for each of the indices. + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1055,10 +1093,11 @@ public function forcemerge(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function get(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']); + $url = '/' . $this->encode($this->convertValue($params['index'])); $method = 'GET'; $url = $this->addQueryString($url, $params, ['local','ignore_unavailable','allow_no_indices','expand_wildcards','features','flat_settings','include_defaults','master_timeout','pretty','human','error_trace','source','filter_path']); @@ -1074,20 +1113,21 @@ public function get(array $params = []) /** * Returns an alias. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html + * @group serverless * * @param array{ - * name: list, // A comma-separated list of alias names to return - * index: list, // A comma-separated list of index names to filter aliases - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // A comma-separated list of alias names to return + * index?: string|array, // A comma-separated list of index names to filter aliases + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * master_timeout?: int|string, // Timeout for waiting for new cluster state in case it is blocked + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1096,22 +1136,23 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function getAlias(array $params = []) + public function getAlias(?array $params = null) { + $params = $params ?? []; if (isset($params['index']) && isset($params['name'])) { - $url = '/' . $this->encode($params['index']) . '/_alias/' . $this->encode($params['name']); + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_alias/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } elseif (isset($params['name'])) { - $url = '/_alias/' . $this->encode($params['name']); + $url = '/_alias/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } elseif (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_alias'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_alias'; $method = 'GET'; } else { $url = '/_alias'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','local','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -1124,18 +1165,19 @@ public function getAlias(array $params = []) /** * Returns the data stream lifecycle of the selected data streams. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-get-lifecycle.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-get-lifecycle.html + * @group serverless * * @param array{ - * name: list, // (REQUIRED) A comma-separated list of data streams to get; use `*` to get all data streams - * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) - * include_defaults: boolean, // Return all relevant default configurations for the data stream (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name: string|array, // (REQUIRED) A comma-separated list of data streams to get; use `*` to get all data streams + * expand_wildcards?: string, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * include_defaults?: bool, // Return all relevant default configurations for the data stream (default: false) + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1145,13 +1187,14 @@ public function getAlias(array $params = []) * * @return Elasticsearch|Promise */ - public function getDataLifecycle(array $params = []) + public function getDataLifecycle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); - $url = '/_data_stream/' . $this->encode($params['name']) . '/_lifecycle'; + $url = '/_data_stream/' . $this->encode($this->convertValue($params['name'])) . '/_lifecycle'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['expand_wildcards','include_defaults','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['expand_wildcards','include_defaults','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -1161,20 +1204,58 @@ public function getDataLifecycle(array $params = []) } + /** + * Get data stream lifecycle statistics. + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-get-lifecycle-stats.html + * + * @param array{ + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function getDataLifecycleStats(?array $params = null) + { + $params = $params ?? []; + $url = '/_lifecycle/stats'; + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'indices.get_data_lifecycle_stats'); + return $this->client->sendRequest($request); + } + + /** * Returns data streams. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @group serverless * * @param array{ - * name: list, // A comma-separated list of data streams to get; use `*` to get all data streams - * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) - * include_defaults: boolean, // Return all relevant default configurations for the data stream (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // A comma-separated list of data streams to get; use `*` to get all data streams + * expand_wildcards?: string, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * include_defaults?: bool, // Return all relevant default configurations for the data stream (default: false) + * master_timeout?: int|string, // Specify timeout for connection to master + * verbose?: bool, // Whether the maximum timestamp for each data stream should be calculated and returned (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1183,16 +1264,17 @@ public function getDataLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function getDataStream(array $params = []) + public function getDataStream(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { - $url = '/_data_stream/' . $this->encode($params['name']); + $url = '/_data_stream/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } else { $url = '/_data_stream'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['expand_wildcards','include_defaults','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['expand_wildcards','include_defaults','master_timeout','verbose','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -1205,21 +1287,21 @@ public function getDataStream(array $params = []) /** * Returns mapping for one or more fields. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html * * @param array{ - * fields: list, // (REQUIRED) A comma-separated list of fields - * index: list, // A comma-separated list of index names - * include_defaults: boolean, // Whether the default mapping values should be returned as well - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * fields: string|array, // (REQUIRED) A comma-separated list of fields + * index?: string|array, // A comma-separated list of index names + * include_defaults?: bool, // Whether the default mapping values should be returned as well + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1229,14 +1311,15 @@ public function getDataStream(array $params = []) * * @return Elasticsearch|Promise */ - public function getFieldMapping(array $params = []) + public function getFieldMapping(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['fields'], $params); if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_mapping/field/' . $this->encode($params['fields']); + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_mapping/field/' . $this->encode($this->convertValue($params['fields'])); $method = 'GET'; } else { - $url = '/_mapping/field/' . $this->encode($params['fields']); + $url = '/_mapping/field/' . $this->encode($this->convertValue($params['fields'])); $method = 'GET'; } $url = $this->addQueryString($url, $params, ['include_defaults','ignore_unavailable','allow_no_indices','expand_wildcards','local','pretty','human','error_trace','source','filter_path']); @@ -1252,19 +1335,20 @@ public function getFieldMapping(array $params = []) /** * Returns an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-template.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-template.html + * @group serverless * * @param array{ - * name: string, // A pattern that returned template names must match - * flat_settings: boolean, // Return settings in flat format (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * include_defaults: boolean, // Return all relevant default configurations for the index template (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string, // A pattern that returned template names must match + * flat_settings?: bool, // Return settings in flat format (default: false) + * master_timeout?: int|string, // Timeout for waiting for new cluster state in case it is blocked + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * include_defaults?: bool, // Return all relevant default configurations for the index template (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1273,8 +1357,9 @@ public function getFieldMapping(array $params = []) * * @return Elasticsearch|Promise */ - public function getIndexTemplate(array $params = []) + public function getIndexTemplate(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { $url = '/_index_template/' . $this->encode($params['name']); $method = 'GET'; @@ -1295,20 +1380,21 @@ public function getIndexTemplate(array $params = []) /** * Returns mappings for one or more indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-mapping.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-mapping.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * master_timeout: time, // Specify timeout for connection to master - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * master_timeout?: int|string, // Specify timeout for connection to master + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1317,10 +1403,11 @@ public function getIndexTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function getMapping(array $params = []) + public function getMapping(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_mapping'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_mapping'; $method = 'GET'; } else { $url = '/_mapping'; @@ -1339,23 +1426,24 @@ public function getMapping(array $params = []) /** * Returns settings for one or more indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-settings.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-settings.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * name: list, // The name of the settings that should be included - * master_timeout: time, // Specify timeout for connection to master - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * flat_settings: boolean, // Return settings in flat format (default: false) - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * include_defaults: boolean, // Whether to return all default setting for each of the indices. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * name?: string|array, // The name of the settings that should be included + * master_timeout?: int|string, // Specify timeout for connection to master + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * flat_settings?: bool, // Return settings in flat format (default: false) + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * include_defaults?: bool, // Whether to return all default setting for each of the indices. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1364,16 +1452,17 @@ public function getMapping(array $params = []) * * @return Elasticsearch|Promise */ - public function getSettings(array $params = []) + public function getSettings(?array $params = null) { + $params = $params ?? []; if (isset($params['index']) && isset($params['name'])) { - $url = '/' . $this->encode($params['index']) . '/_settings/' . $this->encode($params['name']); + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_settings/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } elseif (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_settings'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_settings'; $method = 'GET'; } elseif (isset($params['name'])) { - $url = '/_settings/' . $this->encode($params['name']); + $url = '/_settings/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } else { $url = '/_settings'; @@ -1392,18 +1481,18 @@ public function getSettings(array $params = []) /** * Returns an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-template-v1.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-template-v1.html * * @param array{ - * name: list, // The comma separated names of the index templates - * flat_settings: boolean, // Return settings in flat format (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // The comma separated names of the index templates + * flat_settings?: bool, // Return settings in flat format (default: false) + * master_timeout?: int|string, // Timeout for waiting for new cluster state in case it is blocked + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1412,10 +1501,11 @@ public function getSettings(array $params = []) * * @return Elasticsearch|Promise */ - public function getTemplate(array $params = []) + public function getTemplate(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { - $url = '/_template/' . $this->encode($params['name']); + $url = '/_template/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } else { $url = '/_template'; @@ -1434,15 +1524,18 @@ public function getTemplate(array $params = []) /** * Migrates an alias to a data stream * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the alias to migrate - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // Specify timeout for acknowledging the cluster state update + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1452,13 +1545,14 @@ public function getTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function migrateToDataStream(array $params = []) + public function migrateToDataStream(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_data_stream/_migrate/' . $this->encode($params['name']); $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['timeout','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -1471,15 +1565,16 @@ public function migrateToDataStream(array $params = []) /** * Modifies a data stream * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The data stream modifications + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The data stream modifications. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1488,8 +1583,9 @@ public function migrateToDataStream(array $params = []) * * @return Elasticsearch|Promise */ - public function modifyDataStream(array $params = []) + public function modifyDataStream(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_data_stream/_modify'; $method = 'POST'; @@ -1508,21 +1604,21 @@ public function modifyDataStream(array $params = []) /** * Opens an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html * * @param array{ - * index: list, // (REQUIRED) A comma separated list of indices to open - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * wait_for_active_shards: string, // Sets the number of active shards to wait for before the operation returns. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index: string|array, // (REQUIRED) A comma separated list of indices to open + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * wait_for_active_shards?: string, // Sets the number of active shards to wait for before the operation returns. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1532,10 +1628,11 @@ public function modifyDataStream(array $params = []) * * @return Elasticsearch|Promise */ - public function open(array $params = []) + public function open(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']) . '/_open'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_open'; $method = 'POST'; $url = $this->addQueryString($url, $params, ['timeout','master_timeout','ignore_unavailable','allow_no_indices','expand_wildcards','wait_for_active_shards','pretty','human','error_trace','source','filter_path']); @@ -1551,15 +1648,16 @@ public function open(array $params = []) /** * Promotes a data stream from a replicated data stream managed by CCR to a regular data stream * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html * * @param array{ * name: string, // (REQUIRED) The name of the data stream - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1569,13 +1667,14 @@ public function open(array $params = []) * * @return Elasticsearch|Promise */ - public function promoteDataStream(array $params = []) + public function promoteDataStream(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_data_stream/_promote/' . $this->encode($params['name']); $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -1588,19 +1687,20 @@ public function promoteDataStream(array $params = []) /** * Creates or updates an alias. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. + * index: string|array, // (REQUIRED) A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. * name: string, // (REQUIRED) The name of the alias to be created or updated - * timeout: time, // Explicit timestamp for the document - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The settings for the alias, such as `routing` or `filter` + * timeout?: int|string, // Explicit timestamp for the document + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The settings for the alias, such as `routing` or `filter`. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1610,10 +1710,11 @@ public function promoteDataStream(array $params = []) * * @return Elasticsearch|Promise */ - public function putAlias(array $params = []) + public function putAlias(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','name'], $params); - $url = '/' . $this->encode($params['index']) . '/_alias/' . $this->encode($params['name']); + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_alias/' . $this->encode($params['name']); $method = 'PUT'; $url = $this->addQueryString($url, $params, ['timeout','master_timeout','pretty','human','error_trace','source','filter_path']); @@ -1630,20 +1731,20 @@ public function putAlias(array $params = []) /** * Updates the data stream lifecycle of the selected data streams. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-put-lifecycle.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-put-lifecycle.html + * @group serverless * * @param array{ - * name: list, // (REQUIRED) A comma-separated list of data streams whose lifecycle will be updated; use `*` to set the lifecycle to all data streams - * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) - * timeout: time, // Explicit timestamp for the document - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The data stream lifecycle configuration that consist of the data retention + * name: string|array, // (REQUIRED) A comma-separated list of data streams whose lifecycle will be updated; use `*` to set the lifecycle to all data streams + * expand_wildcards?: string, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * timeout?: int|string, // Explicit timestamp for the document + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The data stream lifecycle configuration that consist of the data retention. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1653,15 +1754,17 @@ public function putAlias(array $params = []) * * @return Elasticsearch|Promise */ - public function putDataLifecycle(array $params = []) + public function putDataLifecycle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); - $url = '/_data_stream/' . $this->encode($params['name']) . '/_lifecycle'; + $url = '/_data_stream/' . $this->encode($this->convertValue($params['name'])) . '/_lifecycle'; $method = 'PUT'; $url = $this->addQueryString($url, $params, ['expand_wildcards','timeout','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', + 'Content-Type' => 'application/json', ]; $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.put_data_lifecycle'); @@ -1672,19 +1775,20 @@ public function putDataLifecycle(array $params = []) /** * Creates or updates an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-template.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-template.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the template - * create: boolean, // Whether the index template should only be added if new or can also replace an existing one - * cause: string, // User defined reason for creating/updating the index template - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The template definition + * create?: bool, // Whether the index template should only be added if new or can also replace an existing one + * cause?: string, // User defined reason for creating/updating the index template + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The template definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1694,8 +1798,9 @@ public function putDataLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function putIndexTemplate(array $params = []) + public function putIndexTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name','body'], $params); $url = '/_index_template/' . $this->encode($params['name']); $method = 'PUT'; @@ -1714,22 +1819,23 @@ public function putIndexTemplate(array $params = []) /** * Updates the index mappings. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * write_index_only: boolean, // When true, applies mappings only to the write index of an alias or data stream - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The mapping definition + * index: string|array, // (REQUIRED) A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * write_index_only?: bool, // When true, applies mappings only to the write index of an alias or data stream + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The mapping definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1739,10 +1845,11 @@ public function putIndexTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function putMapping(array $params = []) + public function putMapping(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','body'], $params); - $url = '/' . $this->encode($params['index']) . '/_mapping'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_mapping'; $method = 'PUT'; $url = $this->addQueryString($url, $params, ['timeout','master_timeout','ignore_unavailable','allow_no_indices','expand_wildcards','write_index_only','pretty','human','error_trace','source','filter_path']); @@ -1759,24 +1866,25 @@ public function putMapping(array $params = []) /** * Updates the index settings. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-update-settings.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-update-settings.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * master_timeout: time, // Specify timeout for connection to master - * timeout: time, // Explicit operation timeout - * preserve_existing: boolean, // Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false` - * reopen: boolean, // Whether to close and reopen the index to apply non-dynamic settings. If set to `true` the indices to which the settings are being applied will be closed temporarily and then reopened in order to apply the changes. The default is `false` - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * flat_settings: boolean, // Return settings in flat format (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The index settings to be updated + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * master_timeout?: int|string, // Specify timeout for connection to master + * timeout?: int|string, // Explicit operation timeout + * preserve_existing?: bool, // Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false` + * reopen?: bool, // Whether to close and reopen the index to apply non-dynamic settings. If set to `true` the indices to which the settings are being applied will be closed temporarily and then reopened in order to apply the changes. The default is `false` + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * flat_settings?: bool, // Return settings in flat format (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The index settings to be updated. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1785,11 +1893,12 @@ public function putMapping(array $params = []) * * @return Elasticsearch|Promise */ - public function putSettings(array $params = []) + public function putSettings(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_settings'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_settings'; $method = 'PUT'; } else { $url = '/_settings'; @@ -1809,19 +1918,20 @@ public function putSettings(array $params = []) /** * Creates or updates an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates-v1.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates-v1.html * * @param array{ * name: string, // (REQUIRED) The name of the template - * order: number, // The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) - * create: boolean, // Whether the index template should only be added if new or can also replace an existing one - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The template definition + * order?: int, // The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) + * create?: bool, // Whether the index template should only be added if new or can also replace an existing one + * cause?: string, // User defined reason for creating/updating the index template + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The template definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1831,13 +1941,14 @@ public function putSettings(array $params = []) * * @return Elasticsearch|Promise */ - public function putTemplate(array $params = []) + public function putTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name','body'], $params); $url = '/_template/' . $this->encode($params['name']); $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['order','create','master_timeout','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['order','create','cause','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -1851,17 +1962,17 @@ public function putTemplate(array $params = []) /** * Returns information about ongoing index shard recoveries. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-recovery.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-recovery.html * * @param array{ - * index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * detailed: boolean, // Whether to display detailed information about shard recovery - * active_only: boolean, // Display only those recoveries that are currently on-going - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * detailed?: bool, // Whether to display detailed information about shard recovery + * active_only?: bool, // Display only those recoveries that are currently on-going + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1870,10 +1981,11 @@ public function putTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function recovery(array $params = []) + public function recovery(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_recovery'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_recovery'; $method = 'GET'; } else { $url = '/_recovery'; @@ -1892,18 +2004,19 @@ public function recovery(array $params = []) /** * Performs the refresh operation in one or more indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1912,14 +2025,15 @@ public function recovery(array $params = []) * * @return Elasticsearch|Promise */ - public function refresh(array $params = []) + public function refresh(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_refresh'; - $method = empty($params['body']) ? 'GET' : 'POST'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_refresh'; + $method = 'POST'; } else { $url = '/_refresh'; - $method = empty($params['body']) ? 'GET' : 'POST'; + $method = 'POST'; } $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); $headers = [ @@ -1934,19 +2048,19 @@ public function refresh(array $params = []) /** * Reloads an index's search analyzers and their resources. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names to reload analyzers for - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * resource: string, // changed resource to reload analyzers from if applicable - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index: string|array, // (REQUIRED) A comma-separated list of index names to reload analyzers for + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * resource?: string, // changed resource to reload analyzers from if applicable + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1956,11 +2070,12 @@ public function refresh(array $params = []) * * @return Elasticsearch|Promise */ - public function reloadSearchAnalyzers(array $params = []) + public function reloadSearchAnalyzers(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']) . '/_reload_search_analyzers'; - $method = empty($params['body']) ? 'GET' : 'POST'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_reload_search_analyzers'; + $method = 'GET'; $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','resource','pretty','human','error_trace','source','filter_path']); $headers = [ @@ -1973,37 +2088,41 @@ public function reloadSearchAnalyzers(array $params = []) /** - * Resolves the specified index expressions to return information about each cluster, including the local cluster, if included. + * Resolves the specified index expressions to return information about each cluster. If no index expression is provided, this endpoint will return information about all the remote clusters that are configured on the local cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-cluster-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-cluster-api.html * * @param array{ - * name: list, // (REQUIRED) A comma-separated list of cluster:index names or wildcard expressions - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * ignore_throttled: boolean, // Whether specified concrete, expanded or aliased indices should be ignored when throttled - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // A comma-separated list of cluster:index names or wildcard expressions + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed). Only allowed when providing an index expression. + * ignore_throttled?: bool, // Whether specified concrete, expanded or aliased indices should be ignored when throttled. Only allowed when providing an index expression. + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified). Only allowed when providing an index expression. + * expand_wildcards?: string, // Whether wildcard expressions should get expanded to open or closed indices (default: open). Only allowed when providing an index expression. + * timeout?: int|string, // The maximum time to wait for remote clusters to respond + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * - * @throws MissingParameterException if a required parameter is missing * @throws NoNodeAvailableException if all the hosts are offline * @throws ClientResponseException if the status code of response is 4xx * @throws ServerResponseException if the status code of response is 5xx * * @return Elasticsearch|Promise */ - public function resolveCluster(array $params = []) + public function resolveCluster(?array $params = null) { - $this->checkRequiredParameters(['name'], $params); - $url = '/_resolve/cluster/' . $this->encode($params['name']); - $method = 'GET'; - - $url = $this->addQueryString($url, $params, ['ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); + $params = $params ?? []; + if (isset($params['name'])) { + $url = '/_resolve/cluster/' . $this->encode($this->convertValue($params['name'])); + $method = 'GET'; + } else { + $url = '/_resolve/cluster'; + $method = 'GET'; + } + $url = $this->addQueryString($url, $params, ['ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -2016,16 +2135,19 @@ public function resolveCluster(array $params = []) /** * Returns information about any matching indices, aliases, and data streams * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-index-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-index-api.html + * @group serverless * * @param array{ - * name: list, // (REQUIRED) A comma-separated list of names or wildcard expressions - * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name: string|array, // (REQUIRED) A comma-separated list of names or wildcard expressions + * expand_wildcards?: string, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2035,13 +2157,14 @@ public function resolveCluster(array $params = []) * * @return Elasticsearch|Promise */ - public function resolveIndex(array $params = []) + public function resolveIndex(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); - $url = '/_resolve/index/' . $this->encode($params['name']); + $url = '/_resolve/index/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; - $url = $this->addQueryString($url, $params, ['expand_wildcards','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['expand_wildcards','ignore_unavailable','allow_no_indices','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -2055,23 +2178,23 @@ public function resolveIndex(array $params = []) * Updates an alias to point to a new index when the existing index * is considered to be too large or too old. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html + * @group serverless * * @param array{ * alias: string, // (REQUIRED) The name of the alias to rollover - * new_index: string, // The name of the rollover index - * timeout: time, // Explicit operation timeout - * dry_run: boolean, // If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false - * master_timeout: time, // Specify timeout for connection to master - * wait_for_active_shards: string, // Set the number of active shards to wait for on the newly created rollover index before the operation returns. - * lazy: boolean, // If set to true, the rollover action will only mark a data stream to signal that it needs to be rolled over at the next write. Only allowed on data streams. - * target_failure_store: boolean, // If set to true, the rollover action will be applied on the failure store of the data stream. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The conditions that needs to be met for executing rollover + * new_index?: string, // The name of the rollover index + * timeout?: int|string, // Explicit operation timeout + * dry_run?: bool, // If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false + * master_timeout?: int|string, // Specify timeout for connection to master + * wait_for_active_shards?: string, // Set the number of active shards to wait for on the newly created rollover index before the operation returns. + * lazy?: bool, // If set to true, the rollover action will only mark a data stream to signal that it needs to be rolled over at the next write. Only allowed on data streams. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The conditions that needs to be met for executing rollover. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2081,8 +2204,9 @@ public function resolveIndex(array $params = []) * * @return Elasticsearch|Promise */ - public function rollover(array $params = []) + public function rollover(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['alias'], $params); if (isset($params['new_index'])) { $url = '/' . $this->encode($params['alias']) . '/_rollover/' . $this->encode($params['new_index']); @@ -2091,7 +2215,7 @@ public function rollover(array $params = []) $url = '/' . $this->encode($params['alias']) . '/_rollover'; $method = 'POST'; } - $url = $this->addQueryString($url, $params, ['timeout','dry_run','master_timeout','wait_for_active_shards','lazy','target_failure_store','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['timeout','dry_run','master_timeout','wait_for_active_shards','lazy','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -2105,19 +2229,18 @@ public function rollover(array $params = []) /** * Provides low-level information about segments in a Lucene index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-segments.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-segments.html * * @param array{ - * index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * verbose: boolean, // Includes detailed memory usage by Lucene. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2126,16 +2249,17 @@ public function rollover(array $params = []) * * @return Elasticsearch|Promise */ - public function segments(array $params = []) + public function segments(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_segments'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_segments'; $method = 'GET'; } else { $url = '/_segments'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','verbose','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -2148,19 +2272,19 @@ public function segments(array $params = []) /** * Provides store information for shard copies of indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html * * @param array{ - * index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * status: list, // A comma-separated list of statuses used to filter on shards to get store information for - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * status?: string|array, // A comma-separated list of statuses used to filter on shards to get store information for + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2169,10 +2293,11 @@ public function segments(array $params = []) * * @return Elasticsearch|Promise */ - public function shardStores(array $params = []) + public function shardStores(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_shard_stores'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_shard_stores'; $method = 'GET'; } else { $url = '/_shard_stores'; @@ -2191,20 +2316,20 @@ public function shardStores(array $params = []) /** * Allow to shrink an existing index into a new index with fewer primary shards. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html * * @param array{ * index: string, // (REQUIRED) The name of the source index to shrink * target: string, // (REQUIRED) The name of the target index to shrink into - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * wait_for_active_shards: string, // Set the number of active shards to wait for on the shrunken index before the operation returns. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The configuration for the target index (`settings` and `aliases`) + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * wait_for_active_shards?: string, // Set the number of active shards to wait for on the shrunken index before the operation returns. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The configuration for the target index (`settings` and `aliases`). If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2214,8 +2339,9 @@ public function shardStores(array $params = []) * * @return Elasticsearch|Promise */ - public function shrink(array $params = []) + public function shrink(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','target'], $params); $url = '/' . $this->encode($params['index']) . '/_shrink/' . $this->encode($params['target']); $method = 'PUT'; @@ -2234,20 +2360,21 @@ public function shrink(array $params = []) /** * Simulate matching the given index name against the index templates in the system * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-index.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-index.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) The name of the index (it must be a concrete index name) - * create: boolean, // Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one - * cause: string, // User defined reason for dry-run creating the new template for simulation purposes - * master_timeout: time, // Specify timeout for connection to master - * include_defaults: boolean, // Return all relevant default configurations for this index template simulation (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // New index template definition, which will be included in the simulation, as if it already exists in the system + * create?: bool, // Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one + * cause?: string, // User defined reason for dry-run creating the new template for simulation purposes + * master_timeout?: int|string, // Specify timeout for connection to master + * include_defaults?: bool, // Return all relevant default configurations for this index template simulation (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // New index template definition, which will be included in the simulation, as if it already exists in the system. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2257,8 +2384,9 @@ public function shrink(array $params = []) * * @return Elasticsearch|Promise */ - public function simulateIndexTemplate(array $params = []) + public function simulateIndexTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_index_template/_simulate_index/' . $this->encode($params['name']); $method = 'POST'; @@ -2277,20 +2405,21 @@ public function simulateIndexTemplate(array $params = []) /** * Simulate resolving the given template name or body * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-template.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-template.html + * @group serverless * * @param array{ - * name: string, // The name of the index template - * create: boolean, // Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one - * cause: string, // User defined reason for dry-run creating the new template for simulation purposes - * master_timeout: time, // Specify timeout for connection to master - * include_defaults: boolean, // Return all relevant default configurations for this template simulation (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // New index template definition to be simulated, if no index template name is specified + * name?: string, // The name of the index template + * create?: bool, // Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one + * cause?: string, // User defined reason for dry-run creating the new template for simulation purposes + * master_timeout?: int|string, // Specify timeout for connection to master + * include_defaults?: bool, // Return all relevant default configurations for this template simulation (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // New index template definition to be simulated, if no index template name is specified. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2299,8 +2428,9 @@ public function simulateIndexTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function simulateTemplate(array $params = []) + public function simulateTemplate(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { $url = '/_index_template/_simulate/' . $this->encode($params['name']); $method = 'POST'; @@ -2322,20 +2452,20 @@ public function simulateTemplate(array $params = []) /** * Allows you to split an existing index into a new index with more primary shards. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html * * @param array{ * index: string, // (REQUIRED) The name of the source index to split * target: string, // (REQUIRED) The name of the target index to split into - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * wait_for_active_shards: string, // Set the number of active shards to wait for on the shrunken index before the operation returns. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The configuration for the target index (`settings` and `aliases`) + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * wait_for_active_shards?: string, // Set the number of active shards to wait for on the shrunken index before the operation returns. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The configuration for the target index (`settings` and `aliases`). If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2345,8 +2475,9 @@ public function simulateTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function split(array $params = []) + public function split(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','target'], $params); $url = '/' . $this->encode($params['index']) . '/_split/' . $this->encode($params['target']); $method = 'PUT'; @@ -2365,25 +2496,25 @@ public function split(array $params = []) /** * Provides statistics on operations happening in an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-stats.html * * @param array{ - * metric: list, // Limit the information returned the specific metrics. - * index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * completion_fields: list, // A comma-separated list of fields for the `completion` index metric (supports wildcards) - * fielddata_fields: list, // A comma-separated list of fields for the `fielddata` index metric (supports wildcards) - * fields: list, // A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) - * groups: list, // A comma-separated list of search groups for `search` index metric - * level: enum, // Return stats aggregated at cluster, index or shard level - * include_segment_file_sizes: boolean, // Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) - * include_unloaded_segments: boolean, // If set to true segment stats will include stats for segments that are not currently loaded into memory - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * forbid_closed_indices: boolean, // If set to false stats will also collected from closed indices if explicitly specified or if expand_wildcards expands to closed indices - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * metric?: string|array, // Limit the information returned the specific metrics. + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * completion_fields?: string|array, // A comma-separated list of fields for the `completion` index metric (supports wildcards) + * fielddata_fields?: string|array, // A comma-separated list of fields for the `fielddata` index metric (supports wildcards) + * fields?: string|array, // A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + * groups?: string|array, // A comma-separated list of search groups for `search` index metric + * level?: string, // Return stats aggregated at cluster, index or shard level + * include_segment_file_sizes?: bool, // Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + * include_unloaded_segments?: bool, // If set to true segment stats will include stats for segments that are not currently loaded into memory + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * forbid_closed_indices?: bool, // If set to false stats will also collected from closed indices if explicitly specified or if expand_wildcards expands to closed indices + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2392,16 +2523,17 @@ public function split(array $params = []) * * @return Elasticsearch|Promise */ - public function stats(array $params = []) + public function stats(?array $params = null) { + $params = $params ?? []; if (isset($params['index']) && isset($params['metric'])) { - $url = '/' . $this->encode($params['index']) . '/_stats/' . $this->encode($params['metric']); + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_stats/' . $this->encode($this->convertValue($params['metric'])); $method = 'GET'; } elseif (isset($params['metric'])) { - $url = '/_stats/' . $this->encode($params['metric']); + $url = '/_stats/' . $this->encode($this->convertValue($params['metric'])); $method = 'GET'; } elseif (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_stats'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_stats'; $method = 'GET'; } else { $url = '/_stats'; @@ -2417,63 +2549,21 @@ public function stats(array $params = []) } - /** - * Unfreezes an index. When a frozen index is unfrozen, the index goes through the normal recovery process and becomes writeable again. - * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/unfreeze-index-api.html - * - * @param array{ - * index: string, // (REQUIRED) The name of the index to unfreeze - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * wait_for_active_shards: string, // Sets the number of active shards to wait for before the operation returns. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * } $params - * - * @throws MissingParameterException if a required parameter is missing - * @throws NoNodeAvailableException if all the hosts are offline - * @throws ClientResponseException if the status code of response is 4xx - * @throws ServerResponseException if the status code of response is 5xx - * - * @return Elasticsearch|Promise - */ - public function unfreeze(array $params = []) - { - $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']) . '/_unfreeze'; - $method = 'POST'; - - $url = $this->addQueryString($url, $params, ['timeout','master_timeout','ignore_unavailable','allow_no_indices','expand_wildcards','wait_for_active_shards','pretty','human','error_trace','source','filter_path']); - $headers = [ - 'Accept' => 'application/json', - ]; - $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); - $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.unfreeze'); - return $this->client->sendRequest($request); - } - - /** * Updates index aliases. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html + * @group serverless * * @param array{ - * timeout: time, // Request timeout - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The definition of `actions` to perform + * timeout?: int|string, // Request timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The definition of `actions` to perform. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2482,8 +2572,9 @@ public function unfreeze(array $params = []) * * @return Elasticsearch|Promise */ - public function updateAliases(array $params = []) + public function updateAliases(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_aliases'; $method = 'POST'; @@ -2502,28 +2593,29 @@ public function updateAliases(array $params = []) /** * Allows a user to validate a potentially expensive query without executing it. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices - * explain: boolean, // Return detailed information about the error - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * q: string, // Query in the Lucene query string syntax - * analyzer: string, // The analyzer to use for the query string - * analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false) - * default_operator: enum, // The default operator for query string query (AND or OR) - * df: string, // The field to use as default where no field prefix is given in the query string - * lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - * rewrite: boolean, // Provide a more detailed explanation showing the actual Lucene query that will be executed. - * all_shards: boolean, // Execute validation on all shards instead of one random shard per index - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The query definition specified with the Query DSL + * index?: string|array, // A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices + * explain?: bool, // Return detailed information about the error + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * q?: string, // Query in the Lucene query string syntax + * analyzer?: string, // The analyzer to use for the query string + * analyze_wildcard?: bool, // Specify whether wildcard and prefix queries should be analyzed (default: false) + * default_operator?: string, // The default operator for query string query (AND or OR) + * df?: string, // The field to use as default where no field prefix is given in the query string + * lenient?: bool, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * rewrite?: bool, // Provide a more detailed explanation showing the actual Lucene query that will be executed. + * all_shards?: bool, // Execute validation on all shards instead of one random shard per index + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The query definition specified with the Query DSL. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2532,10 +2624,11 @@ public function updateAliases(array $params = []) * * @return Elasticsearch|Promise */ - public function validateQuery(array $params = []) + public function validateQuery(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_validate/query'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_validate/query'; $method = empty($params['body']) ? 'GET' : 'POST'; } else { $url = '/_validate/query'; diff --git a/src/Endpoints/Inference.php b/src/Endpoints/Inference.php index 65837f068..ab1b067d8 100644 --- a/src/Endpoints/Inference.php +++ b/src/Endpoints/Inference.php @@ -28,22 +28,104 @@ */ class Inference extends AbstractEndpoint { + /** + * Perform chat completion inference + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/chat-completion-inference.html + * @group serverless + * + * @param array{ + * inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference payload. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function chatCompletionUnified(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['inference_id'], $params); + $url = '/_inference/chat_completion/' . $this->encode($params['inference_id']) . '/_stream'; + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'text/event-stream', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id'], $request, 'inference.chat_completion_unified'); + return $this->client->sendRequest($request); + } + + + /** + * Perform completion inference + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html + * @group serverless + * + * @param array{ + * inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference payload. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function completion(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['inference_id'], $params); + $url = '/_inference/completion/' . $this->encode($params['inference_id']); + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id'], $request, 'inference.completion'); + return $this->client->sendRequest($request); + } + + /** * Delete an inference endpoint * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html + * @group serverless * * @param array{ * inference_id: string, // (REQUIRED) The inference Id - * task_type: string, // The task type - * dry_run: boolean, // If true the endpoint will not be deleted and a list of ingest processors which reference this endpoint will be returned. - * force: boolean, // If true the endpoint will be forcefully stopped (regardless of whether or not it is referenced by any ingest processors or semantic text fields). - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * task_type?: string, // The task type + * dry_run?: bool, // If true the endpoint will not be deleted and a list of ingest processors which reference this endpoint will be returned. + * force?: bool, // If true the endpoint will be forcefully stopped (regardless of whether or not it is referenced by any ingest processors or semantic text fields). + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -53,8 +135,9 @@ class Inference extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function delete(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['inference_id'], $params); if (isset($params['task_type'])) { $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['inference_id']); @@ -76,17 +159,17 @@ public function delete(array $params = []) /** * Get an inference endpoint * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html + * @group serverless * * @param array{ - * inference_id: string, // The inference Id - * task_type: string, // The task type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * inference_id?: string, // The inference Id + * task_type?: string, // The task type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -95,8 +178,9 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function get(?array $params = null) { + $params = $params ?? []; if (isset($params['task_type']) && isset($params['inference_id'])) { $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['inference_id']); $method = 'GET'; @@ -120,18 +204,18 @@ public function get(array $params = []) /** * Perform inference * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html + * @group serverless * * @param array{ * inference_id: string, // (REQUIRED) The inference Id - * task_type: string, // The task type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The inference payload + * task_type?: string, // The task type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference payload. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -141,8 +225,9 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function inference(array $params = []) + public function inference(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['inference_id'], $params); if (isset($params['task_type'])) { $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['inference_id']); @@ -165,18 +250,18 @@ public function inference(array $params = []) /** * Configure an inference endpoint for use in the Inference API * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html + * @group serverless * * @param array{ * inference_id: string, // (REQUIRED) The inference Id - * task_type: string, // The task type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The inference endpoint's task and service settings + * task_type?: string, // The task type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -186,8 +271,9 @@ public function inference(array $params = []) * * @return Elasticsearch|Promise */ - public function put(array $params = []) + public function put(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['inference_id'], $params); if (isset($params['task_type'])) { $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['inference_id']); @@ -205,4 +291,884 @@ public function put(array $params = []) $request = $this->addOtelAttributes($params, ['inference_id', 'task_type'], $request, 'inference.put'); return $this->client->sendRequest($request); } + + + /** + * Configure an AlibabaCloud AI Search inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-alibabacloud-ai-search.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * alibabacloud_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putAlibabacloud(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','alibabacloud_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['alibabacloud_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'alibabacloud_inference_id'], $request, 'inference.put_alibabacloud'); + return $this->client->sendRequest($request); + } + + + /** + * Configure an Amazon Bedrock inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-amazon-bedrock.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * amazonbedrock_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putAmazonbedrock(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','amazonbedrock_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['amazonbedrock_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'amazonbedrock_inference_id'], $request, 'inference.put_amazonbedrock'); + return $this->client->sendRequest($request); + } + + + /** + * Configure an Anthropic inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-anthropic.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * anthropic_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putAnthropic(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','anthropic_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['anthropic_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'anthropic_inference_id'], $request, 'inference.put_anthropic'); + return $this->client->sendRequest($request); + } + + + /** + * Configure an Azure AI Studio inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-azure-ai-studio.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * azureaistudio_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putAzureaistudio(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','azureaistudio_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['azureaistudio_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'azureaistudio_inference_id'], $request, 'inference.put_azureaistudio'); + return $this->client->sendRequest($request); + } + + + /** + * Configure an Azure OpenAI inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-azure-openai.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * azureopenai_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putAzureopenai(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','azureopenai_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['azureopenai_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'azureopenai_inference_id'], $request, 'inference.put_azureopenai'); + return $this->client->sendRequest($request); + } + + + /** + * Configure a Cohere inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-cohere.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * cohere_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putCohere(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','cohere_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['cohere_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'cohere_inference_id'], $request, 'inference.put_cohere'); + return $this->client->sendRequest($request); + } + + + /** + * Configure an Elasticsearch inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-elasticsearch.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * elasticsearch_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putElasticsearch(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','elasticsearch_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['elasticsearch_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'elasticsearch_inference_id'], $request, 'inference.put_elasticsearch'); + return $this->client->sendRequest($request); + } + + + /** + * Configure an ELSER inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-elser.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * elser_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putElser(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','elser_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['elser_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'elser_inference_id'], $request, 'inference.put_elser'); + return $this->client->sendRequest($request); + } + + + /** + * Configure a Google AI Studio inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-google-ai-studio.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * googleaistudio_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putGoogleaistudio(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','googleaistudio_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['googleaistudio_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'googleaistudio_inference_id'], $request, 'inference.put_googleaistudio'); + return $this->client->sendRequest($request); + } + + + /** + * Configure a Google Vertex AI inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-google-vertex-ai.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * googlevertexai_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putGooglevertexai(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','googlevertexai_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['googlevertexai_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'googlevertexai_inference_id'], $request, 'inference.put_googlevertexai'); + return $this->client->sendRequest($request); + } + + + /** + * Configure a HuggingFace inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-hugging-face.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * huggingface_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putHuggingFace(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','huggingface_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['huggingface_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'huggingface_inference_id'], $request, 'inference.put_hugging_face'); + return $this->client->sendRequest($request); + } + + + /** + * Configure a JinaAI inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-jinaai.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * jinaai_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putJinaai(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','jinaai_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['jinaai_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'jinaai_inference_id'], $request, 'inference.put_jinaai'); + return $this->client->sendRequest($request); + } + + + /** + * Configure a Mistral inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-mistral.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * mistral_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putMistral(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','mistral_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['mistral_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'mistral_inference_id'], $request, 'inference.put_mistral'); + return $this->client->sendRequest($request); + } + + + /** + * Configure an OpenAI inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-openai.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * openai_inference_id: string, // (REQUIRED) The inference ID + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putOpenai(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','openai_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['openai_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'openai_inference_id'], $request, 'inference.put_openai'); + return $this->client->sendRequest($request); + } + + + /** + * Configure a VoyageAI inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-apis.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * voyageai_inference_id: string, // (REQUIRED) The inference ID + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putVoyageai(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','voyageai_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['voyageai_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'voyageai_inference_id'], $request, 'inference.put_voyageai'); + return $this->client->sendRequest($request); + } + + + /** + * Configure a Watsonx inference endpoint + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-watsonx-ai.html + * @group serverless + * + * @param array{ + * task_type: string, // (REQUIRED) The task type + * watsonx_inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putWatsonx(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['task_type','watsonx_inference_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['watsonx_inference_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_type', 'watsonx_inference_id'], $request, 'inference.put_watsonx'); + return $this->client->sendRequest($request); + } + + + /** + * Perform reranking inference + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html + * @group serverless + * + * @param array{ + * inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference payload. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function rerank(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['inference_id'], $params); + $url = '/_inference/rerank/' . $this->encode($params['inference_id']); + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id'], $request, 'inference.rerank'); + return $this->client->sendRequest($request); + } + + + /** + * Perform sparse embedding inference + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html + * @group serverless + * + * @param array{ + * inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference payload. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function sparseEmbedding(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['inference_id'], $params); + $url = '/_inference/sparse_embedding/' . $this->encode($params['inference_id']); + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id'], $request, 'inference.sparse_embedding'); + return $this->client->sendRequest($request); + } + + + /** + * Perform streaming completion inference + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/post-stream-inference-api.html + * + * @param array{ + * inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference payload. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function streamCompletion(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['inference_id'], $params); + $url = '/_inference/completion/' . $this->encode($params['inference_id']) . '/_stream'; + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'text/event-stream', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id'], $request, 'inference.stream_completion'); + return $this->client->sendRequest($request); + } + + + /** + * Perform text embedding inference + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html + * @group serverless + * + * @param array{ + * inference_id: string, // (REQUIRED) The inference Id + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference payload. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function textEmbedding(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['inference_id'], $params); + $url = '/_inference/text_embedding/' . $this->encode($params['inference_id']); + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id'], $request, 'inference.text_embedding'); + return $this->client->sendRequest($request); + } + + + /** + * Update inference + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-inference-api.html + * + * @param array{ + * inference_id: string, // (REQUIRED) The inference Id + * task_type?: string, // The task type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The inference endpoint's task and service settings. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function update(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['inference_id'], $params); + if (isset($params['task_type'])) { + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['inference_id']) . '/_update'; + $method = 'PUT'; + } else { + $url = '/_inference/' . $this->encode($params['inference_id']) . '/_update'; + $method = 'PUT'; + } + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id', 'task_type'], $request, 'inference.update'); + return $this->client->sendRequest($request); + } } diff --git a/src/Endpoints/Ingest.php b/src/Endpoints/Ingest.php index 0626caa35..3feb3dfad 100644 --- a/src/Endpoints/Ingest.php +++ b/src/Endpoints/Ingest.php @@ -31,15 +31,17 @@ class Ingest extends AbstractEndpoint /** * Deletes a geoip database configuration * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/TODO.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-geoip-database-api.html * * @param array{ - * id: list, // (REQUIRED) A comma-separated list of geoip database configurations to delete - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * id: string|array, // (REQUIRED) A comma-separated list of geoip database configurations to delete + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -49,13 +51,14 @@ class Ingest extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteGeoipDatabase(array $params = []) + public function deleteGeoipDatabase(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); - $url = '/_ingest/geoip/database/' . $this->encode($params['id']); + $url = '/_ingest/geoip/database/' . $this->encode($this->convertValue($params['id'])); $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -65,20 +68,61 @@ public function deleteGeoipDatabase(array $params = []) } + /** + * Deletes an ip location database configuration + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-ip-location-database-api.html + * + * @param array{ + * id: string|array, // (REQUIRED) A comma-separated list of ip location database configurations to delete + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function deleteIpLocationDatabase(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['id'], $params); + $url = '/_ingest/ip_location/database/' . $this->encode($this->convertValue($params['id'])); + $method = 'DELETE'; + + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.delete_ip_location_database'); + return $this->client->sendRequest($request); + } + + /** * Deletes a pipeline. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-pipeline-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-pipeline-api.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) Pipeline ID - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -88,8 +132,9 @@ public function deleteGeoipDatabase(array $params = []) * * @return Elasticsearch|Promise */ - public function deletePipeline(array $params = []) + public function deletePipeline(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_ingest/pipeline/' . $this->encode($params['id']); $method = 'DELETE'; @@ -107,14 +152,14 @@ public function deletePipeline(array $params = []) /** * Returns statistical information about geoip databases * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/geoip-stats-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/geoip-stats-api.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -123,8 +168,9 @@ public function deletePipeline(array $params = []) * * @return Elasticsearch|Promise */ - public function geoIpStats(array $params = []) + public function geoIpStats(?array $params = null) { + $params = $params ?? []; $url = '/_ingest/geoip/stats'; $method = 'GET'; @@ -141,15 +187,15 @@ public function geoIpStats(array $params = []) /** * Returns geoip database configuration. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/TODO.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-geoip-database-api.html * * @param array{ - * id: list, // A comma-separated list of geoip database configurations to get; use `*` to get all geoip database configurations - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * id?: string|array, // A comma-separated list of geoip database configurations to get; use `*` to get all geoip database configurations + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -158,10 +204,11 @@ public function geoIpStats(array $params = []) * * @return Elasticsearch|Promise */ - public function getGeoipDatabase(array $params = []) + public function getGeoipDatabase(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { - $url = '/_ingest/geoip/database/' . $this->encode($params['id']); + $url = '/_ingest/geoip/database/' . $this->encode($this->convertValue($params['id'])); $method = 'GET'; } else { $url = '/_ingest/geoip/database'; @@ -177,20 +224,61 @@ public function getGeoipDatabase(array $params = []) } + /** + * Returns the specified ip location database configuration + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-ip-location-database-api.html + * + * @param array{ + * id?: string|array, // A comma-separated list of ip location database configurations to get; use `*` to get all ip location database configurations + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function getIpLocationDatabase(?array $params = null) + { + $params = $params ?? []; + if (isset($params['id'])) { + $url = '/_ingest/ip_location/database/' . $this->encode($this->convertValue($params['id'])); + $method = 'GET'; + } else { + $url = '/_ingest/ip_location/database'; + $method = 'GET'; + } + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.get_ip_location_database'); + return $this->client->sendRequest($request); + } + + /** * Returns a pipeline. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-pipeline-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-pipeline-api.html + * @group serverless * * @param array{ - * id: string, // Comma separated list of pipeline ids. Wildcards supported - * summary: boolean, // Return pipelines without their definitions (default: false) - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * id?: string, // Comma separated list of pipeline ids. Wildcards supported + * summary?: bool, // Return pipelines without their definitions (default: false) + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -199,8 +287,9 @@ public function getGeoipDatabase(array $params = []) * * @return Elasticsearch|Promise */ - public function getPipeline(array $params = []) + public function getPipeline(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_ingest/pipeline/' . $this->encode($params['id']); $method = 'GET'; @@ -221,14 +310,15 @@ public function getPipeline(array $params = []) /** * Returns a list of the built-in patterns. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html#grok-processor-rest-get + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html#grok-processor-rest-get + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -237,8 +327,9 @@ public function getPipeline(array $params = []) * * @return Elasticsearch|Promise */ - public function processorGrok(array $params = []) + public function processorGrok(?array $params = null) { + $params = $params ?? []; $url = '/_ingest/processor/grok'; $method = 'GET'; @@ -255,16 +346,18 @@ public function processorGrok(array $params = []) /** * Puts the configuration for a geoip database to be downloaded * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/TODO.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/put-geoip-database-api.html * * @param array{ * id: string, // (REQUIRED) The id of the database configuration - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The database configuration definition + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The database configuration definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -274,15 +367,17 @@ public function processorGrok(array $params = []) * * @return Elasticsearch|Promise */ - public function putGeoipDatabase(array $params = []) + public function putGeoipDatabase(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','body'], $params); $url = '/_ingest/geoip/database/' . $this->encode($params['id']); $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', + 'Content-Type' => 'application/json', ]; $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.put_geoip_database'); @@ -290,22 +385,65 @@ public function putGeoipDatabase(array $params = []) } + /** + * Puts the configuration for a ip location database to be downloaded + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/put-ip-location-database-api.html + * + * @param array{ + * id: string, // (REQUIRED) The id of the database configuration + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The database configuration definition. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putIpLocationDatabase(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['id','body'], $params); + $url = '/_ingest/ip_location/database/' . $this->encode($params['id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.put_ip_location_database'); + return $this->client->sendRequest($request); + } + + /** * Creates or updates a pipeline. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) Pipeline ID - * if_version: int, // Required version for optimistic concurrency control for pipeline updates - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The ingest definition + * if_version?: int, // Required version for optimistic concurrency control for pipeline updates + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The ingest definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -315,8 +453,9 @@ public function putGeoipDatabase(array $params = []) * * @return Elasticsearch|Promise */ - public function putPipeline(array $params = []) + public function putPipeline(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','body'], $params); $url = '/_ingest/pipeline/' . $this->encode($params['id']); $method = 'PUT'; @@ -335,17 +474,18 @@ public function putPipeline(array $params = []) /** * Allows to simulate a pipeline with example documents. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html + * @group serverless * * @param array{ - * id: string, // Pipeline ID - * verbose: boolean, // Verbose mode. Display data output for each processor in executed pipeline - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The simulate definition + * id?: string, // Pipeline ID + * verbose?: bool, // Verbose mode. Display data output for each processor in executed pipeline + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The simulate definition. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -354,8 +494,9 @@ public function putPipeline(array $params = []) * * @return Elasticsearch|Promise */ - public function simulate(array $params = []) + public function simulate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['id'])) { $url = '/_ingest/pipeline/' . $this->encode($params['id']) . '/_simulate'; diff --git a/src/Endpoints/License.php b/src/Endpoints/License.php index 1c60053a4..2a96d87a3 100644 --- a/src/Endpoints/License.php +++ b/src/Endpoints/License.php @@ -31,16 +31,16 @@ class License extends AbstractEndpoint /** * Deletes licensing information for the cluster * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-license.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-license.html * * @param array{ - * master_timeout: time, // Timeout for processing on master node - * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Timeout for processing on master node + * timeout?: int|string, // Timeout for acknowledgement of update from all nodes in cluster + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -49,8 +49,9 @@ class License extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function delete(?array $params = null) { + $params = $params ?? []; $url = '/_license'; $method = 'DELETE'; @@ -67,16 +68,17 @@ public function delete(array $params = []) /** * Retrieves licensing information for the cluster * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html + * @group serverless * * @param array{ - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * accept_enterprise: boolean, // Supported for backwards compatibility with 7.x. If this param is used it must be set to true - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * accept_enterprise?: bool, // Supported for backwards compatibility with 7.x. If this param is used it must be set to true + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -85,8 +87,9 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function get(?array $params = null) { + $params = $params ?? []; $url = '/_license'; $method = 'GET'; @@ -103,14 +106,14 @@ public function get(array $params = []) /** * Retrieves information about the status of the basic license. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-basic-status.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-basic-status.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -119,8 +122,9 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function getBasicStatus(array $params = []) + public function getBasicStatus(?array $params = null) { + $params = $params ?? []; $url = '/_license/basic_status'; $method = 'GET'; @@ -137,14 +141,14 @@ public function getBasicStatus(array $params = []) /** * Retrieves information about the status of the trial license. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-trial-status.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-trial-status.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -153,8 +157,9 @@ public function getBasicStatus(array $params = []) * * @return Elasticsearch|Promise */ - public function getTrialStatus(array $params = []) + public function getTrialStatus(?array $params = null) { + $params = $params ?? []; $url = '/_license/trial_status'; $method = 'GET'; @@ -171,18 +176,18 @@ public function getTrialStatus(array $params = []) /** * Updates the license for the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-license.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/update-license.html * * @param array{ - * acknowledge: boolean, // whether the user has acknowledged acknowledge messages (default: false) - * master_timeout: time, // Timeout for processing on master node - * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // licenses to be installed + * acknowledge?: bool, // whether the user has acknowledged acknowledge messages (default: false) + * master_timeout?: int|string, // Timeout for processing on master node + * timeout?: int|string, // Timeout for acknowledgement of update from all nodes in cluster + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // licenses to be installed. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -191,8 +196,9 @@ public function getTrialStatus(array $params = []) * * @return Elasticsearch|Promise */ - public function post(array $params = []) + public function post(?array $params = null) { + $params = $params ?? []; $url = '/_license'; $method = 'PUT'; @@ -210,17 +216,17 @@ public function post(array $params = []) /** * Starts an indefinite basic license. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/start-basic.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/start-basic.html * * @param array{ - * acknowledge: boolean, // whether the user has acknowledged acknowledge messages (default: false) - * master_timeout: time, // Timeout for processing on master node - * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * acknowledge?: bool, // whether the user has acknowledged acknowledge messages (default: false) + * master_timeout?: int|string, // Timeout for processing on master node + * timeout?: int|string, // Timeout for acknowledgement of update from all nodes in cluster + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -229,8 +235,9 @@ public function post(array $params = []) * * @return Elasticsearch|Promise */ - public function postStartBasic(array $params = []) + public function postStartBasic(?array $params = null) { + $params = $params ?? []; $url = '/_license/start_basic'; $method = 'POST'; @@ -247,18 +254,17 @@ public function postStartBasic(array $params = []) /** * starts a limited time trial license. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trial.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trial.html * * @param array{ - * type: string, // The type of trial license to generate (default: "trial") - * acknowledge: boolean, // whether the user has acknowledged acknowledge messages (default: false) - * master_timeout: time, // Timeout for processing on master node - * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * type?: string, // The type of trial license to generate (default: "trial") + * acknowledge?: bool, // whether the user has acknowledged acknowledge messages (default: false) + * master_timeout?: int|string, // Timeout for processing on master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -267,12 +273,13 @@ public function postStartBasic(array $params = []) * * @return Elasticsearch|Promise */ - public function postStartTrial(array $params = []) + public function postStartTrial(?array $params = null) { + $params = $params ?? []; $url = '/_license/start_trial'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['type','acknowledge','master_timeout','timeout','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['type','acknowledge','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; diff --git a/src/Endpoints/Logstash.php b/src/Endpoints/Logstash.php index 643942d78..3e94e6fff 100644 --- a/src/Endpoints/Logstash.php +++ b/src/Endpoints/Logstash.php @@ -31,15 +31,16 @@ class Logstash extends AbstractEndpoint /** * Deletes Logstash Pipelines used by Central Management * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-delete-pipeline.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-delete-pipeline.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The ID of the Pipeline - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -49,8 +50,9 @@ class Logstash extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deletePipeline(array $params = []) + public function deletePipeline(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_logstash/pipeline/' . $this->encode($params['id']); $method = 'DELETE'; @@ -68,15 +70,16 @@ public function deletePipeline(array $params = []) /** * Retrieves Logstash Pipelines used by Central Management * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-get-pipeline.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-get-pipeline.html + * @group serverless * * @param array{ - * id: string, // A comma-separated list of Pipeline IDs - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * id?: string, // A comma-separated list of Pipeline IDs + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -85,8 +88,9 @@ public function deletePipeline(array $params = []) * * @return Elasticsearch|Promise */ - public function getPipeline(array $params = []) + public function getPipeline(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_logstash/pipeline/' . $this->encode($params['id']); $method = 'GET'; @@ -107,16 +111,17 @@ public function getPipeline(array $params = []) /** * Adds and updates Logstash Pipelines used for Central Management * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-put-pipeline.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-put-pipeline.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The ID of the Pipeline - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The Pipeline to add or update + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The Pipeline to add or update. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -126,8 +131,9 @@ public function getPipeline(array $params = []) * * @return Elasticsearch|Promise */ - public function putPipeline(array $params = []) + public function putPipeline(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','body'], $params); $url = '/_logstash/pipeline/' . $this->encode($params['id']); $method = 'PUT'; diff --git a/src/Endpoints/Migration.php b/src/Endpoints/Migration.php index a14b729a6..7e628f3e0 100644 --- a/src/Endpoints/Migration.php +++ b/src/Endpoints/Migration.php @@ -31,15 +31,15 @@ class Migration extends AbstractEndpoint /** * Retrieves information about different cluster, node, and index level settings that use deprecated features that will be removed or changed in the next major version. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html * * @param array{ - * index: string, // Index pattern - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string, // Index pattern + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -48,8 +48,9 @@ class Migration extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deprecations(array $params = []) + public function deprecations(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { $url = '/' . $this->encode($params['index']) . '/_migration/deprecations'; $method = 'GET'; @@ -70,14 +71,14 @@ public function deprecations(array $params = []) /** * Find out whether system features need to be upgraded or not * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -86,8 +87,9 @@ public function deprecations(array $params = []) * * @return Elasticsearch|Promise */ - public function getFeatureUpgradeStatus(array $params = []) + public function getFeatureUpgradeStatus(?array $params = null) { + $params = $params ?? []; $url = '/_migration/system_features'; $method = 'GET'; @@ -104,14 +106,14 @@ public function getFeatureUpgradeStatus(array $params = []) /** * Begin upgrades for system features * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -120,8 +122,9 @@ public function getFeatureUpgradeStatus(array $params = []) * * @return Elasticsearch|Promise */ - public function postFeatureUpgrade(array $params = []) + public function postFeatureUpgrade(?array $params = null) { + $params = $params ?? []; $url = '/_migration/system_features'; $method = 'POST'; diff --git a/src/Endpoints/Ml.php b/src/Endpoints/Ml.php index 3cdadf612..2d70f8dd0 100644 --- a/src/Endpoints/Ml.php +++ b/src/Endpoints/Ml.php @@ -31,15 +31,15 @@ class Ml extends AbstractEndpoint /** * Clear the cached results from a trained model deployment * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/clear-trained-model-deployment-cache.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/clear-trained-model-deployment-cache.html * * @param array{ * model_id: string, // (REQUIRED) The unique identifier of the trained model. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -49,8 +49,9 @@ class Ml extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function clearTrainedModelDeploymentCache(array $params = []) + public function clearTrainedModelDeploymentCache(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_id'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/deployment/cache/_clear'; $method = 'POST'; @@ -69,19 +70,20 @@ public function clearTrainedModelDeploymentCache(array $params = []) /** * Closes one or more anomaly detection jobs. A job can be opened and closed multiple times throughout its lifecycle. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html + * @group serverless * * @param array{ * job_id: string, // (REQUIRED) The name of the job to close - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - * force: boolean, // True if the job should be forcefully closed - * timeout: time, // Controls the time to wait until a job has closed. Default to 30 minutes - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The URL params optionally sent in the body + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + * force?: bool, // True if the job should be forcefully closed + * timeout?: int|string, // Controls the time to wait until a job has closed. Default to 30 minutes + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The URL params optionally sent in the body. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -91,8 +93,9 @@ public function clearTrainedModelDeploymentCache(array $params = []) * * @return Elasticsearch|Promise */ - public function closeJob(array $params = []) + public function closeJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_close'; $method = 'POST'; @@ -111,15 +114,16 @@ public function closeJob(array $params = []) /** * Deletes a calendar. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar.html + * @group serverless * * @param array{ * calendar_id: string, // (REQUIRED) The ID of the calendar to delete - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -129,8 +133,9 @@ public function closeJob(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteCalendar(array $params = []) + public function deleteCalendar(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['calendar_id'], $params); $url = '/_ml/calendars/' . $this->encode($params['calendar_id']); $method = 'DELETE'; @@ -148,16 +153,17 @@ public function deleteCalendar(array $params = []) /** * Deletes scheduled events from a calendar. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-event.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-event.html + * @group serverless * * @param array{ * calendar_id: string, // (REQUIRED) The ID of the calendar to modify * event_id: string, // (REQUIRED) The ID of the event to remove from the calendar - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -167,8 +173,9 @@ public function deleteCalendar(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteCalendarEvent(array $params = []) + public function deleteCalendarEvent(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['calendar_id','event_id'], $params); $url = '/_ml/calendars/' . $this->encode($params['calendar_id']) . '/events/' . $this->encode($params['event_id']); $method = 'DELETE'; @@ -186,16 +193,17 @@ public function deleteCalendarEvent(array $params = []) /** * Deletes anomaly detection jobs from a calendar. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-job.html + * @group serverless * * @param array{ * calendar_id: string, // (REQUIRED) The ID of the calendar to modify * job_id: string, // (REQUIRED) The ID of the job to remove from the calendar - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -205,8 +213,9 @@ public function deleteCalendarEvent(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteCalendarJob(array $params = []) + public function deleteCalendarJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['calendar_id','job_id'], $params); $url = '/_ml/calendars/' . $this->encode($params['calendar_id']) . '/jobs/' . $this->encode($params['job_id']); $method = 'DELETE'; @@ -224,17 +233,18 @@ public function deleteCalendarJob(array $params = []) /** * Deletes an existing data frame analytics job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-dfanalytics.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-dfanalytics.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The ID of the data frame analytics to delete - * force: boolean, // True if the job should be forcefully deleted - * timeout: time, // Controls the time to wait until a job is deleted. Defaults to 1 minute - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * force?: bool, // True if the job should be forcefully deleted + * timeout?: int|string, // Controls the time to wait until a job is deleted. Defaults to 1 minute + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -244,8 +254,9 @@ public function deleteCalendarJob(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteDataFrameAnalytics(array $params = []) + public function deleteDataFrameAnalytics(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_ml/data_frame/analytics/' . $this->encode($params['id']); $method = 'DELETE'; @@ -263,16 +274,17 @@ public function deleteDataFrameAnalytics(array $params = []) /** * Deletes an existing datafeed. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html + * @group serverless * * @param array{ * datafeed_id: string, // (REQUIRED) The ID of the datafeed to delete - * force: boolean, // True if the datafeed should be forcefully deleted - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * force?: bool, // True if the datafeed should be forcefully deleted + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -282,8 +294,9 @@ public function deleteDataFrameAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteDatafeed(array $params = []) + public function deleteDatafeed(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['datafeed_id'], $params); $url = '/_ml/datafeeds/' . $this->encode($params['datafeed_id']); $method = 'DELETE'; @@ -301,18 +314,18 @@ public function deleteDatafeed(array $params = []) /** * Deletes expired and unused machine learning data. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-expired-data.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-expired-data.html * * @param array{ - * job_id: string, // The ID of the job(s) to perform expired data hygiene for - * requests_per_second: number, // The desired requests per second for the deletion processes. - * timeout: time, // How long can the underlying delete processes run until they are canceled - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // deleting expired data parameters + * job_id?: string, // The ID of the job(s) to perform expired data hygiene for + * requests_per_second?: int, // The desired requests per second for the deletion processes. + * timeout?: int|string, // How long can the underlying delete processes run until they are canceled + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // deleting expired data parameters. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -321,8 +334,9 @@ public function deleteDatafeed(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteExpiredData(array $params = []) + public function deleteExpiredData(?array $params = null) { + $params = $params ?? []; if (isset($params['job_id'])) { $url = '/_ml/_delete_expired_data/' . $this->encode($params['job_id']); $method = 'DELETE'; @@ -344,15 +358,16 @@ public function deleteExpiredData(array $params = []) /** * Deletes a filter. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-filter.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-filter.html + * @group serverless * * @param array{ * filter_id: string, // (REQUIRED) The ID of the filter to delete - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -362,8 +377,9 @@ public function deleteExpiredData(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteFilter(array $params = []) + public function deleteFilter(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['filter_id'], $params); $url = '/_ml/filters/' . $this->encode($params['filter_id']); $method = 'DELETE'; @@ -381,18 +397,18 @@ public function deleteFilter(array $params = []) /** * Deletes forecasts from a machine learning job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html * * @param array{ * job_id: string, // (REQUIRED) The ID of the job from which to delete forecasts - * forecast_id: string, // The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all` - * allow_no_forecasts: boolean, // Whether to ignore if `_all` matches no forecasts - * timeout: time, // Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * forecast_id?: string, // The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all` + * allow_no_forecasts?: bool, // Whether to ignore if `_all` matches no forecasts + * timeout?: int|string, // Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -402,8 +418,9 @@ public function deleteFilter(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteForecast(array $params = []) + public function deleteForecast(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); if (isset($params['forecast_id'])) { $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_forecast/' . $this->encode($params['forecast_id']); @@ -425,18 +442,19 @@ public function deleteForecast(array $params = []) /** * Deletes an existing anomaly detection job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html + * @group serverless * * @param array{ * job_id: string, // (REQUIRED) The ID of the job to delete - * force: boolean, // True if the job should be forcefully deleted - * wait_for_completion: boolean, // Should this request wait until the operation has completed before returning - * delete_user_annotations: boolean, // Should annotations added by the user be deleted - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * force?: bool, // True if the job should be forcefully deleted + * wait_for_completion?: bool, // Should this request wait until the operation has completed before returning + * delete_user_annotations?: bool, // Should annotations added by the user be deleted + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -446,8 +464,9 @@ public function deleteForecast(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteJob(array $params = []) + public function deleteJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']); $method = 'DELETE'; @@ -465,16 +484,16 @@ public function deleteJob(array $params = []) /** * Deletes an existing model snapshot. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html * * @param array{ * job_id: string, // (REQUIRED) The ID of the job to fetch * snapshot_id: string, // (REQUIRED) The ID of the snapshot to delete - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -484,8 +503,9 @@ public function deleteJob(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteModelSnapshot(array $params = []) + public function deleteModelSnapshot(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id','snapshot_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/model_snapshots/' . $this->encode($params['snapshot_id']); $method = 'DELETE'; @@ -503,17 +523,18 @@ public function deleteModelSnapshot(array $params = []) /** * Deletes an existing trained inference model that is currently not referenced by an ingest pipeline. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models.html + * @group serverless * * @param array{ * model_id: string, // (REQUIRED) The ID of the trained model to delete - * timeout: time, // Controls the amount of time to wait for the model to be deleted. - * force: boolean, // True if the model should be forcefully deleted - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // Controls the amount of time to wait for the model to be deleted. + * force?: bool, // True if the model should be forcefully deleted + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -523,8 +544,9 @@ public function deleteModelSnapshot(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteTrainedModel(array $params = []) + public function deleteTrainedModel(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_id'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']); $method = 'DELETE'; @@ -542,16 +564,17 @@ public function deleteTrainedModel(array $params = []) /** * Deletes a model alias that refers to the trained model * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models-aliases.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models-aliases.html + * @group serverless * * @param array{ * model_alias: string, // (REQUIRED) The trained model alias to delete * model_id: string, // (REQUIRED) The trained model where the model alias is assigned - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -561,8 +584,9 @@ public function deleteTrainedModel(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteTrainedModelAlias(array $params = []) + public function deleteTrainedModelAlias(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_alias','model_id'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/model_aliases/' . $this->encode($params['model_alias']); $method = 'DELETE'; @@ -581,15 +605,16 @@ public function deleteTrainedModelAlias(array $params = []) /** * Estimates the model memory * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The analysis config, plus cardinality estimates for fields it references + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The analysis config, plus cardinality estimates for fields it references. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -598,8 +623,9 @@ public function deleteTrainedModelAlias(array $params = []) * * @return Elasticsearch|Promise */ - public function estimateModelMemory(array $params = []) + public function estimateModelMemory(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_ml/anomaly_detectors/_estimate_model_memory'; $method = 'POST'; @@ -618,15 +644,16 @@ public function estimateModelMemory(array $params = []) /** * Evaluates the data frame analytics for an annotated index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/evaluate-dfanalytics.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/evaluate-dfanalytics.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The evaluation definition + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The evaluation definition. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -635,8 +662,9 @@ public function estimateModelMemory(array $params = []) * * @return Elasticsearch|Promise */ - public function evaluateDataFrame(array $params = []) + public function evaluateDataFrame(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_ml/data_frame/_evaluate'; $method = 'POST'; @@ -655,16 +683,16 @@ public function evaluateDataFrame(array $params = []) /** * Explains a data frame analytics config. * - * @see http://www.elastic.co/guide/en/elasticsearch/reference/current/explain-dfanalytics.html + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/explain-dfanalytics.html * * @param array{ - * id: string, // The ID of the data frame analytics to explain - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The data frame analytics config to explain + * id?: string, // The ID of the data frame analytics to explain + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The data frame analytics config to explain. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -673,8 +701,9 @@ public function evaluateDataFrame(array $params = []) * * @return Elasticsearch|Promise */ - public function explainDataFrameAnalytics(array $params = []) + public function explainDataFrameAnalytics(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_ml/data_frame/analytics/' . $this->encode($params['id']) . '/_explain'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -696,21 +725,22 @@ public function explainDataFrameAnalytics(array $params = []) /** * Forces any buffered data to be processed by the job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html + * @group serverless * * @param array{ * job_id: string, // (REQUIRED) The name of the job to flush - * calc_interim: boolean, // Calculates interim results for the most recent bucket or all buckets within the latency period - * start: string, // When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results - * end: string, // When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results - * advance_time: string, // Advances time to the given value generating results and updating the model for the advanced interval - * skip_time: string, // Skips time to the given value without generating results or updating the model for the skipped interval - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Flush parameters + * calc_interim?: bool, // Calculates interim results for the most recent bucket or all buckets within the latency period + * start?: string, // When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results + * end?: string, // When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results + * advance_time?: string, // Advances time to the given value generating results and updating the model for the advanced interval + * skip_time?: string, // Skips time to the given value without generating results or updating the model for the skipped interval + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Flush parameters. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -720,8 +750,9 @@ public function explainDataFrameAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function flushJob(array $params = []) + public function flushJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_flush'; $method = 'POST'; @@ -740,19 +771,19 @@ public function flushJob(array $params = []) /** * Predicts the future behavior of a time series by using its historical behavior. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-forecast.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-forecast.html * * @param array{ * job_id: string, // (REQUIRED) The ID of the job to forecast for - * duration: time, // The duration of the forecast - * expires_in: time, // The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. - * max_model_memory: string, // The max memory able to be used by the forecast. Default is 20mb. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Query parameters can be specified in the body + * duration?: int|string, // The duration of the forecast + * expires_in?: int|string, // The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. + * max_model_memory?: string, // The max memory able to be used by the forecast. Default is 20mb. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Query parameters can be specified in the body. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -762,8 +793,9 @@ public function flushJob(array $params = []) * * @return Elasticsearch|Promise */ - public function forecast(array $params = []) + public function forecast(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_forecast'; $method = 'POST'; @@ -782,26 +814,26 @@ public function forecast(array $params = []) /** * Retrieves anomaly detection job results for one or more buckets. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html * * @param array{ * job_id: string, // (REQUIRED) ID of the job to get bucket results from - * timestamp: string, // The timestamp of the desired single bucket result - * expand: boolean, // Include anomaly records - * exclude_interim: boolean, // Exclude interim results - * from: int, // skips a number of buckets - * size: int, // specifies a max number of buckets to get - * start: string, // Start time filter for buckets - * end: string, // End time filter for buckets - * anomaly_score: double, // Filter for the most anomalous buckets - * sort: string, // Sort buckets by a particular field - * desc: boolean, // Set the sort direction - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Bucket selection details if not provided in URI + * timestamp?: string, // The timestamp of the desired single bucket result + * expand?: bool, // Include anomaly records + * exclude_interim?: bool, // Exclude interim results + * from?: int, // skips a number of buckets + * size?: int, // specifies a max number of buckets to get + * start?: string, // Start time filter for buckets + * end?: string, // End time filter for buckets + * anomaly_score?: float, // Filter for the most anomalous buckets + * sort?: string, // Sort buckets by a particular field + * desc?: bool, // Set the sort direction + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Bucket selection details if not provided in URI. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -811,8 +843,9 @@ public function forecast(array $params = []) * * @return Elasticsearch|Promise */ - public function getBuckets(array $params = []) + public function getBuckets(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); if (isset($params['timestamp'])) { $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/buckets/' . $this->encode($params['timestamp']); @@ -835,20 +868,21 @@ public function getBuckets(array $params = []) /** * Retrieves information about the scheduled events in calendars. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar-event.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar-event.html + * @group serverless * * @param array{ * calendar_id: string, // (REQUIRED) The ID of the calendar containing the events - * job_id: string, // Get events for the job. When this option is used calendar_id must be '_all' - * start: string, // Get events after this time - * end: date, // Get events before this time - * from: int, // Skips a number of events - * size: int, // Specifies a max number of events to get - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * job_id?: string, // Get events for the job. When this option is used calendar_id must be '_all' + * start?: string, // Get events after this time + * end?: string, // Get events before this time + * from?: int, // Skips a number of events + * size?: int, // Specifies a max number of events to get + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -858,8 +892,9 @@ public function getBuckets(array $params = []) * * @return Elasticsearch|Promise */ - public function getCalendarEvents(array $params = []) + public function getCalendarEvents(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['calendar_id'], $params); $url = '/_ml/calendars/' . $this->encode($params['calendar_id']) . '/events'; $method = 'GET'; @@ -877,18 +912,19 @@ public function getCalendarEvents(array $params = []) /** * Retrieves configuration information for calendars. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar.html + * @group serverless * * @param array{ - * calendar_id: string, // The ID of the calendar to fetch - * from: int, // skips a number of calendars - * size: int, // specifies a max number of calendars to get - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The from and size parameters optionally sent in the body + * calendar_id?: string, // The ID of the calendar to fetch + * from?: int, // skips a number of calendars + * size?: int, // specifies a max number of calendars to get + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The from and size parameters optionally sent in the body. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -897,8 +933,9 @@ public function getCalendarEvents(array $params = []) * * @return Elasticsearch|Promise */ - public function getCalendars(array $params = []) + public function getCalendars(?array $params = null) { + $params = $params ?? []; if (isset($params['calendar_id'])) { $url = '/_ml/calendars/' . $this->encode($params['calendar_id']); $method = empty($params['body']) ? 'GET' : 'POST'; @@ -920,20 +957,20 @@ public function getCalendars(array $params = []) /** * Retrieves anomaly detection job results for one or more categories. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html * * @param array{ * job_id: string, // (REQUIRED) The name of the job - * category_id: long, // The identifier of the category definition of interest - * from: int, // skips a number of categories - * size: int, // specifies a max number of categories to get - * partition_field_value: string, // Specifies the partition to retrieve categories for. This is optional, and should never be used for jobs where per-partition categorization is disabled. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Category selection details if not provided in URI + * category_id?: int, // The identifier of the category definition of interest + * from?: int, // skips a number of categories + * size?: int, // specifies a max number of categories to get + * partition_field_value?: string, // Specifies the partition to retrieve categories for. This is optional, and should never be used for jobs where per-partition categorization is disabled. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Category selection details if not provided in URI. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -943,8 +980,9 @@ public function getCalendars(array $params = []) * * @return Elasticsearch|Promise */ - public function getCategories(array $params = []) + public function getCategories(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); if (isset($params['category_id'])) { $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/categories/' . $this->encode($params['category_id']); @@ -967,19 +1005,20 @@ public function getCategories(array $params = []) /** * Retrieves configuration information for data frame analytics jobs. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics.html + * @group serverless * * @param array{ - * id: string, // The ID of the data frame analytics to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) - * from: int, // skips a number of analytics - * size: int, // specifies a max number of analytics to get - * exclude_generated: boolean, // Omits fields that are illegal to set on data frame analytics PUT - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * id?: string, // The ID of the data frame analytics to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) + * from?: int, // skips a number of analytics + * size?: int, // specifies a max number of analytics to get + * exclude_generated?: bool, // Omits fields that are illegal to set on data frame analytics PUT + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -988,8 +1027,9 @@ public function getCategories(array $params = []) * * @return Elasticsearch|Promise */ - public function getDataFrameAnalytics(array $params = []) + public function getDataFrameAnalytics(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_ml/data_frame/analytics/' . $this->encode($params['id']); $method = 'GET'; @@ -1010,19 +1050,20 @@ public function getDataFrameAnalytics(array $params = []) /** * Retrieves usage information for data frame analytics jobs. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics-stats.html + * @group serverless * * @param array{ - * id: string, // The ID of the data frame analytics stats to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) - * from: int, // skips a number of analytics - * size: int, // specifies a max number of analytics to get - * verbose: boolean, // whether the stats response should be verbose - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * id?: string, // The ID of the data frame analytics stats to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) + * from?: int, // skips a number of analytics + * size?: int, // specifies a max number of analytics to get + * verbose?: bool, // whether the stats response should be verbose + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1031,8 +1072,9 @@ public function getDataFrameAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function getDataFrameAnalyticsStats(array $params = []) + public function getDataFrameAnalyticsStats(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_ml/data_frame/analytics/' . $this->encode($params['id']) . '/_stats'; $method = 'GET'; @@ -1053,16 +1095,17 @@ public function getDataFrameAnalyticsStats(array $params = []) /** * Retrieves usage information for datafeeds. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html + * @group serverless * * @param array{ - * datafeed_id: string, // The ID of the datafeeds stats to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * datafeed_id?: string, // The ID of the datafeeds stats to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1071,8 +1114,9 @@ public function getDataFrameAnalyticsStats(array $params = []) * * @return Elasticsearch|Promise */ - public function getDatafeedStats(array $params = []) + public function getDatafeedStats(?array $params = null) { + $params = $params ?? []; if (isset($params['datafeed_id'])) { $url = '/_ml/datafeeds/' . $this->encode($params['datafeed_id']) . '/_stats'; $method = 'GET'; @@ -1093,17 +1137,18 @@ public function getDatafeedStats(array $params = []) /** * Retrieves configuration information for datafeeds. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html + * @group serverless * * @param array{ - * datafeed_id: string, // The ID of the datafeeds to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - * exclude_generated: boolean, // Omits fields that are illegal to set on datafeed PUT - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * datafeed_id?: string, // The ID of the datafeeds to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + * exclude_generated?: bool, // Omits fields that are illegal to set on datafeed PUT + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1112,8 +1157,9 @@ public function getDatafeedStats(array $params = []) * * @return Elasticsearch|Promise */ - public function getDatafeeds(array $params = []) + public function getDatafeeds(?array $params = null) { + $params = $params ?? []; if (isset($params['datafeed_id'])) { $url = '/_ml/datafeeds/' . $this->encode($params['datafeed_id']); $method = 'GET'; @@ -1134,17 +1180,18 @@ public function getDatafeeds(array $params = []) /** * Retrieves filters. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-filter.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-filter.html + * @group serverless * * @param array{ - * filter_id: string, // The ID of the filter to fetch - * from: int, // skips a number of filters - * size: int, // specifies a max number of filters to get - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * filter_id?: string, // The ID of the filter to fetch + * from?: int, // skips a number of filters + * size?: int, // specifies a max number of filters to get + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1153,8 +1200,9 @@ public function getDatafeeds(array $params = []) * * @return Elasticsearch|Promise */ - public function getFilters(array $params = []) + public function getFilters(?array $params = null) { + $params = $params ?? []; if (isset($params['filter_id'])) { $url = '/_ml/filters/' . $this->encode($params['filter_id']); $method = 'GET'; @@ -1175,24 +1223,24 @@ public function getFilters(array $params = []) /** * Retrieves anomaly detection job results for one or more influencers. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html * * @param array{ * job_id: string, // (REQUIRED) Identifier for the anomaly detection job - * exclude_interim: boolean, // Exclude interim results - * from: int, // skips a number of influencers - * size: int, // specifies a max number of influencers to get - * start: string, // start timestamp for the requested influencers - * end: string, // end timestamp for the requested influencers - * influencer_score: double, // influencer score threshold for the requested influencers - * sort: string, // sort field for the requested influencers - * desc: boolean, // whether the results should be sorted in decending order - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Influencer selection criteria + * exclude_interim?: bool, // Exclude interim results + * from?: int, // skips a number of influencers + * size?: int, // specifies a max number of influencers to get + * start?: string, // start timestamp for the requested influencers + * end?: string, // end timestamp for the requested influencers + * influencer_score?: float, // influencer score threshold for the requested influencers + * sort?: string, // sort field for the requested influencers + * desc?: bool, // whether the results should be sorted in decending order + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Influencer selection criteria. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1202,8 +1250,9 @@ public function getFilters(array $params = []) * * @return Elasticsearch|Promise */ - public function getInfluencers(array $params = []) + public function getInfluencers(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/influencers'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1222,16 +1271,17 @@ public function getInfluencers(array $params = []) /** * Retrieves usage information for anomaly detection jobs. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html + * @group serverless * * @param array{ - * job_id: string, // The ID of the jobs stats to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * job_id?: string, // The ID of the jobs stats to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1240,8 +1290,9 @@ public function getInfluencers(array $params = []) * * @return Elasticsearch|Promise */ - public function getJobStats(array $params = []) + public function getJobStats(?array $params = null) { + $params = $params ?? []; if (isset($params['job_id'])) { $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_stats'; $method = 'GET'; @@ -1262,17 +1313,18 @@ public function getJobStats(array $params = []) /** * Retrieves configuration information for anomaly detection jobs. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html + * @group serverless * * @param array{ - * job_id: string, // The ID of the jobs to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - * exclude_generated: boolean, // Omits fields that are illegal to set on job PUT - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * job_id?: string, // The ID of the jobs to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + * exclude_generated?: bool, // Omits fields that are illegal to set on job PUT + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1281,8 +1333,9 @@ public function getJobStats(array $params = []) * * @return Elasticsearch|Promise */ - public function getJobs(array $params = []) + public function getJobs(?array $params = null) { + $params = $params ?? []; if (isset($params['job_id'])) { $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']); $method = 'GET'; @@ -1303,17 +1356,17 @@ public function getJobs(array $params = []) /** * Returns information on how ML is using memory. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-ml-memory.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-ml-memory.html * * @param array{ - * node_id: string, // Specifies the node or nodes to retrieve stats for. - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id?: string, // Specifies the node or nodes to retrieve stats for. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1322,8 +1375,9 @@ public function getJobs(array $params = []) * * @return Elasticsearch|Promise */ - public function getMemoryStats(array $params = []) + public function getMemoryStats(?array $params = null) { + $params = $params ?? []; if (isset($params['node_id'])) { $url = '/_ml/memory/' . $this->encode($params['node_id']) . '/_stats'; $method = 'GET'; @@ -1344,17 +1398,17 @@ public function getMemoryStats(array $params = []) /** * Gets stats for anomaly detection job model snapshot upgrades that are in progress. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-model-snapshot-upgrade-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-model-snapshot-upgrade-stats.html * * @param array{ * job_id: string, // (REQUIRED) The ID of the job. May be a wildcard, comma separated list or `_all`. * snapshot_id: string, // (REQUIRED) The ID of the snapshot. May be a wildcard, comma separated list or `_all`. - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no jobs or no snapshots. (This includes the `_all` string.) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no jobs or no snapshots. (This includes the `_all` string.) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1364,8 +1418,9 @@ public function getMemoryStats(array $params = []) * * @return Elasticsearch|Promise */ - public function getModelSnapshotUpgradeStats(array $params = []) + public function getModelSnapshotUpgradeStats(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id','snapshot_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/model_snapshots/' . $this->encode($params['snapshot_id']) . '/_upgrade/_stats'; $method = 'GET'; @@ -1383,23 +1438,23 @@ public function getModelSnapshotUpgradeStats(array $params = []) /** * Retrieves information about model snapshots. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html * * @param array{ * job_id: string, // (REQUIRED) The ID of the job to fetch - * snapshot_id: string, // The ID of the snapshot to fetch - * from: int, // Skips a number of documents - * size: int, // The default number of documents returned in queries as a string. - * start: date, // The filter 'start' query parameter - * end: date, // The filter 'end' query parameter - * sort: string, // Name of the field to sort on - * desc: boolean, // True if the results should be sorted in descending order - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Model snapshot selection criteria + * snapshot_id?: string, // The ID of the snapshot to fetch + * from?: int, // Skips a number of documents + * size?: int, // The default number of documents returned in queries as a string. + * start?: string, // The filter 'start' query parameter + * end?: string, // The filter 'end' query parameter + * sort?: string, // Name of the field to sort on + * desc?: bool, // True if the results should be sorted in descending order + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Model snapshot selection criteria. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1409,8 +1464,9 @@ public function getModelSnapshotUpgradeStats(array $params = []) * * @return Elasticsearch|Promise */ - public function getModelSnapshots(array $params = []) + public function getModelSnapshots(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); if (isset($params['snapshot_id'])) { $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/model_snapshots/' . $this->encode($params['snapshot_id']); @@ -1433,23 +1489,24 @@ public function getModelSnapshots(array $params = []) /** * Retrieves overall bucket results that summarize the bucket results of multiple anomaly detection jobs. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html + * @group serverless * * @param array{ * job_id: string, // (REQUIRED) The job IDs for which to calculate overall bucket results - * top_n: int, // The number of top job bucket scores to be used in the overall_score calculation - * bucket_span: string, // The span of the overall buckets. Defaults to the longest job bucket_span - * overall_score: double, // Returns overall buckets with overall scores higher than this value - * exclude_interim: boolean, // If true overall buckets that include interim buckets will be excluded - * start: string, // Returns overall buckets with timestamps after this time - * end: string, // Returns overall buckets with timestamps earlier than this time - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Overall bucket selection details if not provided in URI + * top_n?: int, // The number of top job bucket scores to be used in the overall_score calculation + * bucket_span?: string, // The span of the overall buckets. Defaults to the longest job bucket_span + * overall_score?: float, // Returns overall buckets with overall scores higher than this value + * exclude_interim?: bool, // If true overall buckets that include interim buckets will be excluded + * start?: string, // Returns overall buckets with timestamps after this time + * end?: string, // Returns overall buckets with timestamps earlier than this time + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Overall bucket selection details if not provided in URI. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1459,8 +1516,9 @@ public function getModelSnapshots(array $params = []) * * @return Elasticsearch|Promise */ - public function getOverallBuckets(array $params = []) + public function getOverallBuckets(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/overall_buckets'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1479,24 +1537,24 @@ public function getOverallBuckets(array $params = []) /** * Retrieves anomaly records for an anomaly detection job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html * * @param array{ * job_id: string, // (REQUIRED) The ID of the job - * exclude_interim: boolean, // Exclude interim results - * from: int, // skips a number of records - * size: int, // specifies a max number of records to get - * start: string, // Start time filter for records - * end: string, // End time filter for records - * record_score: double, // Returns records with anomaly scores greater or equal than this value - * sort: string, // Sort records by a particular field - * desc: boolean, // Set the sort direction - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Record selection criteria + * exclude_interim?: bool, // Exclude interim results + * from?: int, // skips a number of records + * size?: int, // specifies a max number of records to get + * start?: string, // Start time filter for records + * end?: string, // End time filter for records + * record_score?: float, // Returns records with anomaly scores greater or equal than this value + * sort?: string, // Sort records by a particular field + * desc?: bool, // Set the sort direction + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Record selection criteria. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1506,8 +1564,9 @@ public function getOverallBuckets(array $params = []) * * @return Elasticsearch|Promise */ - public function getRecords(array $params = []) + public function getRecords(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/records'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1526,23 +1585,23 @@ public function getRecords(array $params = []) /** * Retrieves configuration information for a trained inference model. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models.html + * @group serverless * * @param array{ - * model_id: string, // The ID of the trained models to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) - * include: string, // A comma-separate list of fields to optionally include. Valid options are 'definition' and 'total_feature_importance'. Default is none. - * include_model_definition: boolean, // Should the full model definition be included in the results. These definitions can be large. So be cautious when including them. Defaults to false. - * decompress_definition: boolean, // Should the model definition be decompressed into valid JSON or returned in a custom compressed format. Defaults to true. - * from: int, // skips a number of trained models - * size: int, // specifies a max number of trained models to get - * tags: list, // A comma-separated list of tags that the model must have. - * exclude_generated: boolean, // Omits fields that are illegal to set on model PUT - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * model_id?: string, // The ID of the trained models to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + * include?: string, // A comma-separate list of fields to optionally include. Valid options are 'definition' and 'total_feature_importance'. Default is none. + * decompress_definition?: bool, // Should the model definition be decompressed into valid JSON or returned in a custom compressed format. Defaults to true. + * from?: int, // skips a number of trained models + * size?: int, // specifies a max number of trained models to get + * tags?: string|array, // A comma-separated list of tags that the model must have. + * exclude_generated?: bool, // Omits fields that are illegal to set on model PUT + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1551,8 +1610,9 @@ public function getRecords(array $params = []) * * @return Elasticsearch|Promise */ - public function getTrainedModels(array $params = []) + public function getTrainedModels(?array $params = null) { + $params = $params ?? []; if (isset($params['model_id'])) { $url = '/_ml/trained_models/' . $this->encode($params['model_id']); $method = 'GET'; @@ -1560,7 +1620,7 @@ public function getTrainedModels(array $params = []) $url = '/_ml/trained_models'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['allow_no_match','include','include_model_definition','decompress_definition','from','size','tags','exclude_generated','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['allow_no_match','include','decompress_definition','from','size','tags','exclude_generated','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -1573,18 +1633,19 @@ public function getTrainedModels(array $params = []) /** * Retrieves usage information for trained inference models. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html + * @group serverless * * @param array{ - * model_id: string, // The ID of the trained models stats to fetch - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) - * from: int, // skips a number of trained models - * size: int, // specifies a max number of trained models to get - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * model_id?: string, // The ID of the trained models stats to fetch + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + * from?: int, // skips a number of trained models + * size?: int, // specifies a max number of trained models to get + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1593,8 +1654,9 @@ public function getTrainedModels(array $params = []) * * @return Elasticsearch|Promise */ - public function getTrainedModelsStats(array $params = []) + public function getTrainedModelsStats(?array $params = null) { + $params = $params ?? []; if (isset($params['model_id'])) { $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/_stats'; $method = 'GET'; @@ -1615,17 +1677,18 @@ public function getTrainedModelsStats(array $params = []) /** * Evaluate a trained model. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/infer-trained-model.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/infer-trained-model.html + * @group serverless * * @param array{ * model_id: string, // (REQUIRED) The unique identifier of the trained model. - * timeout: time, // Controls the amount of time to wait for inference results. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The docs to apply inference on and inference configuration overrides + * timeout?: int|string, // Controls the amount of time to wait for inference results. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The docs to apply inference on and inference configuration overrides. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1635,8 +1698,9 @@ public function getTrainedModelsStats(array $params = []) * * @return Elasticsearch|Promise */ - public function inferTrainedModel(array $params = []) + public function inferTrainedModel(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_id','body'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/_infer'; $method = 'POST'; @@ -1655,14 +1719,14 @@ public function inferTrainedModel(array $params = []) /** * Returns defaults and limits used by machine learning. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-ml-info.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-ml-info.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1671,8 +1735,9 @@ public function inferTrainedModel(array $params = []) * * @return Elasticsearch|Promise */ - public function info(array $params = []) + public function info(?array $params = null) { + $params = $params ?? []; $url = '/_ml/info'; $method = 'GET'; @@ -1689,16 +1754,17 @@ public function info(array $params = []) /** * Opens one or more anomaly detection jobs. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html + * @group serverless * * @param array{ * job_id: string, // (REQUIRED) The ID of the job to open - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Query parameters can be specified in the body + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Query parameters can be specified in the body. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1708,8 +1774,9 @@ public function info(array $params = []) * * @return Elasticsearch|Promise */ - public function openJob(array $params = []) + public function openJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_open'; $method = 'POST'; @@ -1728,16 +1795,17 @@ public function openJob(array $params = []) /** * Posts scheduled events in a calendar. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-calendar-event.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-calendar-event.html + * @group serverless * * @param array{ * calendar_id: string, // (REQUIRED) The ID of the calendar to modify - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) A list of events + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) A list of events. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1747,8 +1815,9 @@ public function openJob(array $params = []) * * @return Elasticsearch|Promise */ - public function postCalendarEvents(array $params = []) + public function postCalendarEvents(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['calendar_id','body'], $params); $url = '/_ml/calendars/' . $this->encode($params['calendar_id']) . '/events'; $method = 'POST'; @@ -1767,18 +1836,18 @@ public function postCalendarEvents(array $params = []) /** * Sends data to an anomaly detection job for analysis. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html * * @param array{ * job_id: string, // (REQUIRED) The name of the job receiving the data - * reset_start: string, // Optional parameter to specify the start of the bucket resetting range - * reset_end: string, // Optional parameter to specify the end of the bucket resetting range - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The data to process + * reset_start?: string, // Optional parameter to specify the start of the bucket resetting range + * reset_end?: string, // Optional parameter to specify the end of the bucket resetting range + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The data to process. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1788,8 +1857,9 @@ public function postCalendarEvents(array $params = []) * * @return Elasticsearch|Promise */ - public function postData(array $params = []) + public function postData(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id','body'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_data'; $method = 'POST'; @@ -1797,7 +1867,7 @@ public function postData(array $params = []) $url = $this->addQueryString($url, $params, ['reset_start','reset_end','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', - 'Content-Type' => isset($params['body']) && (is_string($params['body']) || $this->isAssociativeArray($params['body'])) ? 'application/json' : 'application/x-ndjson', + 'Content-Type' => is_string($params['body']) || $this->isAssociativeArray($params['body']) ? 'application/json' : 'application/x-ndjson', ]; $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.post_data'); @@ -1808,16 +1878,17 @@ public function postData(array $params = []) /** * Previews that will be analyzed given a data frame analytics config. * - * @see http://www.elastic.co/guide/en/elasticsearch/reference/current/preview-dfanalytics.html + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/preview-dfanalytics.html + * @group serverless * * @param array{ - * id: string, // The ID of the data frame analytics to preview - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The data frame analytics config to preview + * id?: string, // The ID of the data frame analytics to preview + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The data frame analytics config to preview. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1826,8 +1897,9 @@ public function postData(array $params = []) * * @return Elasticsearch|Promise */ - public function previewDataFrameAnalytics(array $params = []) + public function previewDataFrameAnalytics(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_ml/data_frame/analytics/' . $this->encode($params['id']) . '/_preview'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1849,18 +1921,19 @@ public function previewDataFrameAnalytics(array $params = []) /** * Previews a datafeed. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html + * @group serverless * * @param array{ - * datafeed_id: string, // The ID of the datafeed to preview - * start: string, // The start time from where the datafeed preview should begin - * end: string, // The end time when the datafeed preview should stop - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The datafeed config and job config with which to execute the preview + * datafeed_id?: string, // The ID of the datafeed to preview + * start?: string, // The start time from where the datafeed preview should begin + * end?: string, // The end time when the datafeed preview should stop + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The datafeed config and job config with which to execute the preview. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1869,8 +1942,9 @@ public function previewDataFrameAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function previewDatafeed(array $params = []) + public function previewDatafeed(?array $params = null) { + $params = $params ?? []; if (isset($params['datafeed_id'])) { $url = '/_ml/datafeeds/' . $this->encode($params['datafeed_id']) . '/_preview'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1892,16 +1966,17 @@ public function previewDatafeed(array $params = []) /** * Instantiates a calendar. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar.html + * @group serverless * * @param array{ * calendar_id: string, // (REQUIRED) The ID of the calendar to create - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The calendar details + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The calendar details. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1911,8 +1986,9 @@ public function previewDatafeed(array $params = []) * * @return Elasticsearch|Promise */ - public function putCalendar(array $params = []) + public function putCalendar(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['calendar_id'], $params); $url = '/_ml/calendars/' . $this->encode($params['calendar_id']); $method = 'PUT'; @@ -1931,16 +2007,17 @@ public function putCalendar(array $params = []) /** * Adds an anomaly detection job to a calendar. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar-job.html + * @group serverless * * @param array{ * calendar_id: string, // (REQUIRED) The ID of the calendar to modify * job_id: string, // (REQUIRED) The ID of the job to add to the calendar - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1950,8 +2027,9 @@ public function putCalendar(array $params = []) * * @return Elasticsearch|Promise */ - public function putCalendarJob(array $params = []) + public function putCalendarJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['calendar_id','job_id'], $params); $url = '/_ml/calendars/' . $this->encode($params['calendar_id']) . '/jobs/' . $this->encode($params['job_id']); $method = 'PUT'; @@ -1969,16 +2047,17 @@ public function putCalendarJob(array $params = []) /** * Instantiates a data frame analytics job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-dfanalytics.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/put-dfanalytics.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The ID of the data frame analytics to create - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The data frame analytics configuration + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The data frame analytics configuration. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1988,8 +2067,9 @@ public function putCalendarJob(array $params = []) * * @return Elasticsearch|Promise */ - public function putDataFrameAnalytics(array $params = []) + public function putDataFrameAnalytics(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','body'], $params); $url = '/_ml/data_frame/analytics/' . $this->encode($params['id']); $method = 'PUT'; @@ -2008,20 +2088,21 @@ public function putDataFrameAnalytics(array $params = []) /** * Instantiates a datafeed. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html + * @group serverless * * @param array{ * datafeed_id: string, // (REQUIRED) The ID of the datafeed to create - * ignore_unavailable: boolean, // Ignore unavailable indexes (default: false) - * allow_no_indices: boolean, // Ignore if the source indices expressions resolves to no concrete indices (default: true) - * ignore_throttled: boolean, // Ignore indices that are marked as throttled (default: true) - * expand_wildcards: enum, // Whether source index expressions should get expanded to open or closed indices (default: open) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The datafeed config + * ignore_unavailable?: bool, // Ignore unavailable indexes (default: false) + * allow_no_indices?: bool, // Ignore if the source indices expressions resolves to no concrete indices (default: true) + * ignore_throttled?: bool, // Ignore indices that are marked as throttled (default: true) + * expand_wildcards?: string, // Whether source index expressions should get expanded to open or closed indices (default: open) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The datafeed config. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2031,8 +2112,9 @@ public function putDataFrameAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function putDatafeed(array $params = []) + public function putDatafeed(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['datafeed_id','body'], $params); $url = '/_ml/datafeeds/' . $this->encode($params['datafeed_id']); $method = 'PUT'; @@ -2051,16 +2133,17 @@ public function putDatafeed(array $params = []) /** * Instantiates a filter. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-filter.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-filter.html + * @group serverless * * @param array{ * filter_id: string, // (REQUIRED) The ID of the filter to create - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The filter details + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The filter details. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2070,8 +2153,9 @@ public function putDatafeed(array $params = []) * * @return Elasticsearch|Promise */ - public function putFilter(array $params = []) + public function putFilter(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['filter_id','body'], $params); $url = '/_ml/filters/' . $this->encode($params['filter_id']); $method = 'PUT'; @@ -2090,20 +2174,21 @@ public function putFilter(array $params = []) /** * Instantiates an anomaly detection job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html + * @group serverless * * @param array{ * job_id: string, // (REQUIRED) The ID of the job to create - * ignore_unavailable: boolean, // Ignore unavailable indexes (default: false). Only set if datafeed_config is provided. - * allow_no_indices: boolean, // Ignore if the source indices expressions resolves to no concrete indices (default: true). Only set if datafeed_config is provided. - * ignore_throttled: boolean, // Ignore indices that are marked as throttled (default: true). Only set if datafeed_config is provided. - * expand_wildcards: enum, // Whether source index expressions should get expanded to open or closed indices (default: open). Only set if datafeed_config is provided. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The job + * ignore_unavailable?: bool, // Ignore unavailable indexes (default: false). Only set if datafeed_config is provided. + * allow_no_indices?: bool, // Ignore if the source indices expressions resolves to no concrete indices (default: true). Only set if datafeed_config is provided. + * ignore_throttled?: bool, // Ignore indices that are marked as throttled (default: true). Only set if datafeed_config is provided. + * expand_wildcards?: string, // Whether source index expressions should get expanded to open or closed indices (default: open). Only set if datafeed_config is provided. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The job. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2113,8 +2198,9 @@ public function putFilter(array $params = []) * * @return Elasticsearch|Promise */ - public function putJob(array $params = []) + public function putJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id','body'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']); $method = 'PUT'; @@ -2133,18 +2219,19 @@ public function putJob(array $params = []) /** * Creates an inference trained model. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-models.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-models.html + * @group serverless * * @param array{ * model_id: string, // (REQUIRED) The ID of the trained models to store - * defer_definition_decompression: boolean, // If set to `true` and a `compressed_definition` is provided, the request defers definition decompression and skips relevant validations. - * wait_for_completion: boolean, // Whether to wait for all child operations(e.g. model download) to complete, before returning or not. Default to false - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The trained model configuration + * defer_definition_decompression?: bool, // If set to `true` and a `compressed_definition` is provided, the request defers definition decompression and skips relevant validations. + * wait_for_completion?: bool, // Whether to wait for all child operations(e.g. model download) to complete, before returning or not. Default to false + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The trained model configuration. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2154,8 +2241,9 @@ public function putJob(array $params = []) * * @return Elasticsearch|Promise */ - public function putTrainedModel(array $params = []) + public function putTrainedModel(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_id','body'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']); $method = 'PUT'; @@ -2174,17 +2262,18 @@ public function putTrainedModel(array $params = []) /** * Creates a new model alias (or reassigns an existing one) to refer to the trained model * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-models-aliases.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-models-aliases.html + * @group serverless * * @param array{ * model_alias: string, // (REQUIRED) The trained model alias to update * model_id: string, // (REQUIRED) The trained model where the model alias should be assigned - * reassign: boolean, // If the model_alias already exists and points to a separate model_id, this parameter must be true. Defaults to false. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * reassign?: bool, // If the model_alias already exists and points to a separate model_id, this parameter must be true. Defaults to false. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2194,8 +2283,9 @@ public function putTrainedModel(array $params = []) * * @return Elasticsearch|Promise */ - public function putTrainedModelAlias(array $params = []) + public function putTrainedModelAlias(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_alias','model_id'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/model_aliases/' . $this->encode($params['model_alias']); $method = 'PUT'; @@ -2214,17 +2304,18 @@ public function putTrainedModelAlias(array $params = []) /** * Creates part of a trained model definition * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-model-definition-part.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-model-definition-part.html + * @group serverless * * @param array{ * model_id: string, // (REQUIRED) The ID of the trained model for this definition part * part: int, // (REQUIRED) The part number - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The trained model definition part + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The trained model definition part. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2234,8 +2325,9 @@ public function putTrainedModelAlias(array $params = []) * * @return Elasticsearch|Promise */ - public function putTrainedModelDefinitionPart(array $params = []) + public function putTrainedModelDefinitionPart(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_id','part','body'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/definition/' . $this->encode($params['part']); $method = 'PUT'; @@ -2254,16 +2346,17 @@ public function putTrainedModelDefinitionPart(array $params = []) /** * Creates a trained model vocabulary * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-model-vocabulary.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-model-vocabulary.html + * @group serverless * * @param array{ * model_id: string, // (REQUIRED) The ID of the trained model for this vocabulary - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The trained model vocabulary + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The trained model vocabulary. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2273,8 +2366,9 @@ public function putTrainedModelDefinitionPart(array $params = []) * * @return Elasticsearch|Promise */ - public function putTrainedModelVocabulary(array $params = []) + public function putTrainedModelVocabulary(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_id','body'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/vocabulary'; $method = 'PUT'; @@ -2293,17 +2387,18 @@ public function putTrainedModelVocabulary(array $params = []) /** * Resets an existing anomaly detection job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-reset-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-reset-job.html + * @group serverless * * @param array{ * job_id: string, // (REQUIRED) The ID of the job to reset - * wait_for_completion: boolean, // Should this request wait until the operation has completed before returning - * delete_user_annotations: boolean, // Should annotations added by the user be deleted - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * wait_for_completion?: bool, // Should this request wait until the operation has completed before returning + * delete_user_annotations?: bool, // Should annotations added by the user be deleted + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2313,8 +2408,9 @@ public function putTrainedModelVocabulary(array $params = []) * * @return Elasticsearch|Promise */ - public function resetJob(array $params = []) + public function resetJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_reset'; $method = 'POST'; @@ -2332,18 +2428,18 @@ public function resetJob(array $params = []) /** * Reverts to a specific snapshot. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html * * @param array{ * job_id: string, // (REQUIRED) The ID of the job to fetch * snapshot_id: string, // (REQUIRED) The ID of the snapshot to revert to - * delete_intervening_results: boolean, // Should we reset the results back to the time of the snapshot? - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Reversion options + * delete_intervening_results?: bool, // Should we reset the results back to the time of the snapshot? + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Reversion options. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2353,8 +2449,9 @@ public function resetJob(array $params = []) * * @return Elasticsearch|Promise */ - public function revertModelSnapshot(array $params = []) + public function revertModelSnapshot(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id','snapshot_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/model_snapshots/' . $this->encode($params['snapshot_id']) . '/_revert'; $method = 'POST'; @@ -2373,16 +2470,16 @@ public function revertModelSnapshot(array $params = []) /** * Sets a cluster wide upgrade_mode setting that prepares machine learning indices for an upgrade. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html * * @param array{ - * enabled: boolean, // Whether to enable upgrade_mode ML setting or not. Defaults to false. - * timeout: time, // Controls the time to wait before action times out. Defaults to 30 seconds - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * enabled?: bool, // Whether to enable upgrade_mode ML setting or not. Defaults to false. + * timeout?: int|string, // Controls the time to wait before action times out. Defaults to 30 seconds + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2391,8 +2488,9 @@ public function revertModelSnapshot(array $params = []) * * @return Elasticsearch|Promise */ - public function setUpgradeMode(array $params = []) + public function setUpgradeMode(?array $params = null) { + $params = $params ?? []; $url = '/_ml/set_upgrade_mode'; $method = 'POST'; @@ -2409,17 +2507,18 @@ public function setUpgradeMode(array $params = []) /** * Starts a data frame analytics job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/start-dfanalytics.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/start-dfanalytics.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The ID of the data frame analytics to start - * timeout: time, // Controls the time to wait until the task has started. Defaults to 20 seconds - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The start data frame analytics parameters + * timeout?: int|string, // Controls the time to wait until the task has started. Defaults to 20 seconds + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The start data frame analytics parameters. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2429,8 +2528,9 @@ public function setUpgradeMode(array $params = []) * * @return Elasticsearch|Promise */ - public function startDataFrameAnalytics(array $params = []) + public function startDataFrameAnalytics(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_ml/data_frame/analytics/' . $this->encode($params['id']) . '/_start'; $method = 'POST'; @@ -2449,19 +2549,20 @@ public function startDataFrameAnalytics(array $params = []) /** * Starts one or more datafeeds. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html + * @group serverless * * @param array{ * datafeed_id: string, // (REQUIRED) The ID of the datafeed to start - * start: string, // The start time from where the datafeed should begin - * end: string, // The end time when the datafeed should stop. When not set, the datafeed continues in real time - * timeout: time, // Controls the time to wait until a datafeed has started. Default to 20 seconds - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The start datafeed parameters + * start?: string, // The start time from where the datafeed should begin + * end?: string, // The end time when the datafeed should stop. When not set, the datafeed continues in real time + * timeout?: int|string, // Controls the time to wait until a datafeed has started. Default to 20 seconds + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The start datafeed parameters. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2471,8 +2572,9 @@ public function startDataFrameAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function startDatafeed(array $params = []) + public function startDatafeed(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['datafeed_id'], $params); $url = '/_ml/datafeeds/' . $this->encode($params['datafeed_id']) . '/_start'; $method = 'POST'; @@ -2491,23 +2593,25 @@ public function startDatafeed(array $params = []) /** * Start a trained model deployment. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trained-model-deployment.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trained-model-deployment.html + * @group serverless * * @param array{ * model_id: string, // (REQUIRED) The unique identifier of the trained model. - * cache_size: string, // A byte-size value for configuring the inference cache size. For example, 20mb. - * deployment_id: string, // The Id of the new deployment. Defaults to the model_id if not set. - * number_of_allocations: int, // The total number of allocations this model is assigned across machine learning nodes. - * threads_per_allocation: int, // The number of threads used by each model allocation during inference. - * priority: string, // The deployment priority. - * queue_capacity: int, // Controls how many inference requests are allowed in the queue at a time. - * timeout: time, // Controls the amount of time to wait for the model to deploy. - * wait_for: string, // The allocation status for which to wait - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * cache_size?: string, // A byte-size value for configuring the inference cache size. For example, 20mb. + * deployment_id?: string, // The Id of the new deployment. Defaults to the model_id if not set. + * number_of_allocations?: int, // The total number of allocations this model is assigned across machine learning nodes. + * threads_per_allocation?: int, // The number of threads used by each model allocation during inference. + * priority?: string, // The deployment priority. + * queue_capacity?: int, // Controls how many inference requests are allowed in the queue at a time. + * timeout?: int|string, // Controls the amount of time to wait for the model to deploy. + * wait_for?: string, // The allocation status for which to wait + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The settings for the trained model deployment. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2517,8 +2621,9 @@ public function startDatafeed(array $params = []) * * @return Elasticsearch|Promise */ - public function startTrainedModelDeployment(array $params = []) + public function startTrainedModelDeployment(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_id'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/deployment/_start'; $method = 'POST'; @@ -2537,19 +2642,20 @@ public function startTrainedModelDeployment(array $params = []) /** * Stops one or more data frame analytics jobs. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-dfanalytics.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-dfanalytics.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The ID of the data frame analytics to stop - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) - * force: boolean, // True if the data frame analytics should be forcefully stopped - * timeout: time, // Controls the time to wait until the task has stopped. Defaults to 20 seconds - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The stop data frame analytics parameters + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) + * force?: bool, // True if the data frame analytics should be forcefully stopped + * timeout?: int|string, // Controls the time to wait until the task has stopped. Defaults to 20 seconds + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The stop data frame analytics parameters. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2559,8 +2665,9 @@ public function startTrainedModelDeployment(array $params = []) * * @return Elasticsearch|Promise */ - public function stopDataFrameAnalytics(array $params = []) + public function stopDataFrameAnalytics(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_ml/data_frame/analytics/' . $this->encode($params['id']) . '/_stop'; $method = 'POST'; @@ -2579,20 +2686,20 @@ public function stopDataFrameAnalytics(array $params = []) /** * Stops one or more datafeeds. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html + * @group serverless * * @param array{ * datafeed_id: string, // (REQUIRED) The ID of the datafeed to stop - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - * allow_no_datafeeds: boolean, // Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - * force: boolean, // True if the datafeed should be forcefully stopped. - * timeout: time, // Controls the time to wait until a datafeed has stopped. Default to 20 seconds - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The URL params optionally sent in the body + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + * force?: bool, // True if the datafeed should be forcefully stopped. + * timeout?: int|string, // Controls the time to wait until a datafeed has stopped. Default to 20 seconds + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The URL params optionally sent in the body. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2602,13 +2709,14 @@ public function stopDataFrameAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function stopDatafeed(array $params = []) + public function stopDatafeed(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['datafeed_id'], $params); $url = '/_ml/datafeeds/' . $this->encode($params['datafeed_id']) . '/_stop'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['allow_no_match','allow_no_datafeeds','force','timeout','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['allow_no_match','force','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -2622,18 +2730,19 @@ public function stopDatafeed(array $params = []) /** * Stop a trained model deployment. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/stop-trained-model-deployment.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/stop-trained-model-deployment.html + * @group serverless * * @param array{ * model_id: string, // (REQUIRED) The unique identifier of the trained model. - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no deployments. (This includes `_all` string or when no deployments have been specified) - * force: boolean, // True if the deployment should be forcefully stopped - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The stop deployment parameters + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no deployments. (This includes `_all` string or when no deployments have been specified) + * force?: bool, // True if the deployment should be forcefully stopped + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The stop deployment parameters. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2643,8 +2752,9 @@ public function stopDatafeed(array $params = []) * * @return Elasticsearch|Promise */ - public function stopTrainedModelDeployment(array $params = []) + public function stopTrainedModelDeployment(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_id'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/deployment/_stop'; $method = 'POST'; @@ -2663,16 +2773,17 @@ public function stopTrainedModelDeployment(array $params = []) /** * Updates certain properties of a data frame analytics job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/update-dfanalytics.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/update-dfanalytics.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The ID of the data frame analytics to update - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The data frame analytics settings to update + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The data frame analytics settings to update. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2682,8 +2793,9 @@ public function stopTrainedModelDeployment(array $params = []) * * @return Elasticsearch|Promise */ - public function updateDataFrameAnalytics(array $params = []) + public function updateDataFrameAnalytics(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','body'], $params); $url = '/_ml/data_frame/analytics/' . $this->encode($params['id']) . '/_update'; $method = 'POST'; @@ -2702,20 +2814,21 @@ public function updateDataFrameAnalytics(array $params = []) /** * Updates certain properties of a datafeed. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html + * @group serverless * * @param array{ * datafeed_id: string, // (REQUIRED) The ID of the datafeed to update - * ignore_unavailable: boolean, // Ignore unavailable indexes (default: false) - * allow_no_indices: boolean, // Ignore if the source indices expressions resolves to no concrete indices (default: true) - * ignore_throttled: boolean, // Ignore indices that are marked as throttled (default: true) - * expand_wildcards: enum, // Whether source index expressions should get expanded to open or closed indices (default: open) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The datafeed update settings + * ignore_unavailable?: bool, // Ignore unavailable indexes (default: false) + * allow_no_indices?: bool, // Ignore if the source indices expressions resolves to no concrete indices (default: true) + * ignore_throttled?: bool, // Ignore indices that are marked as throttled (default: true) + * expand_wildcards?: string, // Whether source index expressions should get expanded to open or closed indices (default: open) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The datafeed update settings. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2725,8 +2838,9 @@ public function updateDataFrameAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function updateDatafeed(array $params = []) + public function updateDatafeed(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['datafeed_id','body'], $params); $url = '/_ml/datafeeds/' . $this->encode($params['datafeed_id']) . '/_update'; $method = 'POST'; @@ -2745,16 +2859,17 @@ public function updateDatafeed(array $params = []) /** * Updates the description of a filter, adds items, or removes items. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-filter.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-filter.html + * @group serverless * * @param array{ * filter_id: string, // (REQUIRED) The ID of the filter to update - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The filter update + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The filter update. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2764,8 +2879,9 @@ public function updateDatafeed(array $params = []) * * @return Elasticsearch|Promise */ - public function updateFilter(array $params = []) + public function updateFilter(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['filter_id','body'], $params); $url = '/_ml/filters/' . $this->encode($params['filter_id']) . '/_update'; $method = 'POST'; @@ -2784,16 +2900,17 @@ public function updateFilter(array $params = []) /** * Updates certain properties of an anomaly detection job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html + * @group serverless * * @param array{ * job_id: string, // (REQUIRED) The ID of the job to create - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The job update settings + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The job update settings. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2803,8 +2920,9 @@ public function updateFilter(array $params = []) * * @return Elasticsearch|Promise */ - public function updateJob(array $params = []) + public function updateJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id','body'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_update'; $method = 'POST'; @@ -2823,17 +2941,17 @@ public function updateJob(array $params = []) /** * Updates certain properties of a snapshot. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html * * @param array{ * job_id: string, // (REQUIRED) The ID of the job to fetch * snapshot_id: string, // (REQUIRED) The ID of the snapshot to update - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The model snapshot properties to update + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The model snapshot properties to update. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2843,8 +2961,9 @@ public function updateJob(array $params = []) * * @return Elasticsearch|Promise */ - public function updateModelSnapshot(array $params = []) + public function updateModelSnapshot(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id','snapshot_id','body'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/model_snapshots/' . $this->encode($params['snapshot_id']) . '/_update'; $method = 'POST'; @@ -2863,17 +2982,18 @@ public function updateModelSnapshot(array $params = []) /** * Updates certain properties of trained model deployment. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/update-trained-model-deployment.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/update-trained-model-deployment.html + * @group serverless * * @param array{ * model_id: string, // (REQUIRED) The unique identifier of the trained model. - * number_of_allocations: int, // Update the model deployment to this number of allocations. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The updated trained model deployment settings + * number_of_allocations?: int, // Update the model deployment to this number of allocations. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The updated trained model deployment settings. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2883,8 +3003,9 @@ public function updateModelSnapshot(array $params = []) * * @return Elasticsearch|Promise */ - public function updateTrainedModelDeployment(array $params = []) + public function updateTrainedModelDeployment(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['model_id'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/deployment/_update'; $method = 'POST'; @@ -2903,18 +3024,18 @@ public function updateTrainedModelDeployment(array $params = []) /** * Upgrades a given job snapshot to the current major version. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-upgrade-job-model-snapshot.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-upgrade-job-model-snapshot.html * * @param array{ * job_id: string, // (REQUIRED) The ID of the job * snapshot_id: string, // (REQUIRED) The ID of the snapshot - * timeout: time, // How long should the API wait for the job to be opened and the old snapshot to be loaded. - * wait_for_completion: boolean, // Should the request wait until the task is complete before responding to the caller. Default is false. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // How long should the API wait for the job to be opened and the old snapshot to be loaded. + * wait_for_completion?: bool, // Should the request wait until the task is complete before responding to the caller. Default is false. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2924,8 +3045,9 @@ public function updateTrainedModelDeployment(array $params = []) * * @return Elasticsearch|Promise */ - public function upgradeJobSnapshot(array $params = []) + public function upgradeJobSnapshot(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['job_id','snapshot_id'], $params); $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/model_snapshots/' . $this->encode($params['snapshot_id']) . '/_upgrade'; $method = 'POST'; @@ -2943,15 +3065,15 @@ public function upgradeJobSnapshot(array $params = []) /** * Validates an anomaly detection job. * - * @see https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html + * @link https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The job config + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The job config. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2960,8 +3082,9 @@ public function upgradeJobSnapshot(array $params = []) * * @return Elasticsearch|Promise */ - public function validate(array $params = []) + public function validate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_ml/anomaly_detectors/_validate'; $method = 'POST'; @@ -2980,15 +3103,15 @@ public function validate(array $params = []) /** * Validates an anomaly detection detector. * - * @see https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html + * @link https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The detector + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The detector. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2997,8 +3120,9 @@ public function validate(array $params = []) * * @return Elasticsearch|Promise */ - public function validateDetector(array $params = []) + public function validateDetector(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_ml/anomaly_detectors/_validate/detector'; $method = 'POST'; diff --git a/src/Endpoints/Monitoring.php b/src/Endpoints/Monitoring.php index c642629a5..25fa3a0e4 100644 --- a/src/Endpoints/Monitoring.php +++ b/src/Endpoints/Monitoring.php @@ -31,19 +31,19 @@ class Monitoring extends AbstractEndpoint /** * Used by the monitoring features to send monitoring data. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/monitor-elasticsearch-cluster.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/monitor-elasticsearch-cluster.html * * @param array{ - * type: string, // Default document type for items which don't provide one - * system_id: string, // Identifier of the monitored system - * system_api_version: string, // API Version of the monitored system - * interval: string, // Collection interval (e.g., '10s' or '10000ms') of the payload - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The operation definition and data (action-data pairs), separated by newlines + * type?: string, // Default document type for items which don't provide one + * system_id?: string, // Identifier of the monitored system + * system_api_version?: string, // API Version of the monitored system + * interval?: string, // Collection interval (e.g., '10s' or '10000ms') of the payload + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The operation definition and data (action-data pairs), separated by newlines. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -52,8 +52,9 @@ class Monitoring extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function bulk(array $params = []) + public function bulk(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['type'])) { $url = '/_monitoring/' . $this->encode($params['type']) . '/bulk'; diff --git a/src/Endpoints/Nodes.php b/src/Endpoints/Nodes.php index a4f3a93fa..703c46e98 100644 --- a/src/Endpoints/Nodes.php +++ b/src/Endpoints/Nodes.php @@ -31,17 +31,17 @@ class Nodes extends AbstractEndpoint /** * Removes the archived repositories metering information present in the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-repositories-metering-archive-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-repositories-metering-archive-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * node_id: list, // (REQUIRED) Comma-separated list of node IDs or names used to limit returned information. - * max_archive_version: long, // (REQUIRED) Specifies the maximum archive_version to be cleared from the archive. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id: string|array, // (REQUIRED) Comma-separated list of node IDs or names used to limit returned information. + * max_archive_version: int, // (REQUIRED) Specifies the maximum archive_version to be cleared from the archive. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -51,10 +51,11 @@ class Nodes extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function clearRepositoriesMeteringArchive(array $params = []) + public function clearRepositoriesMeteringArchive(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['node_id','max_archive_version'], $params); - $url = '/_nodes/' . $this->encode($params['node_id']) . '/_repositories_metering/' . $this->encode($params['max_archive_version']); + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])) . '/_repositories_metering/' . $this->encode($params['max_archive_version']); $method = 'DELETE'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); @@ -70,16 +71,16 @@ public function clearRepositoriesMeteringArchive(array $params = []) /** * Returns cluster repositories metering information. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-repositories-metering-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-repositories-metering-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * node_id: list, // (REQUIRED) A comma-separated list of node IDs or names to limit the returned information. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id: string|array, // (REQUIRED) A comma-separated list of node IDs or names to limit the returned information. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -89,10 +90,11 @@ public function clearRepositoriesMeteringArchive(array $params = []) * * @return Elasticsearch|Promise */ - public function getRepositoriesMeteringInfo(array $params = []) + public function getRepositoriesMeteringInfo(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['node_id'], $params); - $url = '/_nodes/' . $this->encode($params['node_id']) . '/_repositories_metering'; + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])) . '/_repositories_metering'; $method = 'GET'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); @@ -108,22 +110,22 @@ public function getRepositoriesMeteringInfo(array $params = []) /** * Returns information about hot threads on each node in the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html * * @param array{ - * node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - * interval: time, // The interval for the second sampling of threads - * snapshots: number, // Number of samples of thread stacktrace (default: 10) - * threads: number, // Specify the number of threads to provide information for (default: 3) - * ignore_idle_threads: boolean, // Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) - * type: enum, // The type to sample (default: cpu) - * sort: enum, // The sort order for 'cpu' type (default: total) - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id?: string|array, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * interval?: int|string, // The interval for the second sampling of threads + * snapshots?: int, // Number of samples of thread stacktrace (default: 10) + * threads?: int, // Specify the number of threads to provide information for (default: 3) + * ignore_idle_threads?: bool, // Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) + * type?: string, // The type to sample (default: cpu) + * sort?: string, // The sort order for 'cpu' type (default: total) + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -132,10 +134,11 @@ public function getRepositoriesMeteringInfo(array $params = []) * * @return Elasticsearch|Promise */ - public function hotThreads(array $params = []) + public function hotThreads(?array $params = null) { + $params = $params ?? []; if (isset($params['node_id'])) { - $url = '/_nodes/' . $this->encode($params['node_id']) . '/hot_threads'; + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])) . '/hot_threads'; $method = 'GET'; } else { $url = '/_nodes/hot_threads'; @@ -154,18 +157,18 @@ public function hotThreads(array $params = []) /** * Returns information about nodes in the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html * * @param array{ - * node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - * metric: list, // A comma-separated list of metrics you wish returned. Use `_all` to retrieve all metrics and `_none` to retrieve the node identity without any additional metrics. - * flat_settings: boolean, // Return settings in flat format (default: false) - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id?: string|array, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * metric?: string|array, // A comma-separated list of metrics you wish returned. Use `_all` to retrieve all metrics and `_none` to retrieve the node identity without any additional metrics. + * flat_settings?: bool, // Return settings in flat format (default: false) + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -174,16 +177,17 @@ public function hotThreads(array $params = []) * * @return Elasticsearch|Promise */ - public function info(array $params = []) + public function info(?array $params = null) { + $params = $params ?? []; if (isset($params['node_id']) && isset($params['metric'])) { - $url = '/_nodes/' . $this->encode($params['node_id']) . '/' . $this->encode($params['metric']); + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])) . '/' . $this->encode($this->convertValue($params['metric'])); $method = 'GET'; } elseif (isset($params['node_id'])) { - $url = '/_nodes/' . $this->encode($params['node_id']); + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])); $method = 'GET'; } elseif (isset($params['metric'])) { - $url = '/_nodes/' . $this->encode($params['metric']); + $url = '/_nodes/' . $this->encode($this->convertValue($params['metric'])); $method = 'GET'; } else { $url = '/_nodes'; @@ -202,17 +206,17 @@ public function info(array $params = []) /** * Reloads secure settings. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings * * @param array{ - * node_id: list, // A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // An object containing the password for the elasticsearch keystore + * node_id?: string|array, // A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // An object containing the password for the elasticsearch keystore. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -221,10 +225,11 @@ public function info(array $params = []) * * @return Elasticsearch|Promise */ - public function reloadSecureSettings(array $params = []) + public function reloadSecureSettings(?array $params = null) { + $params = $params ?? []; if (isset($params['node_id'])) { - $url = '/_nodes/' . $this->encode($params['node_id']) . '/reload_secure_settings'; + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])) . '/reload_secure_settings'; $method = 'POST'; } else { $url = '/_nodes/reload_secure_settings'; @@ -244,26 +249,26 @@ public function reloadSecureSettings(array $params = []) /** * Returns statistical information about nodes in the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html * * @param array{ - * node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - * metric: list, // Limit the information returned to the specified metrics - * index_metric: list, // Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. - * completion_fields: list, // A comma-separated list of fields for the `completion` index metric (supports wildcards) - * fielddata_fields: list, // A comma-separated list of fields for the `fielddata` index metric (supports wildcards) - * fields: list, // A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) - * groups: boolean, // A comma-separated list of search groups for `search` index metric - * level: enum, // Return indices stats aggregated at index, node or shard level - * types: list, // A comma-separated list of document types for the `indexing` index metric - * timeout: time, // Explicit operation timeout - * include_segment_file_sizes: boolean, // Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) - * include_unloaded_segments: boolean, // If set to true segment stats will include stats for segments that are not currently loaded into memory - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id?: string|array, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * metric?: string|array, // Limit the information returned to the specified metrics + * index_metric?: string|array, // Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. + * completion_fields?: string|array, // A comma-separated list of fields for the `completion` index metric (supports wildcards) + * fielddata_fields?: string|array, // A comma-separated list of fields for the `fielddata` index metric (supports wildcards) + * fields?: string|array, // A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + * groups?: bool, // A comma-separated list of search groups for `search` index metric + * level?: string, // Return indices stats aggregated at index, node or shard level + * types?: string|array, // A comma-separated list of document types for the `indexing` index metric + * timeout?: int|string, // Explicit operation timeout + * include_segment_file_sizes?: bool, // Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + * include_unloaded_segments?: bool, // If set to true segment stats will include stats for segments that are not currently loaded into memory + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -272,22 +277,23 @@ public function reloadSecureSettings(array $params = []) * * @return Elasticsearch|Promise */ - public function stats(array $params = []) + public function stats(?array $params = null) { + $params = $params ?? []; if (isset($params['metric']) && isset($params['index_metric']) && isset($params['node_id'])) { - $url = '/_nodes/' . $this->encode($params['node_id']) . '/stats/' . $this->encode($params['metric']) . '/' . $this->encode($params['index_metric']); + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])) . '/stats/' . $this->encode($this->convertValue($params['metric'])) . '/' . $this->encode($this->convertValue($params['index_metric'])); $method = 'GET'; } elseif (isset($params['metric']) && isset($params['node_id'])) { - $url = '/_nodes/' . $this->encode($params['node_id']) . '/stats/' . $this->encode($params['metric']); + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])) . '/stats/' . $this->encode($this->convertValue($params['metric'])); $method = 'GET'; } elseif (isset($params['metric']) && isset($params['index_metric'])) { - $url = '/_nodes/stats/' . $this->encode($params['metric']) . '/' . $this->encode($params['index_metric']); + $url = '/_nodes/stats/' . $this->encode($this->convertValue($params['metric'])) . '/' . $this->encode($this->convertValue($params['index_metric'])); $method = 'GET'; } elseif (isset($params['node_id'])) { - $url = '/_nodes/' . $this->encode($params['node_id']) . '/stats'; + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])) . '/stats'; $method = 'GET'; } elseif (isset($params['metric'])) { - $url = '/_nodes/stats/' . $this->encode($params['metric']); + $url = '/_nodes/stats/' . $this->encode($this->convertValue($params['metric'])); $method = 'GET'; } else { $url = '/_nodes/stats'; @@ -306,17 +312,17 @@ public function stats(array $params = []) /** * Returns low-level information about REST actions usage on nodes. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html * * @param array{ - * node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - * metric: list, // Limit the information returned to the specified metrics - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id?: string|array, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * metric?: string|array, // Limit the information returned to the specified metrics + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -325,16 +331,17 @@ public function stats(array $params = []) * * @return Elasticsearch|Promise */ - public function usage(array $params = []) + public function usage(?array $params = null) { + $params = $params ?? []; if (isset($params['metric']) && isset($params['node_id'])) { - $url = '/_nodes/' . $this->encode($params['node_id']) . '/usage/' . $this->encode($params['metric']); + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])) . '/usage/' . $this->encode($this->convertValue($params['metric'])); $method = 'GET'; } elseif (isset($params['node_id'])) { - $url = '/_nodes/' . $this->encode($params['node_id']) . '/usage'; + $url = '/_nodes/' . $this->encode($this->convertValue($params['node_id'])) . '/usage'; $method = 'GET'; } elseif (isset($params['metric'])) { - $url = '/_nodes/usage/' . $this->encode($params['metric']); + $url = '/_nodes/usage/' . $this->encode($this->convertValue($params['metric'])); $method = 'GET'; } else { $url = '/_nodes/usage'; diff --git a/src/Endpoints/Profiling.php b/src/Endpoints/Profiling.php index 18c43dac2..b7f59985c 100644 --- a/src/Endpoints/Profiling.php +++ b/src/Endpoints/Profiling.php @@ -31,15 +31,15 @@ class Profiling extends AbstractEndpoint /** * Extracts a UI-optimized structure to render flamegraphs from Universal Profiling. * - * @see https://www.elastic.co/guide/en/observability/current/universal-profiling.html + * @link https://www.elastic.co/guide/en/observability/current/universal-profiling.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The filter conditions for the flamegraph + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The filter conditions for the flamegraph. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -48,8 +48,9 @@ class Profiling extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function flamegraph(array $params = []) + public function flamegraph(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_profiling/flamegraph'; $method = 'POST'; @@ -68,15 +69,15 @@ public function flamegraph(array $params = []) /** * Extracts raw stacktrace information from Universal Profiling. * - * @see https://www.elastic.co/guide/en/observability/current/universal-profiling.html + * @link https://www.elastic.co/guide/en/observability/current/universal-profiling.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The filter conditions for stacktraces + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The filter conditions for stacktraces. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -85,8 +86,9 @@ public function flamegraph(array $params = []) * * @return Elasticsearch|Promise */ - public function stacktraces(array $params = []) + public function stacktraces(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_profiling/stacktraces'; $method = 'POST'; @@ -105,17 +107,17 @@ public function stacktraces(array $params = []) /** * Returns basic information about the status of Universal Profiling. * - * @see https://www.elastic.co/guide/en/observability/current/universal-profiling.html + * @link https://www.elastic.co/guide/en/observability/current/universal-profiling.html * * @param array{ - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * wait_for_resources_created: boolean, // Whether to return immediately or wait until resources have been created - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * wait_for_resources_created?: bool, // Whether to return immediately or wait until resources have been created + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -124,8 +126,9 @@ public function stacktraces(array $params = []) * * @return Elasticsearch|Promise */ - public function status(array $params = []) + public function status(?array $params = null) { + $params = $params ?? []; $url = '/_profiling/status'; $method = 'GET'; @@ -142,15 +145,15 @@ public function status(array $params = []) /** * Extracts a list of topN functions from Universal Profiling. * - * @see https://www.elastic.co/guide/en/observability/current/universal-profiling.html + * @link https://www.elastic.co/guide/en/observability/current/universal-profiling.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The filter conditions for stacktraces + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The filter conditions for stacktraces. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -159,8 +162,9 @@ public function status(array $params = []) * * @return Elasticsearch|Promise */ - public function topnFunctions(array $params = []) + public function topnFunctions(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_profiling/topn/functions'; $method = 'POST'; diff --git a/src/Endpoints/QueryRules.php b/src/Endpoints/QueryRules.php index 1da8b22f1..16ea174b5 100644 --- a/src/Endpoints/QueryRules.php +++ b/src/Endpoints/QueryRules.php @@ -31,16 +31,17 @@ class QueryRules extends AbstractEndpoint /** * Deletes an individual query rule within a ruleset. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-query-rule.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-query-rule.html + * @group serverless * * @param array{ * ruleset_id: string, // (REQUIRED) The unique identifier of the query ruleset this rule exists in * rule_id: string, // (REQUIRED) The unique identifier of the rule to delete. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -50,8 +51,9 @@ class QueryRules extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteRule(array $params = []) + public function deleteRule(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['ruleset_id','rule_id'], $params); $url = '/_query_rules/' . $this->encode($params['ruleset_id']) . '/_rule/' . $this->encode($params['rule_id']); $method = 'DELETE'; @@ -69,15 +71,16 @@ public function deleteRule(array $params = []) /** * Deletes a query ruleset. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-query-ruleset.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-query-ruleset.html + * @group serverless * * @param array{ * ruleset_id: string, // (REQUIRED) The unique identifier of the query ruleset to delete - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -87,8 +90,9 @@ public function deleteRule(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteRuleset(array $params = []) + public function deleteRuleset(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['ruleset_id'], $params); $url = '/_query_rules/' . $this->encode($params['ruleset_id']); $method = 'DELETE'; @@ -106,16 +110,17 @@ public function deleteRuleset(array $params = []) /** * Returns the details about an individual query rule within a ruleset. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-query-rule.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-query-rule.html + * @group serverless * * @param array{ * ruleset_id: string, // (REQUIRED) The unique identifier of the query ruleset the rule exists within * rule_id: string, // (REQUIRED) The unique identifier of the rule to be retrieved. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -125,8 +130,9 @@ public function deleteRuleset(array $params = []) * * @return Elasticsearch|Promise */ - public function getRule(array $params = []) + public function getRule(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['ruleset_id','rule_id'], $params); $url = '/_query_rules/' . $this->encode($params['ruleset_id']) . '/_rule/' . $this->encode($params['rule_id']); $method = 'GET'; @@ -144,15 +150,16 @@ public function getRule(array $params = []) /** * Returns the details about a query ruleset. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-query-ruleset.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-query-ruleset.html + * @group serverless * * @param array{ * ruleset_id: string, // (REQUIRED) The unique identifier of the query ruleset - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -162,8 +169,9 @@ public function getRule(array $params = []) * * @return Elasticsearch|Promise */ - public function getRuleset(array $params = []) + public function getRuleset(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['ruleset_id'], $params); $url = '/_query_rules/' . $this->encode($params['ruleset_id']); $method = 'GET'; @@ -181,16 +189,17 @@ public function getRuleset(array $params = []) /** * Lists query rulesets. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-query-rulesets.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/list-query-rulesets.html + * @group serverless * * @param array{ - * from: int, // Starting offset (default: 0) - * size: int, // specifies a max number of results to get (default: 100) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * from?: int, // Starting offset (default: 0) + * size?: int, // specifies a max number of results to get (default: 100) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -199,8 +208,9 @@ public function getRuleset(array $params = []) * * @return Elasticsearch|Promise */ - public function listRulesets(array $params = []) + public function listRulesets(?array $params = null) { + $params = $params ?? []; $url = '/_query_rules'; $method = 'GET'; @@ -217,17 +227,18 @@ public function listRulesets(array $params = []) /** * Creates or updates a query rule within a ruleset. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-query-rule.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/put-query-rule.html + * @group serverless * * @param array{ * ruleset_id: string, // (REQUIRED) The unique identifier of the ruleset this rule should be added to. The ruleset will be created if it does not exist. * rule_id: string, // (REQUIRED) The unique identifier of the rule to be created or updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The query rule configuration, including the type of rule, the criteria to match the rule, and the action that should be taken if the rule matches. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The query rule configuration, including the type of rule, the criteria to match the rule, and the action that should be taken if the rule matches.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -237,8 +248,9 @@ public function listRulesets(array $params = []) * * @return Elasticsearch|Promise */ - public function putRule(array $params = []) + public function putRule(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['ruleset_id','rule_id','body'], $params); $url = '/_query_rules/' . $this->encode($params['ruleset_id']) . '/_rule/' . $this->encode($params['rule_id']); $method = 'PUT'; @@ -257,16 +269,17 @@ public function putRule(array $params = []) /** * Creates or updates a query ruleset. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-query-ruleset.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/put-query-ruleset.html + * @group serverless * * @param array{ * ruleset_id: string, // (REQUIRED) The unique identifier of the ruleset to be created or updated. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The query ruleset configuration, including `rules` + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The query ruleset configuration, including `rules`. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -276,8 +289,9 @@ public function putRule(array $params = []) * * @return Elasticsearch|Promise */ - public function putRuleset(array $params = []) + public function putRuleset(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['ruleset_id','body'], $params); $url = '/_query_rules/' . $this->encode($params['ruleset_id']); $method = 'PUT'; @@ -291,4 +305,46 @@ public function putRuleset(array $params = []) $request = $this->addOtelAttributes($params, ['ruleset_id'], $request, 'query_rules.put_ruleset'); return $this->client->sendRequest($request); } + + + /** + * Tests a query ruleset to identify the rules that would match input criteria + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/test-query-ruleset.html + * @group serverless + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * ruleset_id: string, // (REQUIRED) The unique identifier of the ruleset to test. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The match criteria to test against the ruleset. If body is a string must be a valid JSON. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function test(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['ruleset_id','body'], $params); + $url = '/_query_rules/' . $this->encode($params['ruleset_id']) . '/_test'; + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['ruleset_id'], $request, 'query_rules.test'); + return $this->client->sendRequest($request); + } } diff --git a/src/Endpoints/Rollup.php b/src/Endpoints/Rollup.php index e2f00b076..2a11fa511 100644 --- a/src/Endpoints/Rollup.php +++ b/src/Endpoints/Rollup.php @@ -31,16 +31,16 @@ class Rollup extends AbstractEndpoint /** * Deletes an existing rollup job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-delete-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-delete-job.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * id: string, // (REQUIRED) The ID of the job to delete - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -50,8 +50,9 @@ class Rollup extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteJob(array $params = []) + public function deleteJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_rollup/job/' . $this->encode($params['id']); $method = 'DELETE'; @@ -69,16 +70,16 @@ public function deleteJob(array $params = []) /** * Retrieves the configuration, stats, and status of rollup jobs. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-job.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * id: string, // The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * id?: string, // The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -87,8 +88,9 @@ public function deleteJob(array $params = []) * * @return Elasticsearch|Promise */ - public function getJobs(array $params = []) + public function getJobs(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_rollup/job/' . $this->encode($params['id']); $method = 'GET'; @@ -109,16 +111,16 @@ public function getJobs(array $params = []) /** * Returns the capabilities of any rollup jobs that have been configured for a specific index or index pattern. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-caps.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-caps.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * id: string, // The ID of the index to check rollup capabilities on, or left blank for all jobs - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * id?: string, // The ID of the index to check rollup capabilities on, or left blank for all jobs + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -127,8 +129,9 @@ public function getJobs(array $params = []) * * @return Elasticsearch|Promise */ - public function getRollupCaps(array $params = []) + public function getRollupCaps(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_rollup/data/' . $this->encode($params['id']); $method = 'GET'; @@ -149,16 +152,16 @@ public function getRollupCaps(array $params = []) /** * Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the index where rollup data is stored). * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-index-caps.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-index-caps.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * index: string, // (REQUIRED) The rollup index or index pattern to obtain rollup capabilities from. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -168,8 +171,9 @@ public function getRollupCaps(array $params = []) * * @return Elasticsearch|Promise */ - public function getRollupIndexCaps(array $params = []) + public function getRollupIndexCaps(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); $url = '/' . $this->encode($params['index']) . '/_rollup/data'; $method = 'GET'; @@ -187,17 +191,17 @@ public function getRollupIndexCaps(array $params = []) /** * Creates a rollup job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-put-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-put-job.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * id: string, // (REQUIRED) The ID of the job to create - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The job configuration + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The job configuration. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -207,8 +211,9 @@ public function getRollupIndexCaps(array $params = []) * * @return Elasticsearch|Promise */ - public function putJob(array $params = []) + public function putJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','body'], $params); $url = '/_rollup/job/' . $this->encode($params['id']); $method = 'PUT'; @@ -227,19 +232,19 @@ public function putJob(array $params = []) /** * Enables searching rolled-up data using the standard query DSL. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-search.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-search.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * index: list, // (REQUIRED) The indices or index-pattern(s) (containing rollup or regular data) that should be searched - * typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response - * rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The search request body + * index: string|array, // (REQUIRED) The indices or index-pattern(s) (containing rollup or regular data) that should be searched + * typed_keys?: bool, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * rest_total_hits_as_int?: bool, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The search request body. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -249,10 +254,11 @@ public function putJob(array $params = []) * * @return Elasticsearch|Promise */ - public function rollupSearch(array $params = []) + public function rollupSearch(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','body'], $params); - $url = '/' . $this->encode($params['index']) . '/_rollup_search'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_rollup_search'; $method = empty($params['body']) ? 'GET' : 'POST'; $url = $this->addQueryString($url, $params, ['typed_keys','rest_total_hits_as_int','pretty','human','error_trace','source','filter_path']); @@ -269,16 +275,16 @@ public function rollupSearch(array $params = []) /** * Starts an existing, stopped rollup job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-start-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-start-job.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * id: string, // (REQUIRED) The ID of the job to start - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -288,8 +294,9 @@ public function rollupSearch(array $params = []) * * @return Elasticsearch|Promise */ - public function startJob(array $params = []) + public function startJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_rollup/job/' . $this->encode($params['id']) . '/_start'; $method = 'POST'; @@ -307,18 +314,18 @@ public function startJob(array $params = []) /** * Stops an existing, started rollup job. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-stop-job.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-stop-job.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * id: string, // (REQUIRED) The ID of the job to stop - * wait_for_completion: boolean, // True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false. - * timeout: time, // Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * wait_for_completion?: bool, // True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false. + * timeout?: int|string, // Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -328,8 +335,9 @@ public function startJob(array $params = []) * * @return Elasticsearch|Promise */ - public function stopJob(array $params = []) + public function stopJob(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_rollup/job/' . $this->encode($params['id']) . '/_stop'; $method = 'POST'; diff --git a/src/Endpoints/SearchApplication.php b/src/Endpoints/SearchApplication.php index fe70863a1..957fbc1c2 100644 --- a/src/Endpoints/SearchApplication.php +++ b/src/Endpoints/SearchApplication.php @@ -31,16 +31,17 @@ class SearchApplication extends AbstractEndpoint /** * Deletes a search application. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-search-application.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-search-application.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * name: string, // (REQUIRED) The name of the search application - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -50,8 +51,9 @@ class SearchApplication extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function delete(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_application/search_application/' . $this->encode($params['name']); $method = 'DELETE'; @@ -69,16 +71,17 @@ public function delete(array $params = []) /** * Delete a behavioral analytics collection. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-analytics-collection.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-analytics-collection.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * name: string, // (REQUIRED) The name of the analytics collection to be deleted - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -88,8 +91,9 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteBehavioralAnalytics(array $params = []) + public function deleteBehavioralAnalytics(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_application/analytics/' . $this->encode($params['name']); $method = 'DELETE'; @@ -107,16 +111,17 @@ public function deleteBehavioralAnalytics(array $params = []) /** * Returns the details about a search application. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-search-application.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-search-application.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * name: string, // (REQUIRED) The name of the search application - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -126,8 +131,9 @@ public function deleteBehavioralAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function get(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_application/search_application/' . $this->encode($params['name']); $method = 'GET'; @@ -145,16 +151,17 @@ public function get(array $params = []) /** * Returns the existing behavioral analytics collections. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-analytics-collection.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/list-analytics-collection.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * name: list, // A comma-separated list of analytics collections to limit the returned information - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // A comma-separated list of analytics collections to limit the returned information + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -163,10 +170,11 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function getBehavioralAnalytics(array $params = []) + public function getBehavioralAnalytics(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { - $url = '/_application/analytics/' . $this->encode($params['name']); + $url = '/_application/analytics/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } else { $url = '/_application/analytics'; @@ -185,18 +193,19 @@ public function getBehavioralAnalytics(array $params = []) /** * Returns the existing search applications. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-search-applications.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/list-search-applications.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * q: string, // Query in the Lucene query string syntax - * from: int, // Starting offset (default: 0) - * size: int, // specifies a max number of results to get - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * q?: string, // Query in the Lucene query string syntax + * from?: int, // Starting offset (default: 0) + * size?: int, // specifies a max number of results to get + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -205,8 +214,9 @@ public function getBehavioralAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function list(array $params = []) + public function list(?array $params = null) { + $params = $params ?? []; $url = '/_application/search_application'; $method = 'GET'; @@ -223,19 +233,19 @@ public function list(array $params = []) /** * Creates a behavioral analytics event for existing collection. * - * @see http://todo.com/tbd + * @link http://todo.com/tbd * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * collection_name: string, // (REQUIRED) The name of behavioral analytics collection * event_type: string, // (REQUIRED) Behavioral analytics event type. Available: page_view, search, search_click - * debug: boolean, // If true, returns event information that will be stored - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The event definition + * debug?: bool, // If true, returns event information that will be stored + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The event definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -245,8 +255,9 @@ public function list(array $params = []) * * @return Elasticsearch|Promise */ - public function postBehavioralAnalyticsEvent(array $params = []) + public function postBehavioralAnalyticsEvent(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['collection_name','event_type','body'], $params); $url = '/_application/analytics/' . $this->encode($params['collection_name']) . '/event/' . $this->encode($params['event_type']); $method = 'POST'; @@ -265,18 +276,19 @@ public function postBehavioralAnalyticsEvent(array $params = []) /** * Creates or updates a search application. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-search-application.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/put-search-application.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * name: string, // (REQUIRED) The name of the search application to be created or updated - * create: boolean, // If true, requires that a search application with the specified resource_id does not already exist. (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The search application configuration, including `indices` + * create?: bool, // If true, requires that a search application with the specified resource_id does not already exist. (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The search application configuration, including `indices`. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -286,8 +298,9 @@ public function postBehavioralAnalyticsEvent(array $params = []) * * @return Elasticsearch|Promise */ - public function put(array $params = []) + public function put(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name','body'], $params); $url = '/_application/search_application/' . $this->encode($params['name']); $method = 'PUT'; @@ -306,16 +319,17 @@ public function put(array $params = []) /** * Creates a behavioral analytics collection. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-analytics-collection.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/put-analytics-collection.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * name: string, // (REQUIRED) The name of the analytics collection to be created or updated - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -325,8 +339,9 @@ public function put(array $params = []) * * @return Elasticsearch|Promise */ - public function putBehavioralAnalytics(array $params = []) + public function putBehavioralAnalytics(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_application/analytics/' . $this->encode($params['name']); $method = 'PUT'; @@ -344,17 +359,17 @@ public function putBehavioralAnalytics(array $params = []) /** * Renders a query for given search application search parameters * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-application-render-query.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-application-render-query.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * name: string, // (REQUIRED) The name of the search application to render the query for - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Search parameters, which will override any default search parameters defined in the search application template + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Search parameters, which will override any default search parameters defined in the search application template. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -364,8 +379,9 @@ public function putBehavioralAnalytics(array $params = []) * * @return Elasticsearch|Promise */ - public function renderQuery(array $params = []) + public function renderQuery(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_application/search_application/' . $this->encode($params['name']) . '/_render_query'; $method = 'POST'; @@ -384,18 +400,19 @@ public function renderQuery(array $params = []) /** * Perform a search against a search application * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-application-search.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-application-search.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * name: string, // (REQUIRED) The name of the search application to be searched - * typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Search parameters, including template parameters that override defaults + * typed_keys?: bool, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Search parameters, including template parameters that override defaults. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -405,8 +422,9 @@ public function renderQuery(array $params = []) * * @return Elasticsearch|Promise */ - public function search(array $params = []) + public function search(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_application/search_application/' . $this->encode($params['name']) . '/_search'; $method = empty($params['body']) ? 'GET' : 'POST'; diff --git a/src/Endpoints/SearchableSnapshots.php b/src/Endpoints/SearchableSnapshots.php index 7eac97558..3533353d5 100644 --- a/src/Endpoints/SearchableSnapshots.php +++ b/src/Endpoints/SearchableSnapshots.php @@ -31,16 +31,16 @@ class SearchableSnapshots extends AbstractEndpoint /** * Retrieve node-level cache statistics about searchable snapshots. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-apis.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-apis.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id?: string|array, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -49,10 +49,11 @@ class SearchableSnapshots extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function cacheStats(array $params = []) + public function cacheStats(?array $params = null) { + $params = $params ?? []; if (isset($params['node_id'])) { - $url = '/_searchable_snapshots/' . $this->encode($params['node_id']) . '/cache/stats'; + $url = '/_searchable_snapshots/' . $this->encode($this->convertValue($params['node_id'])) . '/cache/stats'; $method = 'GET'; } else { $url = '/_searchable_snapshots/cache/stats'; @@ -71,19 +72,19 @@ public function cacheStats(array $params = []) /** * Clear the cache of searchable snapshots. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-apis.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-apis.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * index: list, // A comma-separated list of index names - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -92,10 +93,11 @@ public function cacheStats(array $params = []) * * @return Elasticsearch|Promise */ - public function clearCache(array $params = []) + public function clearCache(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_searchable_snapshots/cache/clear'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_searchable_snapshots/cache/clear'; $method = 'POST'; } else { $url = '/_searchable_snapshots/cache/clear'; @@ -114,20 +116,20 @@ public function clearCache(array $params = []) /** * Mount a snapshot as a searchable index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-mount-snapshot.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-mount-snapshot.html * * @param array{ * repository: string, // (REQUIRED) The name of the repository containing the snapshot of the index to mount * snapshot: string, // (REQUIRED) The name of the snapshot of the index to mount - * master_timeout: time, // Explicit operation timeout for connection to master node - * wait_for_completion: boolean, // Should this request wait until the operation has completed before returning - * storage: string, // Selects the kind of local storage used to accelerate searches. Experimental, and defaults to `full_copy` - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The restore configuration for mounting the snapshot as searchable + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * wait_for_completion?: bool, // Should this request wait until the operation has completed before returning + * storage?: string, // Selects the kind of local storage used to accelerate searches. Experimental, and defaults to `full_copy` + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The restore configuration for mounting the snapshot as searchable. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -137,8 +139,9 @@ public function clearCache(array $params = []) * * @return Elasticsearch|Promise */ - public function mount(array $params = []) + public function mount(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository','snapshot','body'], $params); $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']) . '/_mount'; $method = 'POST'; @@ -157,16 +160,16 @@ public function mount(array $params = []) /** * Retrieve shard-level statistics about searchable snapshots. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-apis.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-apis.html * * @param array{ - * index: list, // A comma-separated list of index names - * level: enum, // Return stats aggregated at cluster, index or shard level - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names + * level?: string, // Return stats aggregated at cluster, index or shard level + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -175,10 +178,11 @@ public function mount(array $params = []) * * @return Elasticsearch|Promise */ - public function stats(array $params = []) + public function stats(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_searchable_snapshots/stats'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_searchable_snapshots/stats'; $method = 'GET'; } else { $url = '/_searchable_snapshots/stats'; diff --git a/src/Endpoints/Security.php b/src/Endpoints/Security.php index 6841eb65c..555499e83 100644 --- a/src/Endpoints/Security.php +++ b/src/Endpoints/Security.php @@ -31,15 +31,15 @@ class Security extends AbstractEndpoint /** * Creates or updates the user profile on behalf of another user. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-activate-user-profile.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-activate-user-profile.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The grant type and user's credential + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The grant type and user's credential. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -48,8 +48,9 @@ class Security extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function activateUserProfile(array $params = []) + public function activateUserProfile(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/profile/_activate'; $method = 'POST'; @@ -68,14 +69,15 @@ public function activateUserProfile(array $params = []) /** * Enables authentication as a user and retrieve information about the authenticated user. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -84,8 +86,9 @@ public function activateUserProfile(array $params = []) * * @return Elasticsearch|Promise */ - public function authenticate(array $params = []) + public function authenticate(?array $params = null) { + $params = $params ?? []; $url = '/_security/_authenticate'; $method = 'GET'; @@ -102,16 +105,16 @@ public function authenticate(array $params = []) /** * Bulk delete roles in the native realm. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-bulk-delete-role.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-bulk-delete-role.html * * @param array{ - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The roles to delete + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The roles to delete. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -120,8 +123,9 @@ public function authenticate(array $params = []) * * @return Elasticsearch|Promise */ - public function bulkDeleteRole(array $params = []) + public function bulkDeleteRole(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/role'; $method = 'DELETE'; @@ -140,16 +144,16 @@ public function bulkDeleteRole(array $params = []) /** * Bulk adds and updates roles in the native realm. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-bulk-put-role.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-bulk-put-role.html * * @param array{ - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The roles to add + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The roles to add. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -158,8 +162,9 @@ public function bulkDeleteRole(array $params = []) * * @return Elasticsearch|Promise */ - public function bulkPutRole(array $params = []) + public function bulkPutRole(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/role'; $method = 'POST'; @@ -178,15 +183,15 @@ public function bulkPutRole(array $params = []) /** * Updates the attributes of multiple existing API keys. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-bulk-update-api-keys.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-bulk-update-api-keys.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The API key request to update the attributes of multiple API keys. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The API key request to update the attributes of multiple API keys.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -195,8 +200,9 @@ public function bulkPutRole(array $params = []) * * @return Elasticsearch|Promise */ - public function bulkUpdateApiKeys(array $params = []) + public function bulkUpdateApiKeys(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/api_key/_bulk_update'; $method = 'POST'; @@ -215,17 +221,17 @@ public function bulkUpdateApiKeys(array $params = []) /** * Changes the passwords of users in the native realm and built-in users. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html * * @param array{ - * username: string, // The username of the user to change the password for - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) the new password for the user + * username?: string, // The username of the user to change the password for + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) the new password for the user. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -234,8 +240,9 @@ public function bulkUpdateApiKeys(array $params = []) * * @return Elasticsearch|Promise */ - public function changePassword(array $params = []) + public function changePassword(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['username'])) { $url = '/_security/user/' . $this->encode($params['username']) . '/_password'; @@ -258,15 +265,15 @@ public function changePassword(array $params = []) /** * Clear a subset or all entries from the API key cache. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-api-key-cache.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-api-key-cache.html * * @param array{ - * ids: list, // (REQUIRED) A comma-separated list of IDs of API keys to clear from the cache - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * ids: string|array, // (REQUIRED) A comma-separated list of IDs of API keys to clear from the cache + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -276,10 +283,11 @@ public function changePassword(array $params = []) * * @return Elasticsearch|Promise */ - public function clearApiKeyCache(array $params = []) + public function clearApiKeyCache(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['ids'], $params); - $url = '/_security/api_key/' . $this->encode($params['ids']) . '/_clear_cache'; + $url = '/_security/api_key/' . $this->encode($this->convertValue($params['ids'])) . '/_clear_cache'; $method = 'POST'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); @@ -295,15 +303,15 @@ public function clearApiKeyCache(array $params = []) /** * Evicts application privileges from the native application privileges cache. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-privilege-cache.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-privilege-cache.html * * @param array{ - * application: list, // (REQUIRED) A comma-separated list of application names - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * application: string|array, // (REQUIRED) A comma-separated list of application names + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -313,10 +321,11 @@ public function clearApiKeyCache(array $params = []) * * @return Elasticsearch|Promise */ - public function clearCachedPrivileges(array $params = []) + public function clearCachedPrivileges(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['application'], $params); - $url = '/_security/privilege/' . $this->encode($params['application']) . '/_clear_cache'; + $url = '/_security/privilege/' . $this->encode($this->convertValue($params['application'])) . '/_clear_cache'; $method = 'POST'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); @@ -332,16 +341,16 @@ public function clearCachedPrivileges(array $params = []) /** * Evicts users from the user cache. Can completely clear the cache or evict specific users. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html * * @param array{ - * realms: list, // (REQUIRED) Comma-separated list of realms to clear - * usernames: list, // Comma-separated list of usernames to clear from the cache - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * realms: string|array, // (REQUIRED) Comma-separated list of realms to clear + * usernames?: string|array, // Comma-separated list of usernames to clear from the cache + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -351,10 +360,11 @@ public function clearCachedPrivileges(array $params = []) * * @return Elasticsearch|Promise */ - public function clearCachedRealms(array $params = []) + public function clearCachedRealms(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['realms'], $params); - $url = '/_security/realm/' . $this->encode($params['realms']) . '/_clear_cache'; + $url = '/_security/realm/' . $this->encode($this->convertValue($params['realms'])) . '/_clear_cache'; $method = 'POST'; $url = $this->addQueryString($url, $params, ['usernames','pretty','human','error_trace','source','filter_path']); @@ -370,15 +380,15 @@ public function clearCachedRealms(array $params = []) /** * Evicts roles from the native role cache. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html * * @param array{ - * name: list, // (REQUIRED) Role name - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name: string|array, // (REQUIRED) Role name + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -388,10 +398,11 @@ public function clearCachedRealms(array $params = []) * * @return Elasticsearch|Promise */ - public function clearCachedRoles(array $params = []) + public function clearCachedRoles(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); - $url = '/_security/role/' . $this->encode($params['name']) . '/_clear_cache'; + $url = '/_security/role/' . $this->encode($this->convertValue($params['name'])) . '/_clear_cache'; $method = 'POST'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); @@ -407,17 +418,17 @@ public function clearCachedRoles(array $params = []) /** * Evicts tokens from the service account token caches. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-service-token-caches.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-service-token-caches.html * * @param array{ * namespace: string, // (REQUIRED) An identifier for the namespace * service: string, // (REQUIRED) An identifier for the service name - * name: list, // (REQUIRED) A comma-separated list of service token names - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name: string|array, // (REQUIRED) A comma-separated list of service token names + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -427,10 +438,11 @@ public function clearCachedRoles(array $params = []) * * @return Elasticsearch|Promise */ - public function clearCachedServiceTokens(array $params = []) + public function clearCachedServiceTokens(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['namespace','service','name'], $params); - $url = '/_security/service/' . $this->encode($params['namespace']) . '/' . $this->encode($params['service']) . '/credential/token/' . $this->encode($params['name']) . '/_clear_cache'; + $url = '/_security/service/' . $this->encode($params['namespace']) . '/' . $this->encode($params['service']) . '/credential/token/' . $this->encode($this->convertValue($params['name'])) . '/_clear_cache'; $method = 'POST'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); @@ -446,16 +458,17 @@ public function clearCachedServiceTokens(array $params = []) /** * Creates an API key for access without requiring basic authentication. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html + * @group serverless * * @param array{ - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The api key request to create an API key + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The api key request to create an API key. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -464,8 +477,9 @@ public function clearCachedServiceTokens(array $params = []) * * @return Elasticsearch|Promise */ - public function createApiKey(array $params = []) + public function createApiKey(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/api_key'; $method = 'PUT'; @@ -484,15 +498,15 @@ public function createApiKey(array $params = []) /** * Creates a cross-cluster API key for API key based remote cluster access. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-cross-cluster-api-key.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-cross-cluster-api-key.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The request to create a cross-cluster API key + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The request to create a cross-cluster API key. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -501,8 +515,9 @@ public function createApiKey(array $params = []) * * @return Elasticsearch|Promise */ - public function createCrossClusterApiKey(array $params = []) + public function createCrossClusterApiKey(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/cross_cluster/api_key'; $method = 'POST'; @@ -521,18 +536,18 @@ public function createCrossClusterApiKey(array $params = []) /** * Creates a service account token for access without requiring basic authentication. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-service-token.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-service-token.html * * @param array{ * namespace: string, // (REQUIRED) An identifier for the namespace * service: string, // (REQUIRED) An identifier for the service name - * name: string, // An identifier for the token name - * refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string, // An identifier for the token name + * refresh?: string, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -542,8 +557,9 @@ public function createCrossClusterApiKey(array $params = []) * * @return Elasticsearch|Promise */ - public function createServiceToken(array $params = []) + public function createServiceToken(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['namespace','service'], $params); if (isset($params['name'])) { $url = '/_security/service/' . $this->encode($params['namespace']) . '/' . $this->encode($params['service']) . '/credential/token/' . $this->encode($params['name']); @@ -562,20 +578,57 @@ public function createServiceToken(array $params = []) } + /** + * Delegate PKI authentication. + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-delegate-pki-authentication.html + * + * @param array{ + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The X509Certificate chain.. If body is a string must be a valid JSON. + * } $params + * + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function delegatePki(?array $params = null) + { + $params = $params ?? []; + $this->checkRequiredParameters(['body'], $params); + $url = '/_security/delegate_pki'; + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.delegate_pki'); + return $this->client->sendRequest($request); + } + + /** * Removes application privileges. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-privilege.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-privilege.html * * @param array{ * application: string, // (REQUIRED) Application name * name: string, // (REQUIRED) Privilege name - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -585,8 +638,9 @@ public function createServiceToken(array $params = []) * * @return Elasticsearch|Promise */ - public function deletePrivileges(array $params = []) + public function deletePrivileges(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['application','name'], $params); $url = '/_security/privilege/' . $this->encode($params['application']) . '/' . $this->encode($params['name']); $method = 'DELETE'; @@ -604,16 +658,17 @@ public function deletePrivileges(array $params = []) /** * Removes roles in the native realm. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) Role name - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -623,8 +678,9 @@ public function deletePrivileges(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteRole(array $params = []) + public function deleteRole(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_security/role/' . $this->encode($params['name']); $method = 'DELETE'; @@ -642,16 +698,16 @@ public function deleteRole(array $params = []) /** * Removes role mappings. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html * * @param array{ * name: string, // (REQUIRED) Role-mapping name - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -661,8 +717,9 @@ public function deleteRole(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteRoleMapping(array $params = []) + public function deleteRoleMapping(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name'], $params); $url = '/_security/role_mapping/' . $this->encode($params['name']); $method = 'DELETE'; @@ -680,18 +737,18 @@ public function deleteRoleMapping(array $params = []) /** * Deletes a service account token. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-service-token.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-service-token.html * * @param array{ * namespace: string, // (REQUIRED) An identifier for the namespace * service: string, // (REQUIRED) An identifier for the service name * name: string, // (REQUIRED) An identifier for the token name - * refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * refresh?: string, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -701,8 +758,9 @@ public function deleteRoleMapping(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteServiceToken(array $params = []) + public function deleteServiceToken(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['namespace','service','name'], $params); $url = '/_security/service/' . $this->encode($params['namespace']) . '/' . $this->encode($params['service']) . '/credential/token/' . $this->encode($params['name']); $method = 'DELETE'; @@ -720,16 +778,16 @@ public function deleteServiceToken(array $params = []) /** * Deletes users from the native realm. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html * * @param array{ * username: string, // (REQUIRED) username - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -739,8 +797,9 @@ public function deleteServiceToken(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteUser(array $params = []) + public function deleteUser(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['username'], $params); $url = '/_security/user/' . $this->encode($params['username']); $method = 'DELETE'; @@ -758,16 +817,16 @@ public function deleteUser(array $params = []) /** * Disables users in the native realm. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html * * @param array{ * username: string, // (REQUIRED) The username of the user to disable - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -777,8 +836,9 @@ public function deleteUser(array $params = []) * * @return Elasticsearch|Promise */ - public function disableUser(array $params = []) + public function disableUser(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['username'], $params); $url = '/_security/user/' . $this->encode($params['username']) . '/_disable'; $method = 'PUT'; @@ -796,16 +856,16 @@ public function disableUser(array $params = []) /** * Disables a user profile so it's not visible in user profile searches. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-disable-user-profile.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-disable-user-profile.html * * @param array{ * uid: string, // (REQUIRED) Unique identifier for the user profile - * refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * refresh?: string, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -815,8 +875,9 @@ public function disableUser(array $params = []) * * @return Elasticsearch|Promise */ - public function disableUserProfile(array $params = []) + public function disableUserProfile(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['uid'], $params); $url = '/_security/profile/' . $this->encode($params['uid']) . '/_disable'; $method = 'PUT'; @@ -834,16 +895,16 @@ public function disableUserProfile(array $params = []) /** * Enables users in the native realm. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html * * @param array{ * username: string, // (REQUIRED) The username of the user to enable - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -853,8 +914,9 @@ public function disableUserProfile(array $params = []) * * @return Elasticsearch|Promise */ - public function enableUser(array $params = []) + public function enableUser(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['username'], $params); $url = '/_security/user/' . $this->encode($params['username']) . '/_enable'; $method = 'PUT'; @@ -872,16 +934,16 @@ public function enableUser(array $params = []) /** * Enables a user profile so it's visible in user profile searches. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-enable-user-profile.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-enable-user-profile.html * * @param array{ * uid: string, // (REQUIRED) An unique identifier of the user profile - * refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * refresh?: string, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -891,8 +953,9 @@ public function enableUser(array $params = []) * * @return Elasticsearch|Promise */ - public function enableUserProfile(array $params = []) + public function enableUserProfile(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['uid'], $params); $url = '/_security/profile/' . $this->encode($params['uid']) . '/_enable'; $method = 'PUT'; @@ -910,14 +973,14 @@ public function enableUserProfile(array $params = []) /** * Allows a kibana instance to configure itself to communicate with a secured elasticsearch cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-kibana-enrollment.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-kibana-enrollment.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -926,8 +989,9 @@ public function enableUserProfile(array $params = []) * * @return Elasticsearch|Promise */ - public function enrollKibana(array $params = []) + public function enrollKibana(?array $params = null) { + $params = $params ?? []; $url = '/_security/enroll/kibana'; $method = 'GET'; @@ -945,14 +1009,14 @@ public function enrollKibana(array $params = []) /** * Allows a new node to enroll to an existing cluster with security enabled. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-node-enrollment.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-node-enrollment.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -961,8 +1025,9 @@ public function enrollKibana(array $params = []) * * @return Elasticsearch|Promise */ - public function enrollNode(array $params = []) + public function enrollNode(?array $params = null) { + $params = $params ?? []; $url = '/_security/enroll/node'; $method = 'GET'; @@ -980,22 +1045,23 @@ public function enrollNode(array $params = []) /** * Retrieves information for one or more API keys. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html + * @group serverless * * @param array{ - * id: string, // API key id of the API key to be retrieved - * name: string, // API key name of the API key to be retrieved - * username: string, // user name of the user who created this API key to be retrieved - * realm_name: string, // realm name of the user who created this API key to be retrieved - * owner: boolean, // flag to query API keys owned by the currently authenticated user - * with_limited_by: boolean, // flag to show the limited-by role descriptors of API Keys - * with_profile_uid: boolean, // flag to also retrieve the API Key's owner profile uid, if it exists - * active_only: boolean, // flag to limit response to only active (not invalidated or expired) API keys - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * id?: string, // API key id of the API key to be retrieved + * name?: string, // API key name of the API key to be retrieved + * username?: string, // user name of the user who created this API key to be retrieved + * realm_name?: string, // realm name of the user who created this API key to be retrieved + * owner?: bool, // flag to query API keys owned by the currently authenticated user + * with_limited_by?: bool, // flag to show the limited-by role descriptors of API Keys + * with_profile_uid?: bool, // flag to also retrieve the API Key's owner profile uid, if it exists + * active_only?: bool, // flag to limit response to only active (not invalidated or expired) API keys + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1004,8 +1070,9 @@ public function enrollNode(array $params = []) * * @return Elasticsearch|Promise */ - public function getApiKey(array $params = []) + public function getApiKey(?array $params = null) { + $params = $params ?? []; $url = '/_security/api_key'; $method = 'GET'; @@ -1022,14 +1089,15 @@ public function getApiKey(array $params = []) /** * Retrieves the list of cluster privileges and index privileges that are available in this version of Elasticsearch. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-builtin-privileges.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-builtin-privileges.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1038,8 +1106,9 @@ public function getApiKey(array $params = []) * * @return Elasticsearch|Promise */ - public function getBuiltinPrivileges(array $params = []) + public function getBuiltinPrivileges(?array $params = null) { + $params = $params ?? []; $url = '/_security/privilege/_builtin'; $method = 'GET'; @@ -1056,16 +1125,16 @@ public function getBuiltinPrivileges(array $params = []) /** * Retrieves application privileges. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html * * @param array{ - * application: string, // Application name - * name: string, // Privilege name - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * application?: string, // Application name + * name?: string, // Privilege name + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1074,8 +1143,9 @@ public function getBuiltinPrivileges(array $params = []) * * @return Elasticsearch|Promise */ - public function getPrivileges(array $params = []) + public function getPrivileges(?array $params = null) { + $params = $params ?? []; if (isset($params['application']) && isset($params['name'])) { $url = '/_security/privilege/' . $this->encode($params['application']) . '/' . $this->encode($params['name']); $method = 'GET'; @@ -1099,15 +1169,16 @@ public function getPrivileges(array $params = []) /** * Retrieves roles in the native realm. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html + * @group serverless * * @param array{ - * name: list, // A comma-separated list of role names - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // A comma-separated list of role names + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1116,10 +1187,11 @@ public function getPrivileges(array $params = []) * * @return Elasticsearch|Promise */ - public function getRole(array $params = []) + public function getRole(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { - $url = '/_security/role/' . $this->encode($params['name']); + $url = '/_security/role/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } else { $url = '/_security/role'; @@ -1138,15 +1210,15 @@ public function getRole(array $params = []) /** * Retrieves role mappings. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html * * @param array{ - * name: list, // A comma-separated list of role-mapping names - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * name?: string|array, // A comma-separated list of role-mapping names + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1155,10 +1227,11 @@ public function getRole(array $params = []) * * @return Elasticsearch|Promise */ - public function getRoleMapping(array $params = []) + public function getRoleMapping(?array $params = null) { + $params = $params ?? []; if (isset($params['name'])) { - $url = '/_security/role_mapping/' . $this->encode($params['name']); + $url = '/_security/role_mapping/' . $this->encode($this->convertValue($params['name'])); $method = 'GET'; } else { $url = '/_security/role_mapping'; @@ -1177,16 +1250,16 @@ public function getRoleMapping(array $params = []) /** * Retrieves information about service accounts. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-service-accounts.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-service-accounts.html * * @param array{ - * namespace: string, // An identifier for the namespace - * service: string, // An identifier for the service name - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * namespace?: string, // An identifier for the namespace + * service?: string, // An identifier for the service name + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1195,8 +1268,9 @@ public function getRoleMapping(array $params = []) * * @return Elasticsearch|Promise */ - public function getServiceAccounts(array $params = []) + public function getServiceAccounts(?array $params = null) { + $params = $params ?? []; if (isset($params['namespace']) && isset($params['service'])) { $url = '/_security/service/' . $this->encode($params['namespace']) . '/' . $this->encode($params['service']); $method = 'GET'; @@ -1220,16 +1294,16 @@ public function getServiceAccounts(array $params = []) /** * Retrieves information of all service credentials for a service account. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-service-credentials.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-service-credentials.html * * @param array{ * namespace: string, // (REQUIRED) An identifier for the namespace * service: string, // (REQUIRED) An identifier for the service name - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1239,8 +1313,9 @@ public function getServiceAccounts(array $params = []) * * @return Elasticsearch|Promise */ - public function getServiceCredentials(array $params = []) + public function getServiceCredentials(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['namespace','service'], $params); $url = '/_security/service/' . $this->encode($params['namespace']) . '/' . $this->encode($params['service']) . '/credential'; $method = 'GET'; @@ -1258,15 +1333,15 @@ public function getServiceCredentials(array $params = []) /** * Retrieve settings for the security system indices * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-settings.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-settings.html * * @param array{ - * master_timeout: time, // Timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1275,8 +1350,9 @@ public function getServiceCredentials(array $params = []) * * @return Elasticsearch|Promise */ - public function getSettings(array $params = []) + public function getSettings(?array $params = null) { + $params = $params ?? []; $url = '/_security/settings'; $method = 'GET'; @@ -1294,15 +1370,15 @@ public function getSettings(array $params = []) /** * Creates a bearer token for access without requiring basic authentication. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The token request to get + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The token request to get. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1311,8 +1387,9 @@ public function getSettings(array $params = []) * * @return Elasticsearch|Promise */ - public function getToken(array $params = []) + public function getToken(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/oauth2/token'; $method = 'POST'; @@ -1331,16 +1408,16 @@ public function getToken(array $params = []) /** * Retrieves information about users in the native realm and built-in users. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html * * @param array{ - * username: list, // A comma-separated list of usernames - * with_profile_uid: boolean, // flag to retrieve profile uid (if exists) associated to the user - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * username?: string|array, // A comma-separated list of usernames + * with_profile_uid?: bool, // flag to retrieve profile uid (if exists) associated to the user + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1349,10 +1426,11 @@ public function getToken(array $params = []) * * @return Elasticsearch|Promise */ - public function getUser(array $params = []) + public function getUser(?array $params = null) { + $params = $params ?? []; if (isset($params['username'])) { - $url = '/_security/user/' . $this->encode($params['username']); + $url = '/_security/user/' . $this->encode($this->convertValue($params['username'])); $method = 'GET'; } else { $url = '/_security/user'; @@ -1371,14 +1449,14 @@ public function getUser(array $params = []) /** * Retrieves security privileges for the logged in user. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1387,8 +1465,9 @@ public function getUser(array $params = []) * * @return Elasticsearch|Promise */ - public function getUserPrivileges(array $params = []) + public function getUserPrivileges(?array $params = null) { + $params = $params ?? []; $url = '/_security/user/_privileges'; $method = 'GET'; @@ -1405,16 +1484,16 @@ public function getUserPrivileges(array $params = []) /** * Retrieves user profiles for the given unique ID(s). * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-profile.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-profile.html * * @param array{ - * uid: list, // (REQUIRED) A comma-separated list of unique identifier for user profiles - * data: list, // A comma-separated list of keys for which the corresponding application data are retrieved. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * uid: string|array, // (REQUIRED) A comma-separated list of unique identifier for user profiles + * data?: string|array, // A comma-separated list of keys for which the corresponding application data are retrieved. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1424,10 +1503,11 @@ public function getUserPrivileges(array $params = []) * * @return Elasticsearch|Promise */ - public function getUserProfile(array $params = []) + public function getUserProfile(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['uid'], $params); - $url = '/_security/profile/' . $this->encode($params['uid']); + $url = '/_security/profile/' . $this->encode($this->convertValue($params['uid'])); $method = 'GET'; $url = $this->addQueryString($url, $params, ['data','pretty','human','error_trace','source','filter_path']); @@ -1443,16 +1523,16 @@ public function getUserProfile(array $params = []) /** * Creates an API key on behalf of another user. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-grant-api-key.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-grant-api-key.html * * @param array{ - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The api key request to create an API key + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The api key request to create an API key. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1461,8 +1541,9 @@ public function getUserProfile(array $params = []) * * @return Elasticsearch|Promise */ - public function grantApiKey(array $params = []) + public function grantApiKey(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/api_key/grant'; $method = 'POST'; @@ -1481,16 +1562,17 @@ public function grantApiKey(array $params = []) /** * Determines whether the specified user has a specified list of privileges. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + * @group serverless * * @param array{ - * user: string, // Username - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The privileges to test + * user?: string, // Username + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The privileges to test. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1499,8 +1581,9 @@ public function grantApiKey(array $params = []) * * @return Elasticsearch|Promise */ - public function hasPrivileges(array $params = []) + public function hasPrivileges(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['user'])) { $url = '/_security/user/' . $this->encode($params['user']) . '/_has_privileges'; @@ -1523,15 +1606,15 @@ public function hasPrivileges(array $params = []) /** * Determines whether the users associated with the specified profile IDs have all the requested privileges. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges-user-profile.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges-user-profile.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The privileges to check and the list of profile IDs + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The privileges to check and the list of profile IDs. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1540,8 +1623,9 @@ public function hasPrivileges(array $params = []) * * @return Elasticsearch|Promise */ - public function hasPrivilegesUserProfile(array $params = []) + public function hasPrivilegesUserProfile(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/profile/_has_privileges'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1560,15 +1644,16 @@ public function hasPrivilegesUserProfile(array $params = []) /** * Invalidates one or more API keys. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The api key request to invalidate API key(s) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The api key request to invalidate API key(s). If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1577,8 +1662,9 @@ public function hasPrivilegesUserProfile(array $params = []) * * @return Elasticsearch|Promise */ - public function invalidateApiKey(array $params = []) + public function invalidateApiKey(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/api_key'; $method = 'DELETE'; @@ -1597,15 +1683,15 @@ public function invalidateApiKey(array $params = []) /** * Invalidates one or more access tokens or refresh tokens. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The token to invalidate + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The token to invalidate. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1614,8 +1700,9 @@ public function invalidateApiKey(array $params = []) * * @return Elasticsearch|Promise */ - public function invalidateToken(array $params = []) + public function invalidateToken(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/oauth2/token'; $method = 'DELETE'; @@ -1634,15 +1721,15 @@ public function invalidateToken(array $params = []) /** * Exchanges an OpenID Connection authentication response message for an Elasticsearch access token and refresh token pair * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-oidc-authenticate.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-oidc-authenticate.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The OpenID Connect response to authenticate + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The OpenID Connect response to authenticate. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1651,8 +1738,9 @@ public function invalidateToken(array $params = []) * * @return Elasticsearch|Promise */ - public function oidcAuthenticate(array $params = []) + public function oidcAuthenticate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/oidc/authenticate'; $method = 'POST'; @@ -1671,15 +1759,15 @@ public function oidcAuthenticate(array $params = []) /** * Invalidates a refresh token and access token that was generated from the OpenID Connect Authenticate API * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-oidc-logout.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-oidc-logout.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Access token and refresh token to invalidate + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Access token and refresh token to invalidate. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1688,8 +1776,9 @@ public function oidcAuthenticate(array $params = []) * * @return Elasticsearch|Promise */ - public function oidcLogout(array $params = []) + public function oidcLogout(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/oidc/logout'; $method = 'POST'; @@ -1708,15 +1797,15 @@ public function oidcLogout(array $params = []) /** * Creates an OAuth 2.0 authentication request as a URL string * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-oidc-prepare-authentication.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-oidc-prepare-authentication.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The OpenID Connect authentication realm configuration + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The OpenID Connect authentication realm configuration. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1725,8 +1814,9 @@ public function oidcLogout(array $params = []) * * @return Elasticsearch|Promise */ - public function oidcPrepareAuthentication(array $params = []) + public function oidcPrepareAuthentication(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/oidc/prepare'; $method = 'POST'; @@ -1745,16 +1835,16 @@ public function oidcPrepareAuthentication(array $params = []) /** * Adds or updates application privileges. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-privileges.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-privileges.html * * @param array{ - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The privilege(s) to add + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The privilege(s) to add. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1763,8 +1853,9 @@ public function oidcPrepareAuthentication(array $params = []) * * @return Elasticsearch|Promise */ - public function putPrivileges(array $params = []) + public function putPrivileges(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/privilege'; $method = 'PUT'; @@ -1783,17 +1874,18 @@ public function putPrivileges(array $params = []) /** * Adds and updates roles in the native realm. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html + * @group serverless * * @param array{ * name: string, // (REQUIRED) Role name - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The role to add + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The role to add. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1803,8 +1895,9 @@ public function putPrivileges(array $params = []) * * @return Elasticsearch|Promise */ - public function putRole(array $params = []) + public function putRole(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name','body'], $params); $url = '/_security/role/' . $this->encode($params['name']); $method = 'PUT'; @@ -1823,17 +1916,17 @@ public function putRole(array $params = []) /** * Creates and updates role mappings. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html * * @param array{ * name: string, // (REQUIRED) Role-mapping name - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The role mapping to add + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The role mapping to add. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1843,8 +1936,9 @@ public function putRole(array $params = []) * * @return Elasticsearch|Promise */ - public function putRoleMapping(array $params = []) + public function putRoleMapping(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['name','body'], $params); $url = '/_security/role_mapping/' . $this->encode($params['name']); $method = 'PUT'; @@ -1863,17 +1957,17 @@ public function putRoleMapping(array $params = []) /** * Adds and updates users in the native realm. These users are commonly referred to as native users. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html * * @param array{ * username: string, // (REQUIRED) The username of the User - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The user to add + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The user to add. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1883,8 +1977,9 @@ public function putRoleMapping(array $params = []) * * @return Elasticsearch|Promise */ - public function putUser(array $params = []) + public function putUser(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['username','body'], $params); $url = '/_security/user/' . $this->encode($params['username']); $method = 'PUT'; @@ -1903,18 +1998,19 @@ public function putUser(array $params = []) /** * Retrieves information for API keys using a subset of query DSL * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-api-key.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-api-key.html + * @group serverless * * @param array{ - * with_limited_by: boolean, // flag to show the limited-by role descriptors of API Keys - * with_profile_uid: boolean, // flag to also retrieve the API Key's owner profile uid, if it exists - * typed_keys: boolean, // flag to prefix aggregation names by their respective types in the response - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // From, size, query, sort and search_after + * with_limited_by?: bool, // flag to show the limited-by role descriptors of API Keys + * with_profile_uid?: bool, // flag to also retrieve the API Key's owner profile uid, if it exists + * typed_keys?: bool, // flag to prefix aggregation names by their respective types in the response + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // From, size, query, sort and search_after. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1923,8 +2019,9 @@ public function putUser(array $params = []) * * @return Elasticsearch|Promise */ - public function queryApiKeys(array $params = []) + public function queryApiKeys(?array $params = null) { + $params = $params ?? []; $url = '/_security/_query/api_key'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1942,15 +2039,16 @@ public function queryApiKeys(array $params = []) /** * Retrieves information for Roles using a subset of query DSL * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-role.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-role.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // From, size, query, sort and search_after + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // From, size, query, sort and search_after. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1959,8 +2057,9 @@ public function queryApiKeys(array $params = []) * * @return Elasticsearch|Promise */ - public function queryRole(array $params = []) + public function queryRole(?array $params = null) { + $params = $params ?? []; $url = '/_security/_query/role'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1978,16 +2077,16 @@ public function queryRole(array $params = []) /** * Retrieves information for Users using a subset of query DSL * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-user.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-user.html * * @param array{ - * with_profile_uid: boolean, // flag to retrieve profile uid (if exists) associated with the user - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // From, size, query, sort and search_after + * with_profile_uid?: bool, // flag to retrieve profile uid (if exists) associated with the user + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // From, size, query, sort and search_after. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1996,8 +2095,9 @@ public function queryRole(array $params = []) * * @return Elasticsearch|Promise */ - public function queryUser(array $params = []) + public function queryUser(?array $params = null) { + $params = $params ?? []; $url = '/_security/_query/user'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -2015,15 +2115,15 @@ public function queryUser(array $params = []) /** * Exchanges a SAML Response message for an Elasticsearch access token and refresh token pair * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-authenticate.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-authenticate.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The SAML response to authenticate + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The SAML response to authenticate. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2032,8 +2132,9 @@ public function queryUser(array $params = []) * * @return Elasticsearch|Promise */ - public function samlAuthenticate(array $params = []) + public function samlAuthenticate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/saml/authenticate'; $method = 'POST'; @@ -2052,15 +2153,15 @@ public function samlAuthenticate(array $params = []) /** * Verifies the logout response sent from the SAML IdP * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-complete-logout.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-complete-logout.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The logout response to verify + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The logout response to verify. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2069,8 +2170,9 @@ public function samlAuthenticate(array $params = []) * * @return Elasticsearch|Promise */ - public function samlCompleteLogout(array $params = []) + public function samlCompleteLogout(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/saml/complete_logout'; $method = 'POST'; @@ -2089,15 +2191,15 @@ public function samlCompleteLogout(array $params = []) /** * Consumes a SAML LogoutRequest * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-invalidate.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-invalidate.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The LogoutRequest message + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The LogoutRequest message. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2106,8 +2208,9 @@ public function samlCompleteLogout(array $params = []) * * @return Elasticsearch|Promise */ - public function samlInvalidate(array $params = []) + public function samlInvalidate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/saml/invalidate'; $method = 'POST'; @@ -2126,15 +2229,15 @@ public function samlInvalidate(array $params = []) /** * Invalidates an access token and a refresh token that were generated via the SAML Authenticate API * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-logout.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-logout.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The tokens to invalidate + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The tokens to invalidate. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2143,8 +2246,9 @@ public function samlInvalidate(array $params = []) * * @return Elasticsearch|Promise */ - public function samlLogout(array $params = []) + public function samlLogout(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/saml/logout'; $method = 'POST'; @@ -2163,15 +2267,15 @@ public function samlLogout(array $params = []) /** * Creates a SAML authentication request * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-prepare-authentication.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-prepare-authentication.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The realm for which to create the authentication request, identified by either its name or the ACS URL + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The realm for which to create the authentication request, identified by either its name or the ACS URL. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2180,8 +2284,9 @@ public function samlLogout(array $params = []) * * @return Elasticsearch|Promise */ - public function samlPrepareAuthentication(array $params = []) + public function samlPrepareAuthentication(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/saml/prepare'; $method = 'POST'; @@ -2200,15 +2305,15 @@ public function samlPrepareAuthentication(array $params = []) /** * Generates SAML metadata for the Elastic stack SAML 2.0 Service Provider * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-sp-metadata.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-sp-metadata.html * * @param array{ * realm_name: string, // (REQUIRED) The name of the SAML realm to get the metadata for - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2218,8 +2323,9 @@ public function samlPrepareAuthentication(array $params = []) * * @return Elasticsearch|Promise */ - public function samlServiceProviderMetadata(array $params = []) + public function samlServiceProviderMetadata(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['realm_name'], $params); $url = '/_security/saml/metadata/' . $this->encode($params['realm_name']); $method = 'GET'; @@ -2238,16 +2344,16 @@ public function samlServiceProviderMetadata(array $params = []) /** * Get suggestions for user profiles that match specified search criteria. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-suggest-user-profile.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-suggest-user-profile.html * * @param array{ - * data: list, // A comma-separated list of keys for which the corresponding application data are retrieved. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The suggestion definition for user profiles + * data?: string|array, // A comma-separated list of keys for which the corresponding application data are retrieved. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The suggestion definition for user profiles. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2256,8 +2362,9 @@ public function samlServiceProviderMetadata(array $params = []) * * @return Elasticsearch|Promise */ - public function suggestUserProfiles(array $params = []) + public function suggestUserProfiles(?array $params = null) { + $params = $params ?? []; $url = '/_security/profile/_suggest'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -2275,16 +2382,17 @@ public function suggestUserProfiles(array $params = []) /** * Updates attributes of an existing API key. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-api-key.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-api-key.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The ID of the API key to update - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The API key request to update attributes of an API key. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The API key request to update attributes of an API key.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2294,8 +2402,9 @@ public function suggestUserProfiles(array $params = []) * * @return Elasticsearch|Promise */ - public function updateApiKey(array $params = []) + public function updateApiKey(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_security/api_key/' . $this->encode($params['id']); $method = 'PUT'; @@ -2314,16 +2423,16 @@ public function updateApiKey(array $params = []) /** * Updates attributes of an existing cross-cluster API key. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-cross-cluster-api-key.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-cross-cluster-api-key.html * * @param array{ * id: string, // (REQUIRED) The ID of the cross-cluster API key to update - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The request to update attributes of a cross-cluster API key. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The request to update attributes of a cross-cluster API key.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2333,8 +2442,9 @@ public function updateApiKey(array $params = []) * * @return Elasticsearch|Promise */ - public function updateCrossClusterApiKey(array $params = []) + public function updateCrossClusterApiKey(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','body'], $params); $url = '/_security/cross_cluster/api_key/' . $this->encode($params['id']); $method = 'PUT'; @@ -2353,17 +2463,17 @@ public function updateCrossClusterApiKey(array $params = []) /** * Update settings for the security system index * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-settings.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-settings.html * * @param array{ - * master_timeout: time, // Timeout for connection to master - * timeout: time, // Timeout for acknowledgements from all nodes - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object with the new settings for each index, if any + * master_timeout?: int|string, // Timeout for connection to master + * timeout?: int|string, // Timeout for acknowledgements from all nodes + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object with the new settings for each index, if any. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -2372,8 +2482,9 @@ public function updateCrossClusterApiKey(array $params = []) * * @return Elasticsearch|Promise */ - public function updateSettings(array $params = []) + public function updateSettings(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_security/settings'; $method = 'PUT'; @@ -2392,19 +2503,19 @@ public function updateSettings(array $params = []) /** * Update application specific data for the user profile of the given unique ID. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-user-profile-data.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-user-profile-data.html * * @param array{ * uid: string, // (REQUIRED) An unique identifier of the user profile - * if_seq_no: number, // only perform the update operation if the last operation that has changed the document has the specified sequence number - * if_primary_term: number, // only perform the update operation if the last operation that has changed the document has the specified primary term - * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The application data to update + * if_seq_no?: int, // only perform the update operation if the last operation that has changed the document has the specified sequence number + * if_primary_term?: int, // only perform the update operation if the last operation that has changed the document has the specified primary term + * refresh?: string, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The application data to update. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2414,8 +2525,9 @@ public function updateSettings(array $params = []) * * @return Elasticsearch|Promise */ - public function updateUserProfileData(array $params = []) + public function updateUserProfileData(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['uid','body'], $params); $url = '/_security/profile/' . $this->encode($params['uid']) . '/_data'; $method = 'PUT'; diff --git a/src/Endpoints/Shutdown.php b/src/Endpoints/Shutdown.php index a03144389..fa1650805 100644 --- a/src/Endpoints/Shutdown.php +++ b/src/Endpoints/Shutdown.php @@ -31,15 +31,17 @@ class Shutdown extends AbstractEndpoint /** * Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current * * @param array{ * node_id: string, // (REQUIRED) The node id of node to be removed from the shutdown state - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -49,13 +51,14 @@ class Shutdown extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteNode(array $params = []) + public function deleteNode(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['node_id'], $params); $url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown'; $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -69,16 +72,16 @@ public function deleteNode(array $params = []) /** * Retrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current * * @param array{ - * node_id: string, // Which node for which to retrieve the shutdown status - * master_timeout: time, // Timeout for processing on master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * node_id?: string, // Which node for which to retrieve the shutdown status + * master_timeout?: int|string, // Timeout for processing on master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -87,8 +90,9 @@ public function deleteNode(array $params = []) * * @return Elasticsearch|Promise */ - public function getNode(array $params = []) + public function getNode(?array $params = null) { + $params = $params ?? []; if (isset($params['node_id'])) { $url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown'; $method = 'GET'; @@ -110,16 +114,18 @@ public function getNode(array $params = []) /** * Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current * * @param array{ * node_id: string, // (REQUIRED) The node id of node to be shut down - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The shutdown type definition to register + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The shutdown type definition to register. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -129,13 +135,14 @@ public function getNode(array $params = []) * * @return Elasticsearch|Promise */ - public function putNode(array $params = []) + public function putNode(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['node_id','body'], $params); $url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown'; $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Endpoints/Simulate.php b/src/Endpoints/Simulate.php index 02b987137..2b25a3061 100644 --- a/src/Endpoints/Simulate.php +++ b/src/Endpoints/Simulate.php @@ -31,18 +31,18 @@ class Simulate extends AbstractEndpoint /** * Simulates running ingest with example documents. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-ingest-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-ingest-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * index: string, // Default index for docs which don't provide one - * pipeline: string, // The pipeline id to preprocess incoming documents with if no pipeline is given for a particular document - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The simulate definition + * index?: string, // Default index for docs which don't provide one + * pipeline?: string, // The pipeline id to preprocess incoming documents with if no pipeline is given for a particular document + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The simulate definition. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -51,8 +51,9 @@ class Simulate extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function ingest(array $params = []) + public function ingest(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['index'])) { $url = '/_ingest/' . $this->encode($params['index']) . '/_simulate'; diff --git a/src/Endpoints/Slm.php b/src/Endpoints/Slm.php index 48369ae79..6601098dc 100644 --- a/src/Endpoints/Slm.php +++ b/src/Endpoints/Slm.php @@ -31,15 +31,17 @@ class Slm extends AbstractEndpoint /** * Deletes an existing snapshot lifecycle policy. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete-policy.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete-policy.html * * @param array{ * policy_id: string, // (REQUIRED) The id of the snapshot lifecycle policy to remove - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -49,13 +51,14 @@ class Slm extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteLifecycle(array $params = []) + public function deleteLifecycle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['policy_id'], $params); $url = '/_slm/policy/' . $this->encode($params['policy_id']); $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -68,15 +71,17 @@ public function deleteLifecycle(array $params = []) /** * Immediately creates a snapshot according to the lifecycle policy, without waiting for the scheduled time. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-lifecycle.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-lifecycle.html * * @param array{ * policy_id: string, // (REQUIRED) The id of the snapshot lifecycle policy to be executed - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -86,13 +91,14 @@ public function deleteLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function executeLifecycle(array $params = []) + public function executeLifecycle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['policy_id'], $params); $url = '/_slm/policy/' . $this->encode($params['policy_id']) . '/_execute'; $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -105,14 +111,16 @@ public function executeLifecycle(array $params = []) /** * Deletes any snapshots that are expired according to the policy's retention rules. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-retention.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-retention.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -121,12 +129,13 @@ public function executeLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function executeRetention(array $params = []) + public function executeRetention(?array $params = null) { + $params = $params ?? []; $url = '/_slm/_execute_retention'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -139,15 +148,17 @@ public function executeRetention(array $params = []) /** * Retrieves one or more snapshot lifecycle policy definitions and information about the latest snapshot attempts. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-policy.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-policy.html * * @param array{ - * policy_id: list, // Comma-separated list of snapshot lifecycle policies to retrieve - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * policy_id?: string|array, // Comma-separated list of snapshot lifecycle policies to retrieve + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -156,16 +167,17 @@ public function executeRetention(array $params = []) * * @return Elasticsearch|Promise */ - public function getLifecycle(array $params = []) + public function getLifecycle(?array $params = null) { + $params = $params ?? []; if (isset($params['policy_id'])) { - $url = '/_slm/policy/' . $this->encode($params['policy_id']); + $url = '/_slm/policy/' . $this->encode($this->convertValue($params['policy_id'])); $method = 'GET'; } else { $url = '/_slm/policy'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -178,14 +190,16 @@ public function getLifecycle(array $params = []) /** * Returns global and policy-level statistics about actions taken by snapshot lifecycle management. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-stats.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -194,12 +208,13 @@ public function getLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function getStats(array $params = []) + public function getStats(?array $params = null) { + $params = $params ?? []; $url = '/_slm/stats'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -212,14 +227,16 @@ public function getStats(array $params = []) /** * Retrieves the status of snapshot lifecycle management (SLM). * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-status.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-status.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -228,12 +245,13 @@ public function getStats(array $params = []) * * @return Elasticsearch|Promise */ - public function getStatus(array $params = []) + public function getStatus(?array $params = null) { + $params = $params ?? []; $url = '/_slm/status'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -246,16 +264,18 @@ public function getStatus(array $params = []) /** * Creates or updates a snapshot lifecycle policy. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html * * @param array{ * policy_id: string, // (REQUIRED) The id of the snapshot lifecycle policy - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The snapshot lifecycle policy definition to register + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The snapshot lifecycle policy definition to register. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -265,13 +285,14 @@ public function getStatus(array $params = []) * * @return Elasticsearch|Promise */ - public function putLifecycle(array $params = []) + public function putLifecycle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['policy_id'], $params); $url = '/_slm/policy/' . $this->encode($params['policy_id']); $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -285,16 +306,16 @@ public function putLifecycle(array $params = []) /** * Turns on snapshot lifecycle management (SLM). * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-start.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-start.html * * @param array{ - * master_timeout: time, // Timeout for processing on master node - * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Timeout for processing on master node + * timeout?: int|string, // Timeout for acknowledgement of update from all nodes in cluster + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -303,8 +324,9 @@ public function putLifecycle(array $params = []) * * @return Elasticsearch|Promise */ - public function start(array $params = []) + public function start(?array $params = null) { + $params = $params ?? []; $url = '/_slm/start'; $method = 'POST'; @@ -321,16 +343,16 @@ public function start(array $params = []) /** * Turns off snapshot lifecycle management (SLM). * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-stop.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-stop.html * * @param array{ - * master_timeout: time, // Timeout for processing on master node - * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Timeout for processing on master node + * timeout?: int|string, // Timeout for acknowledgement of update from all nodes in cluster + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -339,8 +361,9 @@ public function start(array $params = []) * * @return Elasticsearch|Promise */ - public function stop(array $params = []) + public function stop(?array $params = null) { + $params = $params ?? []; $url = '/_slm/stop'; $method = 'POST'; diff --git a/src/Endpoints/Snapshot.php b/src/Endpoints/Snapshot.php index 331d36295..6693f96b7 100644 --- a/src/Endpoints/Snapshot.php +++ b/src/Endpoints/Snapshot.php @@ -31,17 +31,17 @@ class Snapshot extends AbstractEndpoint /** * Removes stale data from repository. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/clean-up-snapshot-repo-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/clean-up-snapshot-repo-api.html * * @param array{ * repository: string, // (REQUIRED) A repository name - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -51,8 +51,9 @@ class Snapshot extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function cleanupRepository(array $params = []) + public function cleanupRepository(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository'], $params); $url = '/_snapshot/' . $this->encode($params['repository']) . '/_cleanup'; $method = 'POST'; @@ -70,19 +71,19 @@ public function cleanupRepository(array $params = []) /** * Clones indices from one snapshot into another snapshot in the same repository. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ * repository: string, // (REQUIRED) A repository name * snapshot: string, // (REQUIRED) The name of the snapshot to clone from * target_snapshot: string, // (REQUIRED) The name of the cloned snapshot to create - * master_timeout: time, // Explicit operation timeout for connection to master node - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The snapshot clone definition + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The snapshot clone definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -92,8 +93,9 @@ public function cleanupRepository(array $params = []) * * @return Elasticsearch|Promise */ - public function clone(array $params = []) + public function clone(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository','snapshot','target_snapshot','body'], $params); $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']) . '/_clone/' . $this->encode($params['target_snapshot']); $method = 'PUT'; @@ -112,19 +114,19 @@ public function clone(array $params = []) /** * Creates a snapshot in a repository. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ * repository: string, // (REQUIRED) A repository name * snapshot: string, // (REQUIRED) A snapshot name - * master_timeout: time, // Explicit operation timeout for connection to master node - * wait_for_completion: boolean, // Should this request wait until the operation has completed before returning - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The snapshot definition + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * wait_for_completion?: bool, // Should this request wait until the operation has completed before returning + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The snapshot definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -134,8 +136,9 @@ public function clone(array $params = []) * * @return Elasticsearch|Promise */ - public function create(array $params = []) + public function create(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository','snapshot'], $params); $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']); $method = 'PUT'; @@ -154,19 +157,19 @@ public function create(array $params = []) /** * Creates a repository. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ * repository: string, // (REQUIRED) A repository name - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * verify: boolean, // Whether to verify the repository after creation - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The repository definition + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * verify?: bool, // Whether to verify the repository after creation + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The repository definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -176,8 +179,9 @@ public function create(array $params = []) * * @return Elasticsearch|Promise */ - public function createRepository(array $params = []) + public function createRepository(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository','body'], $params); $url = '/_snapshot/' . $this->encode($params['repository']); $method = 'PUT'; @@ -196,18 +200,18 @@ public function createRepository(array $params = []) /** * Deletes one or more snapshots. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ * repository: string, // (REQUIRED) A repository name - * snapshot: list, // (REQUIRED) A comma-separated list of snapshot names - * master_timeout: time, // Explicit operation timeout for connection to master node - * wait_for_completion: boolean, // Should this request wait until the operation has completed before returning - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * snapshot: string|array, // (REQUIRED) A comma-separated list of snapshot names + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * wait_for_completion?: bool, // Should this request wait until the operation has completed before returning + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -217,10 +221,11 @@ public function createRepository(array $params = []) * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function delete(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository','snapshot'], $params); - $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']); + $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($this->convertValue($params['snapshot'])); $method = 'DELETE'; $url = $this->addQueryString($url, $params, ['master_timeout','wait_for_completion','pretty','human','error_trace','source','filter_path']); @@ -236,17 +241,17 @@ public function delete(array $params = []) /** * Deletes a repository. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ - * repository: list, // (REQUIRED) Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported. - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * repository: string|array, // (REQUIRED) Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -256,10 +261,11 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteRepository(array $params = []) + public function deleteRepository(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository'], $params); - $url = '/_snapshot/' . $this->encode($params['repository']); + $url = '/_snapshot/' . $this->encode($this->convertValue($params['repository'])); $method = 'DELETE'; $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); @@ -275,29 +281,29 @@ public function deleteRepository(array $params = []) /** * Returns information about a snapshot. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ * repository: string, // (REQUIRED) A repository name - * snapshot: list, // (REQUIRED) A comma-separated list of snapshot names - * master_timeout: time, // Explicit operation timeout for connection to master node - * ignore_unavailable: boolean, // Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - * index_names: boolean, // Whether to include the name of each index in the snapshot. Defaults to true. - * index_details: boolean, // Whether to include details of each index in the snapshot, if those details are available. Defaults to false. - * include_repository: boolean, // Whether to include the repository name in the snapshot info. Defaults to true. - * sort: enum, // Allows setting a sort order for the result. Defaults to start_time - * size: integer, // Maximum number of snapshots to return. Defaults to 0 which means return all that match without limit. - * order: enum, // Sort order - * from_sort_value: string, // Value of the current sort column at which to start retrieval. - * after: string, // Offset identifier to start pagination from as returned by the 'next' field in the response body. - * offset: integer, // Numeric offset to start pagination based on the snapshots matching the request. Defaults to 0 - * slm_policy_filter: string, // Filter snapshots by a comma-separated list of SLM policy names that snapshots belong to. Accepts wildcards. Use the special pattern '_none' to match snapshots without an SLM policy - * verbose: boolean, // Whether to show verbose snapshot info or only show the basic info found in the repository index blob - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * snapshot: string|array, // (REQUIRED) A comma-separated list of snapshot names + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * ignore_unavailable?: bool, // Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + * index_names?: bool, // Whether to include the name of each index in the snapshot. Defaults to true. + * index_details?: bool, // Whether to include details of each index in the snapshot, if those details are available. Defaults to false. + * include_repository?: bool, // Whether to include the repository name in the snapshot info. Defaults to true. + * sort?: string, // Allows setting a sort order for the result. Defaults to start_time + * size?: int, // Maximum number of snapshots to return. Defaults to 0 which means return all that match without limit. + * order?: string, // Sort order + * from_sort_value?: string, // Value of the current sort column at which to start retrieval. + * after?: string, // Offset identifier to start pagination from as returned by the 'next' field in the response body. + * offset?: int, // Numeric offset to start pagination based on the snapshots matching the request. Defaults to 0 + * slm_policy_filter?: string, // Filter snapshots by a comma-separated list of SLM policy names that snapshots belong to. Accepts wildcards. Use the special pattern '_none' to match snapshots without an SLM policy + * verbose?: bool, // Whether to show verbose snapshot info or only show the basic info found in the repository index blob + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -307,10 +313,11 @@ public function deleteRepository(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function get(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository','snapshot'], $params); - $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']); + $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($this->convertValue($params['snapshot'])); $method = 'GET'; $url = $this->addQueryString($url, $params, ['master_timeout','ignore_unavailable','index_names','index_details','include_repository','sort','size','order','from_sort_value','after','offset','slm_policy_filter','verbose','pretty','human','error_trace','source','filter_path']); @@ -326,17 +333,17 @@ public function get(array $params = []) /** * Returns information about a repository. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ - * repository: list, // A comma-separated list of repository names - * master_timeout: time, // Explicit operation timeout for connection to master node - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * repository?: string|array, // A comma-separated list of repository names + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -345,10 +352,11 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function getRepository(array $params = []) + public function getRepository(?array $params = null) { + $params = $params ?? []; if (isset($params['repository'])) { - $url = '/_snapshot/' . $this->encode($params['repository']); + $url = '/_snapshot/' . $this->encode($this->convertValue($params['repository'])); $method = 'GET'; } else { $url = '/_snapshot'; @@ -367,26 +375,26 @@ public function getRepository(array $params = []) /** * Analyzes a repository for correctness and performance * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ * repository: string, // (REQUIRED) A repository name - * blob_count: number, // Number of blobs to create during the test. Defaults to 100. - * concurrency: number, // Number of operations to run concurrently during the test. Defaults to 10. - * read_node_count: number, // Number of nodes on which to read a blob after writing. Defaults to 10. - * early_read_node_count: number, // Number of nodes on which to perform an early read on a blob, i.e. before writing has completed. Early reads are rare actions so the 'rare_action_probability' parameter is also relevant. Defaults to 2. - * seed: number, // Seed for the random number generator used to create the test workload. Defaults to a random value. - * rare_action_probability: number, // Probability of taking a rare action such as an early read or an overwrite. Defaults to 0.02. - * max_blob_size: string, // Maximum size of a blob to create during the test, e.g '1gb' or '100mb'. Defaults to '10mb'. - * max_total_data_size: string, // Maximum total size of all blobs to create during the test, e.g '1tb' or '100gb'. Defaults to '1gb'. - * timeout: time, // Explicit operation timeout. Defaults to '30s'. - * detailed: boolean, // Whether to return detailed results or a summary. Defaults to 'false' so that only the summary is returned. - * rarely_abort_writes: boolean, // Whether to rarely abort writes before they complete. Defaults to 'true'. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * blob_count?: int, // Number of blobs to create during the test. Defaults to 100. + * concurrency?: int, // Number of operations to run concurrently during the test. Defaults to 10. + * read_node_count?: int, // Number of nodes on which to read a blob after writing. Defaults to 10. + * early_read_node_count?: int, // Number of nodes on which to perform an early read on a blob, i.e. before writing has completed. Early reads are rare actions so the 'rare_action_probability' parameter is also relevant. Defaults to 2. + * seed?: int, // Seed for the random number generator used to create the test workload. Defaults to a random value. + * rare_action_probability?: int, // Probability of taking a rare action such as an early read or an overwrite. Defaults to 0.02. + * max_blob_size?: string, // Maximum size of a blob to create during the test, e.g '1gb' or '100mb'. Defaults to '10mb'. + * max_total_data_size?: string, // Maximum total size of all blobs to create during the test, e.g '1tb' or '100gb'. Defaults to '1gb'. + * timeout?: int|string, // Explicit operation timeout. Defaults to '30s'. + * detailed?: bool, // Whether to return detailed results or a summary. Defaults to 'false' so that only the summary is returned. + * rarely_abort_writes?: bool, // Whether to rarely abort writes before they complete. Defaults to 'true'. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -396,8 +404,9 @@ public function getRepository(array $params = []) * * @return Elasticsearch|Promise */ - public function repositoryAnalyze(array $params = []) + public function repositoryAnalyze(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository'], $params); $url = '/_snapshot/' . $this->encode($params['repository']) . '/_analyze'; $method = 'POST'; @@ -415,19 +424,19 @@ public function repositoryAnalyze(array $params = []) /** * Restores a snapshot. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ * repository: string, // (REQUIRED) A repository name * snapshot: string, // (REQUIRED) A snapshot name - * master_timeout: time, // Explicit operation timeout for connection to master node - * wait_for_completion: boolean, // Should this request wait until the operation has completed before returning - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Details of what to restore + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * wait_for_completion?: bool, // Should this request wait until the operation has completed before returning + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Details of what to restore. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -437,8 +446,9 @@ public function repositoryAnalyze(array $params = []) * * @return Elasticsearch|Promise */ - public function restore(array $params = []) + public function restore(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository','snapshot'], $params); $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']) . '/_restore'; $method = 'POST'; @@ -457,18 +467,18 @@ public function restore(array $params = []) /** * Returns information about the status of a snapshot. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ - * repository: string, // A repository name - * snapshot: list, // A comma-separated list of snapshot names - * master_timeout: time, // Explicit operation timeout for connection to master node - * ignore_unavailable: boolean, // Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * repository?: string, // A repository name + * snapshot?: string|array, // A comma-separated list of snapshot names + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * ignore_unavailable?: bool, // Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -477,10 +487,11 @@ public function restore(array $params = []) * * @return Elasticsearch|Promise */ - public function status(array $params = []) + public function status(?array $params = null) { + $params = $params ?? []; if (isset($params['repository']) && isset($params['snapshot'])) { - $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']) . '/_status'; + $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($this->convertValue($params['snapshot'])) . '/_status'; $method = 'GET'; } elseif (isset($params['repository'])) { $url = '/_snapshot/' . $this->encode($params['repository']) . '/_status'; @@ -502,17 +513,17 @@ public function status(array $params = []) /** * Verifies a repository. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html * * @param array{ * repository: string, // (REQUIRED) A repository name - * master_timeout: time, // Explicit operation timeout for connection to master node - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -522,8 +533,9 @@ public function status(array $params = []) * * @return Elasticsearch|Promise */ - public function verifyRepository(array $params = []) + public function verifyRepository(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['repository'], $params); $url = '/_snapshot/' . $this->encode($params['repository']) . '/_verify'; $method = 'POST'; diff --git a/src/Endpoints/Sql.php b/src/Endpoints/Sql.php index 1524f3da6..f96e827c1 100644 --- a/src/Endpoints/Sql.php +++ b/src/Endpoints/Sql.php @@ -31,15 +31,16 @@ class Sql extends AbstractEndpoint /** * Clears the SQL cursor * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-sql-cursor-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-sql-cursor-api.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Specify the cursor value in the `cursor` element to clean the cursor. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Specify the cursor value in the `cursor` element to clean the cursor.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -48,8 +49,9 @@ class Sql extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function clearCursor(array $params = []) + public function clearCursor(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_sql/close'; $method = 'POST'; @@ -68,15 +70,16 @@ public function clearCursor(array $params = []) /** * Deletes an async SQL search or a stored synchronous SQL search. If the search is still running, the API cancels it. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-async-sql-search-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-async-sql-search-api.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The async search ID - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -86,8 +89,9 @@ public function clearCursor(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteAsync(array $params = []) + public function deleteAsync(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_sql/async/delete/' . $this->encode($params['id']); $method = 'DELETE'; @@ -105,19 +109,20 @@ public function deleteAsync(array $params = []) /** * Returns the current status and available results for an async SQL search or stored synchronous SQL search * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-async-sql-search-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-async-sql-search-api.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The async search ID - * delimiter: string, // Separator for CSV results - * format: string, // Short version of the Accept header, e.g. json, yaml - * keep_alive: time, // Retention period for the search and its results - * wait_for_completion_timeout: time, // Duration to wait for complete results - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * delimiter?: string, // Separator for CSV results + * format?: string, // Short version of the Accept header, e.g. json, yaml + * keep_alive?: int|string, // Retention period for the search and its results + * wait_for_completion_timeout?: int|string, // Duration to wait for complete results + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -127,8 +132,9 @@ public function deleteAsync(array $params = []) * * @return Elasticsearch|Promise */ - public function getAsync(array $params = []) + public function getAsync(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_sql/async/' . $this->encode($params['id']); $method = 'GET'; @@ -146,15 +152,16 @@ public function getAsync(array $params = []) /** * Returns the current status of an async SQL search or a stored synchronous SQL search * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-async-sql-search-status-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-async-sql-search-status-api.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The async search ID - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -164,8 +171,9 @@ public function getAsync(array $params = []) * * @return Elasticsearch|Promise */ - public function getAsyncStatus(array $params = []) + public function getAsyncStatus(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_sql/async/status/' . $this->encode($params['id']); $method = 'GET'; @@ -183,16 +191,17 @@ public function getAsyncStatus(array $params = []) /** * Executes a SQL request * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-search-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-search-api.html + * @group serverless * * @param array{ - * format: string, // a short version of the Accept header, e.g. json, yaml - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Use the `query` element to start a query. Use the `cursor` element to continue a query. + * format?: string, // a short version of the Accept header, e.g. json, yaml + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Use the `query` element to start a query. Use the `cursor` element to continue a query.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -201,8 +210,9 @@ public function getAsyncStatus(array $params = []) * * @return Elasticsearch|Promise */ - public function query(array $params = []) + public function query(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_sql'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -221,15 +231,16 @@ public function query(array $params = []) /** * Translates SQL into Elasticsearch queries * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate-api.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Specify the query in the `query` element. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Specify the query in the `query` element.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -238,8 +249,9 @@ public function query(array $params = []) * * @return Elasticsearch|Promise */ - public function translate(array $params = []) + public function translate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_sql/translate'; $method = empty($params['body']) ? 'GET' : 'POST'; diff --git a/src/Endpoints/Ssl.php b/src/Endpoints/Ssl.php index 81ca3786e..25441e2d8 100644 --- a/src/Endpoints/Ssl.php +++ b/src/Endpoints/Ssl.php @@ -31,14 +31,14 @@ class Ssl extends AbstractEndpoint /** * Retrieves information about the X.509 certificates used to encrypt communications in the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -47,8 +47,9 @@ class Ssl extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function certificates(array $params = []) + public function certificates(?array $params = null) { + $params = $params ?? []; $url = '/_ssl/certificates'; $method = 'GET'; diff --git a/src/Endpoints/Synonyms.php b/src/Endpoints/Synonyms.php index 8f79597e7..11b21c6a9 100644 --- a/src/Endpoints/Synonyms.php +++ b/src/Endpoints/Synonyms.php @@ -31,15 +31,16 @@ class Synonyms extends AbstractEndpoint /** * Deletes a synonym set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonyms-set.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonyms-set.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The id of the synonyms set to be deleted - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -49,8 +50,9 @@ class Synonyms extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteSynonym(array $params = []) + public function deleteSynonym(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_synonyms/' . $this->encode($params['id']); $method = 'DELETE'; @@ -68,16 +70,17 @@ public function deleteSynonym(array $params = []) /** * Deletes a synonym rule in a synonym set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonym-rule.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonym-rule.html + * @group serverless * * @param array{ * set_id: string, // (REQUIRED) The id of the synonym set to be updated * rule_id: string, // (REQUIRED) The id of the synonym rule to be deleted - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -87,8 +90,9 @@ public function deleteSynonym(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteSynonymRule(array $params = []) + public function deleteSynonymRule(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['set_id','rule_id'], $params); $url = '/_synonyms/' . $this->encode($params['set_id']) . '/' . $this->encode($params['rule_id']); $method = 'DELETE'; @@ -107,17 +111,18 @@ public function deleteSynonymRule(array $params = []) /** * Retrieves a synonym set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonyms-set.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonyms-set.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The name of the synonyms set to be retrieved - * from: int, // Starting offset - * size: int, // specifies a max number of results to get - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * from?: int, // Starting offset + * size?: int, // specifies a max number of results to get + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -127,8 +132,9 @@ public function deleteSynonymRule(array $params = []) * * @return Elasticsearch|Promise */ - public function getSynonym(array $params = []) + public function getSynonym(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_synonyms/' . $this->encode($params['id']); $method = 'GET'; @@ -146,16 +152,17 @@ public function getSynonym(array $params = []) /** * Retrieves a synonym rule from a synonym set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonym-rule.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonym-rule.html + * @group serverless * * @param array{ * set_id: string, // (REQUIRED) The id of the synonym set to retrieve the synonym rule from * rule_id: string, // (REQUIRED) The id of the synonym rule to retrieve - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -165,8 +172,9 @@ public function getSynonym(array $params = []) * * @return Elasticsearch|Promise */ - public function getSynonymRule(array $params = []) + public function getSynonymRule(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['set_id','rule_id'], $params); $url = '/_synonyms/' . $this->encode($params['set_id']) . '/' . $this->encode($params['rule_id']); $method = 'GET'; @@ -185,16 +193,17 @@ public function getSynonymRule(array $params = []) /** * Retrieves a summary of all defined synonym sets * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-synonyms-sets.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/list-synonyms-sets.html + * @group serverless * * @param array{ - * from: int, // Starting offset - * size: int, // specifies a max number of results to get - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * from?: int, // Starting offset + * size?: int, // specifies a max number of results to get + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -203,8 +212,9 @@ public function getSynonymRule(array $params = []) * * @return Elasticsearch|Promise */ - public function getSynonymsSets(array $params = []) + public function getSynonymsSets(?array $params = null) { + $params = $params ?? []; $url = '/_synonyms'; $method = 'GET'; @@ -221,16 +231,17 @@ public function getSynonymsSets(array $params = []) /** * Creates or updates a synonyms set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonyms-set.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonyms-set.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The id of the synonyms set to be created or updated - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Synonyms set rules + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Synonyms set rules. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -240,8 +251,9 @@ public function getSynonymsSets(array $params = []) * * @return Elasticsearch|Promise */ - public function putSynonym(array $params = []) + public function putSynonym(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','body'], $params); $url = '/_synonyms/' . $this->encode($params['id']); $method = 'PUT'; @@ -260,17 +272,18 @@ public function putSynonym(array $params = []) /** * Creates or updates a synonym rule in a synonym set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonym-rule.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonym-rule.html + * @group serverless * * @param array{ * set_id: string, // (REQUIRED) The id of the synonym set to be updated with the synonym rule * rule_id: string, // (REQUIRED) The id of the synonym rule to be updated or created - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Synonym rule + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Synonym rule. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -280,8 +293,9 @@ public function putSynonym(array $params = []) * * @return Elasticsearch|Promise */ - public function putSynonymRule(array $params = []) + public function putSynonymRule(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['set_id','rule_id','body'], $params); $url = '/_synonyms/' . $this->encode($params['set_id']) . '/' . $this->encode($params['rule_id']); $method = 'PUT'; diff --git a/src/Endpoints/Tasks.php b/src/Endpoints/Tasks.php index a305f5c54..4d4ebeb82 100644 --- a/src/Endpoints/Tasks.php +++ b/src/Endpoints/Tasks.php @@ -31,20 +31,20 @@ class Tasks extends AbstractEndpoint /** * Cancels a task, if it can be cancelled through an API. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * task_id: string, // Cancel the task with specified task id (node_id:task_number) - * nodes: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - * actions: list, // A comma-separated list of actions that should be cancelled. Leave empty to cancel all. - * parent_task_id: string, // Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. - * wait_for_completion: boolean, // Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * task_id?: string, // Cancel the task with specified task id (node_id:task_number) + * nodes?: string|array, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * actions?: string|array, // A comma-separated list of actions that should be cancelled. Leave empty to cancel all. + * parent_task_id?: string, // Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. + * wait_for_completion?: bool, // Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -53,8 +53,9 @@ class Tasks extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function cancel(array $params = []) + public function cancel(?array $params = null) { + $params = $params ?? []; if (isset($params['task_id'])) { $url = '/_tasks/' . $this->encode($params['task_id']) . '/_cancel'; $method = 'POST'; @@ -75,18 +76,19 @@ public function cancel(array $params = []) /** * Returns information about a task. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * task_id: string, // (REQUIRED) Return the task with specified id (node_id:task_number) - * wait_for_completion: boolean, // Wait for the matching tasks to complete (default: false) - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * wait_for_completion?: bool, // Wait for the matching tasks to complete (default: false) + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -96,8 +98,9 @@ public function cancel(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function get(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['task_id'], $params); $url = '/_tasks/' . $this->encode($params['task_id']); $method = 'GET'; @@ -115,22 +118,22 @@ public function get(array $params = []) /** * Returns a list of tasks. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * nodes: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - * actions: list, // A comma-separated list of actions that should be returned. Leave empty to return all. - * detailed: boolean, // Return detailed task information (default: false) - * parent_task_id: string, // Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. - * wait_for_completion: boolean, // Wait for the matching tasks to complete (default: false) - * group_by: enum, // Group tasks by nodes or parent/child relationships - * timeout: time, // Explicit operation timeout - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * nodes?: string|array, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * actions?: string|array, // A comma-separated list of actions that should be returned. Leave empty to return all. + * detailed?: bool, // Return detailed task information (default: false) + * parent_task_id?: string, // Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. + * wait_for_completion?: bool, // Wait for the matching tasks to complete (default: false) + * group_by?: string, // Group tasks by nodes or parent/child relationships + * timeout?: int|string, // Explicit operation timeout + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -139,8 +142,9 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function list(array $params = []) + public function list(?array $params = null) { + $params = $params ?? []; $url = '/_tasks'; $method = 'GET'; diff --git a/src/Endpoints/TextStructure.php b/src/Endpoints/TextStructure.php index a9e121ecd..1e07c9f19 100644 --- a/src/Endpoints/TextStructure.php +++ b/src/Endpoints/TextStructure.php @@ -31,28 +31,28 @@ class TextStructure extends AbstractEndpoint /** * Finds the structure of a text field in an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/find-field-structure.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/find-field-structure.html * * @param array{ - * index: string, // The index containing the analyzed field - * field: string, // The field that should be analyzed - * documents_to_sample: int, // How many documents should be included in the analysis - * timeout: time, // Timeout after which the analysis will be aborted - * format: enum, // Optional parameter to specify the high level file format - * column_names: list, // Optional parameter containing a comma separated list of the column names for a delimited file - * delimiter: string, // Optional parameter to specify the delimiter character for a delimited file - must be a single character - * quote: string, // Optional parameter to specify the quote character for a delimited file - must be a single character - * should_trim_fields: boolean, // Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them - * grok_pattern: string, // Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file - * ecs_compatibility: string, // Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled' - * timestamp_field: string, // Optional parameter to specify the timestamp field in the file - * timestamp_format: string, // Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format - * explain: boolean, // Whether to include a commentary on how the structure was derived - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string, // The index containing the analyzed field + * field?: string, // The field that should be analyzed + * documents_to_sample?: int, // How many documents should be included in the analysis + * timeout?: int|string, // Timeout after which the analysis will be aborted + * format?: string, // Optional parameter to specify the high level file format + * column_names?: string|array, // Optional parameter containing a comma separated list of the column names for a delimited file + * delimiter?: string, // Optional parameter to specify the delimiter character for a delimited file - must be a single character + * quote?: string, // Optional parameter to specify the quote character for a delimited file - must be a single character + * should_trim_fields?: bool, // Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them + * grok_pattern?: string, // Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file + * ecs_compatibility?: string, // Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled' + * timestamp_field?: string, // Optional parameter to specify the timestamp field in the file + * timestamp_format?: string, // Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format + * explain?: bool, // Whether to include a commentary on how the structure was derived + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -61,8 +61,9 @@ class TextStructure extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function findFieldStructure(array $params = []) + public function findFieldStructure(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','field'], $params); $url = '/_text_structure/find_field_structure'; $method = 'GET'; @@ -80,26 +81,26 @@ public function findFieldStructure(array $params = []) /** * Finds the structure of a list of messages. The messages must contain data that is suitable to be ingested into Elasticsearch. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/find-message-structure.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/find-message-structure.html * * @param array{ - * timeout: time, // Timeout after which the analysis will be aborted - * format: enum, // Optional parameter to specify the high level file format - * column_names: list, // Optional parameter containing a comma separated list of the column names for a delimited file - * delimiter: string, // Optional parameter to specify the delimiter character for a delimited file - must be a single character - * quote: string, // Optional parameter to specify the quote character for a delimited file - must be a single character - * should_trim_fields: boolean, // Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them - * grok_pattern: string, // Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file - * ecs_compatibility: string, // Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled' - * timestamp_field: string, // Optional parameter to specify the timestamp field in the file - * timestamp_format: string, // Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format - * explain: boolean, // Whether to include a commentary on how the structure was derived - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) JSON object with one field [messages], containing an array of messages to be analyzed + * timeout?: int|string, // Timeout after which the analysis will be aborted + * format?: string, // Optional parameter to specify the high level file format + * column_names?: string|array, // Optional parameter containing a comma separated list of the column names for a delimited file + * delimiter?: string, // Optional parameter to specify the delimiter character for a delimited file - must be a single character + * quote?: string, // Optional parameter to specify the quote character for a delimited file - must be a single character + * should_trim_fields?: bool, // Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them + * grok_pattern?: string, // Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file + * ecs_compatibility?: string, // Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled' + * timestamp_field?: string, // Optional parameter to specify the timestamp field in the file + * timestamp_format?: string, // Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format + * explain?: bool, // Whether to include a commentary on how the structure was derived + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) JSON object with one field [messages], containing an array of messages to be analyzed. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -108,8 +109,9 @@ public function findFieldStructure(array $params = []) * * @return Elasticsearch|Promise */ - public function findMessageStructure(array $params = []) + public function findMessageStructure(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_text_structure/find_message_structure'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -128,30 +130,30 @@ public function findMessageStructure(array $params = []) /** * Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html * * @param array{ - * lines_to_sample: int, // How many lines of the file should be included in the analysis - * line_merge_size_limit: int, // Maximum number of characters permitted in a single message when lines are merged to create messages. - * timeout: time, // Timeout after which the analysis will be aborted - * charset: string, // Optional parameter to specify the character set of the file - * format: enum, // Optional parameter to specify the high level file format - * has_header_row: boolean, // Optional parameter to specify whether a delimited file includes the column names in its first row - * column_names: list, // Optional parameter containing a comma separated list of the column names for a delimited file - * delimiter: string, // Optional parameter to specify the delimiter character for a delimited file - must be a single character - * quote: string, // Optional parameter to specify the quote character for a delimited file - must be a single character - * should_trim_fields: boolean, // Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them - * grok_pattern: string, // Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file - * ecs_compatibility: string, // Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled' - * timestamp_field: string, // Optional parameter to specify the timestamp field in the file - * timestamp_format: string, // Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format - * explain: boolean, // Whether to include a commentary on how the structure was derived - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The contents of the file to be analyzed + * lines_to_sample?: int, // How many lines of the file should be included in the analysis + * line_merge_size_limit?: int, // Maximum number of characters permitted in a single message when lines are merged to create messages. + * timeout?: int|string, // Timeout after which the analysis will be aborted + * charset?: string, // Optional parameter to specify the character set of the file + * format?: string, // Optional parameter to specify the high level file format + * has_header_row?: bool, // Optional parameter to specify whether a delimited file includes the column names in its first row + * column_names?: string|array, // Optional parameter containing a comma separated list of the column names for a delimited file + * delimiter?: string, // Optional parameter to specify the delimiter character for a delimited file - must be a single character + * quote?: string, // Optional parameter to specify the quote character for a delimited file - must be a single character + * should_trim_fields?: bool, // Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them + * grok_pattern?: string, // Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file + * ecs_compatibility?: string, // Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled' + * timestamp_field?: string, // Optional parameter to specify the timestamp field in the file + * timestamp_format?: string, // Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format + * explain?: bool, // Whether to include a commentary on how the structure was derived + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The contents of the file to be analyzed. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -160,8 +162,9 @@ public function findMessageStructure(array $params = []) * * @return Elasticsearch|Promise */ - public function findStructure(array $params = []) + public function findStructure(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_text_structure/find_structure'; $method = 'POST'; @@ -180,16 +183,16 @@ public function findStructure(array $params = []) /** * Tests a Grok pattern on some text. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/test-grok-pattern.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/test-grok-pattern.html * * @param array{ - * ecs_compatibility: string, // Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled' - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The Grok pattern and text. + * ecs_compatibility?: string, // Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled' + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The Grok pattern and text.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -198,8 +201,9 @@ public function findStructure(array $params = []) * * @return Elasticsearch|Promise */ - public function testGrokPattern(array $params = []) + public function testGrokPattern(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_text_structure/test_grok_pattern'; $method = empty($params['body']) ? 'GET' : 'POST'; diff --git a/src/Endpoints/Transform.php b/src/Endpoints/Transform.php index 653a8c5a7..7d83b62c9 100644 --- a/src/Endpoints/Transform.php +++ b/src/Endpoints/Transform.php @@ -31,18 +31,19 @@ class Transform extends AbstractEndpoint /** * Deletes an existing transform. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html + * @group serverless * * @param array{ * transform_id: string, // (REQUIRED) The id of the transform to delete - * force: boolean, // When `true`, the transform is deleted regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be deleted. - * delete_dest_index: boolean, // When `true`, the destination index is deleted together with the transform. The default value is `false`, meaning that the destination index will not be deleted. - * timeout: time, // Controls the time to wait for the transform deletion - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * force?: bool, // When `true`, the transform is deleted regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be deleted. + * delete_dest_index?: bool, // When `true`, the destination index is deleted together with the transform. The default value is `false`, meaning that the destination index will not be deleted. + * timeout?: int|string, // Controls the time to wait for the transform deletion + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -52,8 +53,9 @@ class Transform extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteTransform(array $params = []) + public function deleteTransform(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['transform_id'], $params); $url = '/_transform/' . $this->encode($params['transform_id']); $method = 'DELETE'; @@ -71,14 +73,14 @@ public function deleteTransform(array $params = []) /** * Retrieves transform usage information for transform nodes. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-node-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-node-stats.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -87,8 +89,9 @@ public function deleteTransform(array $params = []) * * @return Elasticsearch|Promise */ - public function getNodeStats(array $params = []) + public function getNodeStats(?array $params = null) { + $params = $params ?? []; $url = '/_transform/_node_stats'; $method = 'GET'; @@ -105,19 +108,20 @@ public function getNodeStats(array $params = []) /** * Retrieves configuration information for transforms. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html + * @group serverless * * @param array{ - * transform_id: string, // The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all transforms - * from: int, // skips a number of transform configs, defaults to 0 - * size: int, // specifies a max number of transforms to get, defaults to 100 - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - * exclude_generated: boolean, // Omits fields that are illegal to set on transform PUT - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * transform_id?: string, // The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all transforms + * from?: int, // skips a number of transform configs, defaults to 0 + * size?: int, // specifies a max number of transforms to get, defaults to 100 + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) + * exclude_generated?: bool, // Omits fields that are illegal to set on transform PUT + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -126,8 +130,9 @@ public function getNodeStats(array $params = []) * * @return Elasticsearch|Promise */ - public function getTransform(array $params = []) + public function getTransform(?array $params = null) { + $params = $params ?? []; if (isset($params['transform_id'])) { $url = '/_transform/' . $this->encode($params['transform_id']); $method = 'GET'; @@ -148,19 +153,20 @@ public function getTransform(array $params = []) /** * Retrieves usage information for transforms. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html + * @group serverless * * @param array{ * transform_id: string, // (REQUIRED) The id of the transform for which to get stats. '_all' or '*' implies all transforms - * from: number, // skips a number of transform stats, defaults to 0 - * size: number, // specifies a max number of transform stats to get, defaults to 100 - * timeout: time, // Controls the time to wait for the stats - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * from?: int, // skips a number of transform stats, defaults to 0 + * size?: int, // specifies a max number of transform stats to get, defaults to 100 + * timeout?: int|string, // Controls the time to wait for the stats + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -170,8 +176,9 @@ public function getTransform(array $params = []) * * @return Elasticsearch|Promise */ - public function getTransformStats(array $params = []) + public function getTransformStats(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['transform_id'], $params); $url = '/_transform/' . $this->encode($params['transform_id']) . '/_stats'; $method = 'GET'; @@ -189,17 +196,18 @@ public function getTransformStats(array $params = []) /** * Previews a transform. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html + * @group serverless * * @param array{ - * transform_id: string, // The id of the transform to preview. - * timeout: time, // Controls the time to wait for the preview - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The definition for the transform to preview + * transform_id?: string, // The id of the transform to preview. + * timeout?: int|string, // Controls the time to wait for the preview + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The definition for the transform to preview. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -208,8 +216,9 @@ public function getTransformStats(array $params = []) * * @return Elasticsearch|Promise */ - public function previewTransform(array $params = []) + public function previewTransform(?array $params = null) { + $params = $params ?? []; if (isset($params['transform_id'])) { $url = '/_transform/' . $this->encode($params['transform_id']) . '/_preview'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -231,18 +240,19 @@ public function previewTransform(array $params = []) /** * Instantiates a transform. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html + * @group serverless * * @param array{ * transform_id: string, // (REQUIRED) The id of the new transform. - * defer_validation: boolean, // If validations should be deferred until transform starts, defaults to false. - * timeout: time, // Controls the time to wait for the transform to start - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The transform definition + * defer_validation?: bool, // If validations should be deferred until transform starts, defaults to false. + * timeout?: int|string, // Controls the time to wait for the transform to start + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The transform definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -252,8 +262,9 @@ public function previewTransform(array $params = []) * * @return Elasticsearch|Promise */ - public function putTransform(array $params = []) + public function putTransform(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['transform_id','body'], $params); $url = '/_transform/' . $this->encode($params['transform_id']); $method = 'PUT'; @@ -272,17 +283,18 @@ public function putTransform(array $params = []) /** * Resets an existing transform. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/reset-transform.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/reset-transform.html + * @group serverless * * @param array{ * transform_id: string, // (REQUIRED) The id of the transform to reset - * force: boolean, // When `true`, the transform is reset regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be reset. - * timeout: time, // Controls the time to wait for the transform to reset - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * force?: bool, // When `true`, the transform is reset regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be reset. + * timeout?: int|string, // Controls the time to wait for the transform to reset + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -292,8 +304,9 @@ public function putTransform(array $params = []) * * @return Elasticsearch|Promise */ - public function resetTransform(array $params = []) + public function resetTransform(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['transform_id'], $params); $url = '/_transform/' . $this->encode($params['transform_id']) . '/_reset'; $method = 'POST'; @@ -311,16 +324,17 @@ public function resetTransform(array $params = []) /** * Schedules now a transform. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/schedule-now-transform.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/schedule-now-transform.html + * @group serverless * * @param array{ * transform_id: string, // (REQUIRED) The id of the transform. - * timeout: time, // Controls the time to wait for the scheduling to take place - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // Controls the time to wait for the scheduling to take place + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -330,8 +344,9 @@ public function resetTransform(array $params = []) * * @return Elasticsearch|Promise */ - public function scheduleNowTransform(array $params = []) + public function scheduleNowTransform(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['transform_id'], $params); $url = '/_transform/' . $this->encode($params['transform_id']) . '/_schedule_now'; $method = 'POST'; @@ -350,17 +365,18 @@ public function scheduleNowTransform(array $params = []) /** * Starts one or more transforms. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html + * @group serverless * * @param array{ * transform_id: string, // (REQUIRED) The id of the transform to start - * from: string, // Restricts the set of transformed entities to those changed after this time - * timeout: time, // Controls the time to wait for the transform to start - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * from?: string, // Restricts the set of transformed entities to those changed after this time + * timeout?: int|string, // Controls the time to wait for the transform to start + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -370,8 +386,9 @@ public function scheduleNowTransform(array $params = []) * * @return Elasticsearch|Promise */ - public function startTransform(array $params = []) + public function startTransform(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['transform_id'], $params); $url = '/_transform/' . $this->encode($params['transform_id']) . '/_start'; $method = 'POST'; @@ -389,20 +406,21 @@ public function startTransform(array $params = []) /** * Stops one or more transforms. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html + * @group serverless * * @param array{ * transform_id: string, // (REQUIRED) The id of the transform to stop - * force: boolean, // Whether to force stop a failed transform or not. Default to false - * wait_for_completion: boolean, // Whether to wait for the transform to fully stop before returning or not. Default to false - * timeout: time, // Controls the time to wait until the transform has stopped. Default to 30 seconds - * allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - * wait_for_checkpoint: boolean, // Whether to wait for the transform to reach a checkpoint before stopping. Default to false - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * force?: bool, // Whether to force stop a failed transform or not. Default to false + * wait_for_completion?: bool, // Whether to wait for the transform to fully stop before returning or not. Default to false + * timeout?: int|string, // Controls the time to wait until the transform has stopped. Default to 30 seconds + * allow_no_match?: bool, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) + * wait_for_checkpoint?: bool, // Whether to wait for the transform to reach a checkpoint before stopping. Default to false + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -412,8 +430,9 @@ public function startTransform(array $params = []) * * @return Elasticsearch|Promise */ - public function stopTransform(array $params = []) + public function stopTransform(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['transform_id'], $params); $url = '/_transform/' . $this->encode($params['transform_id']) . '/_stop'; $method = 'POST'; @@ -431,18 +450,19 @@ public function stopTransform(array $params = []) /** * Updates certain properties of a transform. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html + * @group serverless * * @param array{ * transform_id: string, // (REQUIRED) The id of the transform. - * defer_validation: boolean, // If validations should be deferred until transform starts, defaults to false. - * timeout: time, // Controls the time to wait for the update - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The update transform definition + * defer_validation?: bool, // If validations should be deferred until transform starts, defaults to false. + * timeout?: int|string, // Controls the time to wait for the update + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The update transform definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -452,8 +472,9 @@ public function stopTransform(array $params = []) * * @return Elasticsearch|Promise */ - public function updateTransform(array $params = []) + public function updateTransform(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['transform_id','body'], $params); $url = '/_transform/' . $this->encode($params['transform_id']) . '/_update'; $method = 'POST'; @@ -472,16 +493,16 @@ public function updateTransform(array $params = []) /** * Upgrades all transforms. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/upgrade-transforms.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/upgrade-transforms.html * * @param array{ - * dry_run: boolean, // Whether to only check for updates but don't execute - * timeout: time, // Controls the time to wait for the upgrade - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * dry_run?: bool, // Whether to only check for updates but don't execute + * timeout?: int|string, // Controls the time to wait for the upgrade + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -490,8 +511,9 @@ public function updateTransform(array $params = []) * * @return Elasticsearch|Promise */ - public function upgradeTransforms(array $params = []) + public function upgradeTransforms(?array $params = null) { + $params = $params ?? []; $url = '/_transform/_upgrade'; $method = 'POST'; diff --git a/src/Endpoints/Watcher.php b/src/Endpoints/Watcher.php index 872179a64..97e285f17 100644 --- a/src/Endpoints/Watcher.php +++ b/src/Endpoints/Watcher.php @@ -31,16 +31,16 @@ class Watcher extends AbstractEndpoint /** * Acknowledges a watch, manually throttling the execution of the watch's actions. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html * * @param array{ * watch_id: string, // (REQUIRED) Watch ID - * action_id: list, // A comma-separated list of the action ids to be acked - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * action_id?: string|array, // A comma-separated list of the action ids to be acked + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -50,11 +50,12 @@ class Watcher extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function ackWatch(array $params = []) + public function ackWatch(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['watch_id'], $params); if (isset($params['action_id'])) { - $url = '/_watcher/watch/' . $this->encode($params['watch_id']) . '/_ack/' . $this->encode($params['action_id']); + $url = '/_watcher/watch/' . $this->encode($params['watch_id']) . '/_ack/' . $this->encode($this->convertValue($params['action_id'])); $method = 'PUT'; } else { $url = '/_watcher/watch/' . $this->encode($params['watch_id']) . '/_ack'; @@ -73,15 +74,15 @@ public function ackWatch(array $params = []) /** * Activates a currently inactive watch. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html * * @param array{ * watch_id: string, // (REQUIRED) Watch ID - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -91,8 +92,9 @@ public function ackWatch(array $params = []) * * @return Elasticsearch|Promise */ - public function activateWatch(array $params = []) + public function activateWatch(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['watch_id'], $params); $url = '/_watcher/watch/' . $this->encode($params['watch_id']) . '/_activate'; $method = 'PUT'; @@ -110,15 +112,15 @@ public function activateWatch(array $params = []) /** * Deactivates a currently active watch. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html * * @param array{ * watch_id: string, // (REQUIRED) Watch ID - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -128,8 +130,9 @@ public function activateWatch(array $params = []) * * @return Elasticsearch|Promise */ - public function deactivateWatch(array $params = []) + public function deactivateWatch(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['watch_id'], $params); $url = '/_watcher/watch/' . $this->encode($params['watch_id']) . '/_deactivate'; $method = 'PUT'; @@ -147,15 +150,15 @@ public function deactivateWatch(array $params = []) /** * Removes a watch from Watcher. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html * * @param array{ * id: string, // (REQUIRED) Watch ID - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -165,8 +168,9 @@ public function deactivateWatch(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteWatch(array $params = []) + public function deleteWatch(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_watcher/watch/' . $this->encode($params['id']); $method = 'DELETE'; @@ -184,17 +188,17 @@ public function deleteWatch(array $params = []) /** * Forces the execution of a stored watch. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html * * @param array{ - * id: string, // Watch ID - * debug: boolean, // indicates whether the watch should execute in debug mode - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Execution control + * id?: string, // Watch ID + * debug?: bool, // indicates whether the watch should execute in debug mode + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Execution control. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -203,8 +207,9 @@ public function deleteWatch(array $params = []) * * @return Elasticsearch|Promise */ - public function executeWatch(array $params = []) + public function executeWatch(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_watcher/watch/' . $this->encode($params['id']) . '/_execute'; $method = 'PUT'; @@ -226,15 +231,15 @@ public function executeWatch(array $params = []) /** * Retrieve settings for the watcher system index * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-settings.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-settings.html * * @param array{ - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -243,8 +248,9 @@ public function executeWatch(array $params = []) * * @return Elasticsearch|Promise */ - public function getSettings(array $params = []) + public function getSettings(?array $params = null) { + $params = $params ?? []; $url = '/_watcher/settings'; $method = 'GET'; @@ -262,15 +268,15 @@ public function getSettings(array $params = []) /** * Retrieves a watch by its ID. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html * * @param array{ * id: string, // (REQUIRED) Watch ID - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -280,8 +286,9 @@ public function getSettings(array $params = []) * * @return Elasticsearch|Promise */ - public function getWatch(array $params = []) + public function getWatch(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_watcher/watch/' . $this->encode($params['id']); $method = 'GET'; @@ -299,20 +306,20 @@ public function getWatch(array $params = []) /** * Creates a new watch, or updates an existing one. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html * * @param array{ * id: string, // (REQUIRED) Watch ID - * active: boolean, // Specify whether the watch is in/active by default - * version: number, // Explicit version number for concurrency control - * if_seq_no: number, // only update the watch if the last operation that has changed the watch has the specified sequence number - * if_primary_term: number, // only update the watch if the last operation that has changed the watch has the specified primary term - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The watch + * active?: bool, // Specify whether the watch is in/active by default + * version?: int, // Explicit version number for concurrency control + * if_seq_no?: int, // only update the watch if the last operation that has changed the watch has the specified sequence number + * if_primary_term?: int, // only update the watch if the last operation that has changed the watch has the specified primary term + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The watch. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -322,8 +329,9 @@ public function getWatch(array $params = []) * * @return Elasticsearch|Promise */ - public function putWatch(array $params = []) + public function putWatch(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_watcher/watch/' . $this->encode($params['id']); $method = 'PUT'; @@ -342,15 +350,15 @@ public function putWatch(array $params = []) /** * Retrieves stored watches. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-query-watches.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-query-watches.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // From, size, query, sort and search_after + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // From, size, query, sort and search_after. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -359,8 +367,9 @@ public function putWatch(array $params = []) * * @return Elasticsearch|Promise */ - public function queryWatches(array $params = []) + public function queryWatches(?array $params = null) { + $params = $params ?? []; $url = '/_watcher/_query/watches'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -378,15 +387,15 @@ public function queryWatches(array $params = []) /** * Starts Watcher if it is not already running. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html * * @param array{ - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -395,8 +404,9 @@ public function queryWatches(array $params = []) * * @return Elasticsearch|Promise */ - public function start(array $params = []) + public function start(?array $params = null) { + $params = $params ?? []; $url = '/_watcher/_start'; $method = 'POST'; @@ -413,16 +423,16 @@ public function start(array $params = []) /** * Retrieves the current Watcher metrics. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html * * @param array{ - * metric: list, // Controls what additional stat metrics should be include in the response - * emit_stacktraces: boolean, // Emits stack traces of currently running watches - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * metric?: string|array, // Controls what additional stat metrics should be include in the response + * emit_stacktraces?: bool, // Emits stack traces of currently running watches + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -431,10 +441,11 @@ public function start(array $params = []) * * @return Elasticsearch|Promise */ - public function stats(array $params = []) + public function stats(?array $params = null) { + $params = $params ?? []; if (isset($params['metric'])) { - $url = '/_watcher/stats/' . $this->encode($params['metric']); + $url = '/_watcher/stats/' . $this->encode($this->convertValue($params['metric'])); $method = 'GET'; } else { $url = '/_watcher/stats'; @@ -453,15 +464,15 @@ public function stats(array $params = []) /** * Stops Watcher if it is running. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html * * @param array{ - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -470,8 +481,9 @@ public function stats(array $params = []) * * @return Elasticsearch|Promise */ - public function stop(array $params = []) + public function stop(?array $params = null) { + $params = $params ?? []; $url = '/_watcher/_stop'; $method = 'POST'; @@ -488,17 +500,17 @@ public function stop(array $params = []) /** * Update settings for the watcher system index * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-update-settings.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-update-settings.html * * @param array{ - * timeout: time, // Specify timeout for waiting for acknowledgement from all nodes - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) An object with the new index settings + * timeout?: int|string, // Specify timeout for waiting for acknowledgement from all nodes + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) An object with the new index settings. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -507,8 +519,9 @@ public function stop(array $params = []) * * @return Elasticsearch|Promise */ - public function updateSettings(array $params = []) + public function updateSettings(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_watcher/settings'; $method = 'PUT'; diff --git a/src/Endpoints/Xpack.php b/src/Endpoints/Xpack.php index 19b17f25e..0bc0a20f3 100644 --- a/src/Endpoints/Xpack.php +++ b/src/Endpoints/Xpack.php @@ -31,16 +31,17 @@ class Xpack extends AbstractEndpoint /** * Retrieves information about the installed X-Pack features. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html * * @param array{ - * categories: list, // Comma-separated list of info categories. Can be any of: build, license, features - * accept_enterprise: boolean, // If this param is used it must be set to true - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * human?: bool, // Defines whether additional human-readable information is included in the response. In particular, it adds descriptions and a tag line. The default value is true. + * categories?: string|array, // Comma-separated list of info categories. Can be any of: build, license, features + * accept_enterprise?: bool, // If this param is used it must be set to true + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -49,12 +50,13 @@ class Xpack extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function info(array $params = []) + public function info(?array $params = null) { + $params = $params ?? []; $url = '/_xpack'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['categories','accept_enterprise','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['human','categories','accept_enterprise','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -67,15 +69,15 @@ public function info(array $params = []) /** * Retrieves usage information about the installed X-Pack features. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/usage-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/usage-api.html * * @param array{ - * master_timeout: time, // Specify timeout for watch write operation - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Specify timeout for watch write operation + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -84,8 +86,9 @@ public function info(array $params = []) * * @return Elasticsearch|Promise */ - public function usage(array $params = []) + public function usage(?array $params = null) { + $params = $params ?? []; $url = '/_xpack/usage'; $method = 'GET'; diff --git a/src/Response/Elasticsearch.php b/src/Response/Elasticsearch.php index 267f72b12..51a77a02b 100644 --- a/src/Response/Elasticsearch.php +++ b/src/Response/Elasticsearch.php @@ -16,6 +16,7 @@ use ArrayAccess; use DateTime; +use Elastic\Elasticsearch\Client; use Elastic\Elasticsearch\Exception\ArrayAccessException; use Elastic\Elasticsearch\Exception\ClientResponseException; use Elastic\Elasticsearch\Exception\ServerResponseException; @@ -44,6 +45,7 @@ class Elasticsearch implements ElasticsearchInterface, ResponseInterface, ArrayA protected array $asArray; protected object $asObject; protected string $asString; + protected bool $serverless = false; /** * The PSR-7 response @@ -62,6 +64,8 @@ class Elasticsearch implements ElasticsearchInterface, ResponseInterface, ArrayA public function setResponse(ResponseInterface $response, bool $throwException = true): void { $this->productCheck($response); + // Check for Serverless response + $this->serverless = $this->isServerlessResponse($response); $this->response = $response; $status = $response->getStatusCode(); if ($throwException && $status > 399 && $status < 500) { @@ -79,6 +83,22 @@ public function setResponse(ResponseInterface $response, bool $throwException = } } + /** + * Check whether the response is from Serverless + */ + private function isServerlessResponse(ResponseInterface $response): bool + { + return !empty($response->getHeader(Client::API_VERSION_HEADER)); + } + + /** + * Return true if the response is from Serverless + */ + public function isServerless(): bool + { + return $this->serverless; + } + /** * Return true if status code is 2xx */ diff --git a/src/Traits/ClientEndpointsTrait.php b/src/Traits/ClientEndpointsTrait.php index e2cfe6199..a91dd908f 100644 --- a/src/Traits/ClientEndpointsTrait.php +++ b/src/Traits/ClientEndpointsTrait.php @@ -31,28 +31,29 @@ trait ClientEndpointsTrait /** * Allows to perform multiple index/update/delete operations in a single request. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html + * @group serverless * * @param array{ - * index: string, // Default index for items which don't provide one - * wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - * routing: string, // Specific routing value - * timeout: time, // Explicit operation timeout - * type: string, // Default document type for items which don't provide one - * _source: list, // True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request - * _source_excludes: list, // Default list of fields to exclude from the returned _source field, can be overridden on each sub-request - * _source_includes: list, // Default list of fields to extract and return from the _source field, can be overridden on each sub-request - * pipeline: string, // The pipeline id to preprocess incoming documents with - * require_alias: boolean, // Sets require_alias for all incoming documents. Defaults to unset (false) - * require_data_stream: boolean, // When true, requires the destination to be a data stream (existing or to-be-created). Default is false - * list_executed_pipelines: boolean, // Sets list_executed_pipelines for all incoming documents. Defaults to unset (false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The operation definition and data (action-data pairs), separated by newlines + * index?: string, // Default index for items which don't provide one + * wait_for_active_shards?: string, // Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * refresh?: string, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * routing?: string, // Specific routing value + * timeout?: int|string, // Explicit operation timeout + * _source?: string|array, // True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request + * _source_excludes?: string|array, // Default list of fields to exclude from the returned _source field, can be overridden on each sub-request + * _source_includes?: string|array, // Default list of fields to extract and return from the _source field, can be overridden on each sub-request + * pipeline?: string, // The pipeline id to preprocess incoming documents with + * require_alias?: bool, // If true, the request’s actions must target an index alias. Defaults to false. + * require_data_stream?: bool, // If true, the request's actions must target a data stream (existing or to-be-created). Default to false + * list_executed_pipelines?: bool, // Sets list_executed_pipelines for all incoming documents. Defaults to unset (false) + * include_source_on_error?: bool, // True or false if to include the document source in the error message in case of parsing errors. Defaults to true. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The operation definition and data (action-data pairs), separated by newlines. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -61,8 +62,9 @@ trait ClientEndpointsTrait * * @return Elasticsearch|Promise */ - public function bulk(array $params = []) + public function bulk(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['index'])) { $url = '/' . $this->encode($params['index']) . '/_bulk'; @@ -71,7 +73,7 @@ public function bulk(array $params = []) $url = '/_bulk'; $method = 'POST'; } - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','type','_source','_source_excludes','_source_includes','pipeline','require_alias','require_data_stream','list_executed_pipelines','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','_source','_source_excludes','_source_includes','pipeline','require_alias','require_data_stream','list_executed_pipelines','include_source_on_error','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/x-ndjson', @@ -85,16 +87,17 @@ public function bulk(array $params = []) /** * Explicitly clears the search context for a scroll. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-scroll-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-scroll-api.html + * @group serverless * * @param array{ - * scroll_id: list, // A comma-separated list of scroll IDs to clear - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter + * scroll_id?: string|array, // A comma-separated list of scroll IDs to clear + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -103,10 +106,11 @@ public function bulk(array $params = []) * * @return Elasticsearch|Promise */ - public function clearScroll(array $params = []) + public function clearScroll(?array $params = null) { + $params = $params ?? []; if (isset($params['scroll_id'])) { - $url = '/_search/scroll/' . $this->encode($params['scroll_id']); + $url = '/_search/scroll/' . $this->encode($this->convertValue($params['scroll_id'])); $method = 'DELETE'; } else { $url = '/_search/scroll'; @@ -126,15 +130,16 @@ public function clearScroll(array $params = []) /** * Close a point in time * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // a point-in-time id to close + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // a point-in-time id to close. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -143,8 +148,9 @@ public function clearScroll(array $params = []) * * @return Elasticsearch|Promise */ - public function closePointInTime(array $params = []) + public function closePointInTime(?array $params = null) { + $params = $params ?? []; $url = '/_pit'; $method = 'DELETE'; @@ -162,30 +168,31 @@ public function closePointInTime(array $params = []) /** * Returns number of documents matching a query. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of indices to restrict the results - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * ignore_throttled: boolean, // Whether specified concrete, expanded or aliased indices should be ignored when throttled - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * min_score: number, // Include only documents with a specific `_score` value in the result - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * routing: list, // A comma-separated list of specific routing values - * q: string, // Query in the Lucene query string syntax - * analyzer: string, // The analyzer to use for the query string - * analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false) - * default_operator: enum, // The default operator for query string query (AND or OR) - * df: string, // The field to use as default where no field prefix is given in the query string - * lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - * terminate_after: number, // The maximum count for each shard, upon reaching which the query execution will terminate early - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // A query to restrict the results specified with the Query DSL (optional) + * index?: string|array, // A comma-separated list of indices to restrict the results + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * ignore_throttled?: bool, // Whether specified concrete, expanded or aliased indices should be ignored when throttled + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * min_score?: int, // Include only documents with a specific `_score` value in the result + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * routing?: string|array, // A comma-separated list of specific routing values + * q?: string, // Query in the Lucene query string syntax + * analyzer?: string, // The analyzer to use for the query string + * analyze_wildcard?: bool, // Specify whether wildcard and prefix queries should be analyzed (default: false) + * default_operator?: string, // The default operator for query string query (AND or OR) + * df?: string, // The field to use as default where no field prefix is given in the query string + * lenient?: bool, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * terminate_after?: int, // The maximum count for each shard, upon reaching which the query execution will terminate early + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // A query to restrict the results specified with the Query DSL (optional). If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -194,10 +201,11 @@ public function closePointInTime(array $params = []) * * @return Elasticsearch|Promise */ - public function count(array $params = []) + public function count(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_count'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_count'; $method = empty($params['body']) ? 'GET' : 'POST'; } else { $url = '/_count'; @@ -219,24 +227,26 @@ public function count(array $params = []) * * Returns a 409 response when a document with a same ID already exists in the index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) Document ID * index: string, // (REQUIRED) The name of the index - * wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - * routing: string, // Specific routing value - * timeout: time, // Explicit operation timeout - * version: number, // Explicit version number for concurrency control - * version_type: enum, // Specific version type - * pipeline: string, // The pipeline id to preprocess incoming documents with - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The document + * wait_for_active_shards?: string, // Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * refresh?: string, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * routing?: string, // Specific routing value + * timeout?: int|string, // Explicit operation timeout + * version?: int, // Explicit version number for concurrency control + * version_type?: string, // Specific version type + * pipeline?: string, // The pipeline id to preprocess incoming documents with + * include_source_on_error?: bool, // True or false if to include the document source in the error message in case of parsing errors. Defaults to true. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The document. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -246,13 +256,14 @@ public function count(array $params = []) * * @return Elasticsearch|Promise */ - public function create(array $params = []) + public function create(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','index','body'], $params); $url = '/' . $this->encode($params['index']) . '/_create/' . $this->encode($params['id']); $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','version','version_type','pipeline','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','version','version_type','pipeline','include_source_on_error','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -266,24 +277,25 @@ public function create(array $params = []) /** * Removes a document from the index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The document ID * index: string, // (REQUIRED) The name of the index - * wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - * routing: string, // Specific routing value - * timeout: time, // Explicit operation timeout - * if_seq_no: number, // only perform the delete operation if the last operation that has changed the document has the specified sequence number - * if_primary_term: number, // only perform the delete operation if the last operation that has changed the document has the specified primary term - * version: number, // Explicit version number for concurrency control - * version_type: enum, // Specific version type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * wait_for_active_shards?: string, // Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * refresh?: string, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * routing?: string, // Specific routing value + * timeout?: int|string, // Explicit operation timeout + * if_seq_no?: int, // only perform the delete operation if the last operation that has changed the document has the specified sequence number + * if_primary_term?: int, // only perform the delete operation if the last operation that has changed the document has the specified primary term + * version?: int, // Explicit version number for concurrency control + * version_type?: string, // Specific version type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -293,8 +305,9 @@ public function create(array $params = []) * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function delete(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','index'], $params); $url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']); $method = 'DELETE'; @@ -312,45 +325,46 @@ public function delete(array $params = []) /** * Deletes documents matching the provided query. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * analyzer: string, // The analyzer to use for the query string - * analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false) - * default_operator: enum, // The default operator for query string query (AND or OR) - * df: string, // The field to use as default where no field prefix is given in the query string - * from: number, // Starting offset (default: 0) - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * conflicts: enum, // What to do when the delete by query hits version conflicts? - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * q: string, // Query in the Lucene query string syntax - * routing: list, // A comma-separated list of specific routing values - * scroll: time, // Specify how long a consistent view of the index should be maintained for scrolled search - * search_type: enum, // Search operation type - * search_timeout: time, // Explicit timeout for each search request. Defaults to no timeout. - * max_docs: number, // Maximum number of documents to process (default: all documents) - * sort: list, // A comma-separated list of : pairs - * terminate_after: number, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - * stats: list, // Specific 'tag' of the request for logging and statistical purposes - * version: boolean, // Specify whether to return document version as part of a hit - * request_cache: boolean, // Specify if request cache should be used for this request or not, defaults to index level setting - * refresh: boolean, // Should the affected indexes be refreshed? - * timeout: time, // Time each individual bulk request should wait for shards that are unavailable. - * wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * scroll_size: number, // Size on the scroll request powering the delete by query - * wait_for_completion: boolean, // Should the request should block until the delete by query is complete. - * requests_per_second: number, // The throttle for this request in sub-requests per second. -1 means no throttle. - * slices: number|string, // The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The search definition using the Query DSL + * index: string|array, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * analyzer?: string, // The analyzer to use for the query string + * analyze_wildcard?: bool, // Specify whether wildcard and prefix queries should be analyzed (default: false) + * default_operator?: string, // The default operator for query string query (AND or OR) + * df?: string, // The field to use as default where no field prefix is given in the query string + * from?: int, // Starting offset (default: 0) + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * conflicts?: string, // What to do when the delete by query hits version conflicts? + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * lenient?: bool, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * q?: string, // Query in the Lucene query string syntax + * routing?: string|array, // A comma-separated list of specific routing values + * scroll?: int|string, // Specify how long a consistent view of the index should be maintained for scrolled search + * search_type?: string, // Search operation type + * search_timeout?: int|string, // Explicit timeout for each search request. Defaults to no timeout. + * max_docs?: int, // Maximum number of documents to process (default: all documents) + * sort?: string|array, // A comma-separated list of : pairs + * terminate_after?: int, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * stats?: string|array, // Specific 'tag' of the request for logging and statistical purposes + * version?: bool, // Specify whether to return document version as part of a hit + * request_cache?: bool, // Specify if request cache should be used for this request or not, defaults to index level setting + * refresh?: bool, // Should the affected indexes be refreshed? + * timeout?: int|string, // Time each individual bulk request should wait for shards that are unavailable. + * wait_for_active_shards?: string, // Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * scroll_size?: int, // Size on the scroll request powering the delete by query + * wait_for_completion?: bool, // Should the request should block until the delete by query is complete. + * requests_per_second?: int, // The throttle for this request in sub-requests per second. -1 means no throttle. + * slices?: int|string, // The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The search definition using the Query DSL. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -360,10 +374,11 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteByQuery(array $params = []) + public function deleteByQuery(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','body'], $params); - $url = '/' . $this->encode($params['index']) . '/_delete_by_query'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_delete_by_query'; $method = 'POST'; $url = $this->addQueryString($url, $params, ['analyzer','analyze_wildcard','default_operator','df','from','ignore_unavailable','allow_no_indices','conflicts','expand_wildcards','lenient','preference','q','routing','scroll','search_type','search_timeout','max_docs','sort','terminate_after','stats','version','request_cache','refresh','timeout','wait_for_active_shards','scroll_size','wait_for_completion','requests_per_second','slices','pretty','human','error_trace','source','filter_path']); @@ -380,16 +395,16 @@ public function deleteByQuery(array $params = []) /** * Changes the number of requests per second for a particular Delete By Query operation. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html * * @param array{ * task_id: string, // (REQUIRED) The task id to rethrottle - * requests_per_second: number, // The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * requests_per_second?: int, // The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -399,8 +414,9 @@ public function deleteByQuery(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteByQueryRethrottle(array $params = []) + public function deleteByQueryRethrottle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['task_id','requests_per_second'], $params); $url = '/_delete_by_query/' . $this->encode($params['task_id']) . '/_rethrottle'; $method = 'POST'; @@ -418,17 +434,18 @@ public function deleteByQueryRethrottle(array $params = []) /** * Deletes a script. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) Script ID - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -438,8 +455,9 @@ public function deleteByQueryRethrottle(array $params = []) * * @return Elasticsearch|Promise */ - public function deleteScript(array $params = []) + public function deleteScript(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_scripts/' . $this->encode($params['id']); $method = 'DELETE'; @@ -457,26 +475,27 @@ public function deleteScript(array $params = []) /** * Returns information about whether a document exists in an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The document ID * index: string, // (REQUIRED) The name of the index - * stored_fields: list, // A comma-separated list of stored fields to return in the response - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * realtime: boolean, // Specify whether to perform the operation in realtime or search mode - * refresh: boolean, // Refresh the shard containing the document before performing the operation - * routing: string, // Specific routing value - * _source: list, // True or false to return the _source field or not, or a list of fields to return - * _source_excludes: list, // A list of fields to exclude from the returned _source field - * _source_includes: list, // A list of fields to extract and return from the _source field - * version: number, // Explicit version number for concurrency control - * version_type: enum, // Specific version type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * stored_fields?: string|array, // A comma-separated list of stored fields to return in the response + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * realtime?: bool, // Specify whether to perform the operation in realtime or search mode + * refresh?: bool, // Refresh the shard containing the document before performing the operation + * routing?: string, // Specific routing value + * _source?: string|array, // True or false to return the _source field or not, or a list of fields to return + * _source_excludes?: string|array, // A list of fields to exclude from the returned _source field + * _source_includes?: string|array, // A list of fields to extract and return from the _source field + * version?: int, // Explicit version number for concurrency control + * version_type?: string, // Specific version type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -486,8 +505,9 @@ public function deleteScript(array $params = []) * * @return Elasticsearch|Promise */ - public function exists(array $params = []) + public function exists(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','index'], $params); $url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']); $method = 'HEAD'; @@ -505,25 +525,26 @@ public function exists(array $params = []) /** * Returns information about whether a document source exists in an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The document ID * index: string, // (REQUIRED) The name of the index - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * realtime: boolean, // Specify whether to perform the operation in realtime or search mode - * refresh: boolean, // Refresh the shard containing the document before performing the operation - * routing: string, // Specific routing value - * _source: list, // True or false to return the _source field or not, or a list of fields to return - * _source_excludes: list, // A list of fields to exclude from the returned _source field - * _source_includes: list, // A list of fields to extract and return from the _source field - * version: number, // Explicit version number for concurrency control - * version_type: enum, // Specific version type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * realtime?: bool, // Specify whether to perform the operation in realtime or search mode + * refresh?: bool, // Refresh the shard containing the document before performing the operation + * routing?: string, // Specific routing value + * _source?: string|array, // True or false to return the _source field or not, or a list of fields to return + * _source_excludes?: string|array, // A list of fields to exclude from the returned _source field + * _source_includes?: string|array, // A list of fields to extract and return from the _source field + * version?: int, // Explicit version number for concurrency control + * version_type?: string, // Specific version type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -533,8 +554,9 @@ public function exists(array $params = []) * * @return Elasticsearch|Promise */ - public function existsSource(array $params = []) + public function existsSource(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','index'], $params); $url = '/' . $this->encode($params['index']) . '/_source/' . $this->encode($params['id']); $method = 'HEAD'; @@ -552,29 +574,30 @@ public function existsSource(array $params = []) /** * Returns information about why a specific matches (or doesn't match) a query. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The document ID * index: string, // (REQUIRED) The name of the index - * analyze_wildcard: boolean, // Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) - * analyzer: string, // The analyzer for the query string query - * default_operator: enum, // The default operator for query string query (AND or OR) - * df: string, // The default field for query string query (default: _all) - * stored_fields: list, // A comma-separated list of stored fields to return in the response - * lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * q: string, // Query in the Lucene query string syntax - * routing: string, // Specific routing value - * _source: list, // True or false to return the _source field or not, or a list of fields to return - * _source_excludes: list, // A list of fields to exclude from the returned _source field - * _source_includes: list, // A list of fields to extract and return from the _source field - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The query definition using the Query DSL + * analyze_wildcard?: bool, // Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) + * analyzer?: string, // The analyzer for the query string query + * default_operator?: string, // The default operator for query string query (AND or OR) + * df?: string, // The default field for query string query (default: _all) + * stored_fields?: string|array, // A comma-separated list of stored fields to return in the response + * lenient?: bool, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * q?: string, // Query in the Lucene query string syntax + * routing?: string, // Specific routing value + * _source?: string|array, // True or false to return the _source field or not, or a list of fields to return + * _source_excludes?: string|array, // A list of fields to exclude from the returned _source field + * _source_includes?: string|array, // A list of fields to extract and return from the _source field + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The query definition using the Query DSL. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -584,8 +607,9 @@ public function existsSource(array $params = []) * * @return Elasticsearch|Promise */ - public function explain(array $params = []) + public function explain(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','index'], $params); $url = '/' . $this->encode($params['index']) . '/_explain/' . $this->encode($params['id']); $method = empty($params['body']) ? 'GET' : 'POST'; @@ -604,24 +628,25 @@ public function explain(array $params = []) /** * Returns the information about the capabilities of fields among multiple indices. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * fields: list, // A comma-separated list of field names - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * include_unmapped: boolean, // Indicates whether unmapped fields should be included in the response. - * filters: list, // An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent - * types: list, // Only return results for fields that have one of the types in the list - * include_empty_fields: boolean, // Include empty fields in result - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // An index filter specified with the Query DSL + * index?: string|array, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * fields?: string|array, // A comma-separated list of field names + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * include_unmapped?: bool, // Indicates whether unmapped fields should be included in the response. + * filters?: string|array, // An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent + * types?: string|array, // Only return results for fields that have one of the types in the list + * include_empty_fields?: bool, // Include empty fields in result + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // An index filter specified with the Query DSL. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -630,10 +655,11 @@ public function explain(array $params = []) * * @return Elasticsearch|Promise */ - public function fieldCaps(array $params = []) + public function fieldCaps(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_field_caps'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_field_caps'; $method = empty($params['body']) ? 'GET' : 'POST'; } else { $url = '/_field_caps'; @@ -653,27 +679,28 @@ public function fieldCaps(array $params = []) /** * Returns a document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The document ID * index: string, // (REQUIRED) The name of the index - * force_synthetic_source: boolean, // Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. - * stored_fields: list, // A comma-separated list of stored fields to return in the response - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * realtime: boolean, // Specify whether to perform the operation in realtime or search mode - * refresh: boolean, // Refresh the shard containing the document before performing the operation - * routing: string, // Specific routing value - * _source: list, // True or false to return the _source field or not, or a list of fields to return - * _source_excludes: list, // A list of fields to exclude from the returned _source field - * _source_includes: list, // A list of fields to extract and return from the _source field - * version: number, // Explicit version number for concurrency control - * version_type: enum, // Specific version type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * force_synthetic_source?: bool, // Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. + * stored_fields?: string|array, // A comma-separated list of stored fields to return in the response + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * realtime?: bool, // Specify whether to perform the operation in realtime or search mode + * refresh?: bool, // Refresh the shard containing the document before performing the operation + * routing?: string, // Specific routing value + * _source?: string|array, // True or false to return the _source field or not, or a list of fields to return + * _source_excludes?: string|array, // A list of fields to exclude from the returned _source field + * _source_includes?: string|array, // A list of fields to extract and return from the _source field + * version?: int, // Explicit version number for concurrency control + * version_type?: string, // Specific version type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -683,8 +710,9 @@ public function fieldCaps(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function get(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','index'], $params); $url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']); $method = 'GET'; @@ -702,16 +730,17 @@ public function get(array $params = []) /** * Returns a script. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) Script ID - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -721,8 +750,9 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function getScript(array $params = []) + public function getScript(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id'], $params); $url = '/_scripts/' . $this->encode($params['id']); $method = 'GET'; @@ -740,14 +770,14 @@ public function getScript(array $params = []) /** * Returns all script contexts. * - * @see https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html + * @link https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -756,8 +786,9 @@ public function getScript(array $params = []) * * @return Elasticsearch|Promise */ - public function getScriptContext(array $params = []) + public function getScriptContext(?array $params = null) { + $params = $params ?? []; $url = '/_script_context'; $method = 'GET'; @@ -774,14 +805,14 @@ public function getScriptContext(array $params = []) /** * Returns available script types, languages and contexts * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -790,8 +821,9 @@ public function getScriptContext(array $params = []) * * @return Elasticsearch|Promise */ - public function getScriptLanguages(array $params = []) + public function getScriptLanguages(?array $params = null) { + $params = $params ?? []; $url = '/_script_language'; $method = 'GET'; @@ -808,25 +840,26 @@ public function getScriptLanguages(array $params = []) /** * Returns the source of a document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) The document ID * index: string, // (REQUIRED) The name of the index - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * realtime: boolean, // Specify whether to perform the operation in realtime or search mode - * refresh: boolean, // Refresh the shard containing the document before performing the operation - * routing: string, // Specific routing value - * _source: list, // True or false to return the _source field or not, or a list of fields to return - * _source_excludes: list, // A list of fields to exclude from the returned _source field - * _source_includes: list, // A list of fields to extract and return from the _source field - * version: number, // Explicit version number for concurrency control - * version_type: enum, // Specific version type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * realtime?: bool, // Specify whether to perform the operation in realtime or search mode + * refresh?: bool, // Refresh the shard containing the document before performing the operation + * routing?: string, // Specific routing value + * _source?: string|array, // True or false to return the _source field or not, or a list of fields to return + * _source_excludes?: string|array, // A list of fields to exclude from the returned _source field + * _source_includes?: string|array, // A list of fields to extract and return from the _source field + * version?: int, // Explicit version number for concurrency control + * version_type?: string, // Specific version type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -836,8 +869,9 @@ public function getScriptLanguages(array $params = []) * * @return Elasticsearch|Promise */ - public function getSource(array $params = []) + public function getSource(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','index'], $params); $url = '/' . $this->encode($params['index']) . '/_source/' . $this->encode($params['id']); $method = 'GET'; @@ -855,18 +889,18 @@ public function getSource(array $params = []) /** * Returns the health of the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/health-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/health-api.html * * @param array{ - * feature: string, // A feature of the cluster, as returned by the top-level health API - * timeout: time, // Explicit operation timeout - * verbose: boolean, // Opt in for more information about the health of the system - * size: int, // Limit the number of affected resources the health API returns - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * feature?: string, // A feature of the cluster, as returned by the top-level health API + * timeout?: int|string, // Explicit operation timeout + * verbose?: bool, // Opt in for more information about the health of the system + * size?: int, // Limit the number of affected resources the health API returns + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -875,8 +909,9 @@ public function getSource(array $params = []) * * @return Elasticsearch|Promise */ - public function healthReport(array $params = []) + public function healthReport(?array $params = null) { + $params = $params ?? []; if (isset($params['feature'])) { $url = '/_health_report/' . $this->encode($params['feature']); $method = 'GET'; @@ -897,29 +932,31 @@ public function healthReport(array $params = []) /** * Creates or updates a document in an index. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html + * @group serverless * * @param array{ - * id: string, // Document ID + * id?: string, // Document ID * index: string, // (REQUIRED) The name of the index - * wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * op_type: enum, // Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID - * refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - * routing: string, // Specific routing value - * timeout: time, // Explicit operation timeout - * version: number, // Explicit version number for concurrency control - * version_type: enum, // Specific version type - * if_seq_no: number, // only perform the index operation if the last operation that has changed the document has the specified sequence number - * if_primary_term: number, // only perform the index operation if the last operation that has changed the document has the specified primary term - * pipeline: string, // The pipeline id to preprocess incoming documents with - * require_alias: boolean, // When true, requires destination to be an alias. Default is false - * require_data_stream: boolean, // When true, requires the destination to be a data stream (existing or to-be-created). Default is false - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The document + * wait_for_active_shards?: string, // Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * op_type?: string, // Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID + * refresh?: string, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * routing?: string, // Specific routing value + * timeout?: int|string, // Explicit operation timeout + * version?: int, // Explicit version number for concurrency control + * version_type?: string, // Specific version type + * if_seq_no?: int, // only perform the index operation if the last operation that has changed the document has the specified sequence number + * if_primary_term?: int, // only perform the index operation if the last operation that has changed the document has the specified primary term + * pipeline?: string, // The pipeline id to preprocess incoming documents with + * require_alias?: bool, // When true, requires destination to be an alias. Default is false + * require_data_stream?: bool, // When true, requires the destination to be a data stream (existing or to-be-created). Default is false + * include_source_on_error?: bool, // True or false if to include the document source in the error message in case of parsing errors. Defaults to true. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The document. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -929,8 +966,9 @@ public function healthReport(array $params = []) * * @return Elasticsearch|Promise */ - public function index(array $params = []) + public function index(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','body'], $params); if (isset($params['id'])) { $url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']); @@ -939,7 +977,7 @@ public function index(array $params = []) $url = '/' . $this->encode($params['index']) . '/_doc'; $method = 'POST'; } - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','op_type','refresh','routing','timeout','version','version_type','if_seq_no','if_primary_term','pipeline','require_alias','require_data_stream','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['wait_for_active_shards','op_type','refresh','routing','timeout','version','version_type','if_seq_no','if_primary_term','pipeline','require_alias','require_data_stream','include_source_on_error','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -953,14 +991,15 @@ public function index(array $params = []) /** * Returns basic information about the cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -969,8 +1008,9 @@ public function index(array $params = []) * * @return Elasticsearch|Promise */ - public function info(array $params = []) + public function info(?array $params = null) { + $params = $params ?? []; $url = '/'; $method = 'GET'; @@ -987,18 +1027,18 @@ public function info(array $params = []) /** * Performs a kNN search. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names to search; use `_all` to perform the operation on all indices - * routing: list, // A comma-separated list of specific routing values - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The search definition + * index: string|array, // (REQUIRED) A comma-separated list of index names to search; use `_all` to perform the operation on all indices + * routing?: string|array, // A comma-separated list of specific routing values + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The search definition. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1008,10 +1048,11 @@ public function info(array $params = []) * * @return Elasticsearch|Promise */ - public function knnSearch(array $params = []) + public function knnSearch(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']) . '/_knn_search'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_knn_search'; $method = empty($params['body']) ? 'GET' : 'POST'; $url = $this->addQueryString($url, $params, ['routing','pretty','human','error_trace','source','filter_path']); @@ -1028,25 +1069,26 @@ public function knnSearch(array $params = []) /** * Allows to get multiple documents in one request. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html + * @group serverless * * @param array{ - * index: string, // The name of the index - * force_synthetic_source: boolean, // Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. - * stored_fields: list, // A comma-separated list of stored fields to return in the response - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * realtime: boolean, // Specify whether to perform the operation in realtime or search mode - * refresh: boolean, // Refresh the shard containing the document before performing the operation - * routing: string, // Specific routing value - * _source: list, // True or false to return the _source field or not, or a list of fields to return - * _source_excludes: list, // A list of fields to exclude from the returned _source field - * _source_includes: list, // A list of fields to extract and return from the _source field - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL. + * index?: string, // The name of the index + * force_synthetic_source?: bool, // Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. + * stored_fields?: string|array, // A comma-separated list of stored fields to return in the response + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * realtime?: bool, // Specify whether to perform the operation in realtime or search mode + * refresh?: bool, // Refresh the shard containing the document before performing the operation + * routing?: string, // Specific routing value + * _source?: string|array, // True or false to return the _source field or not, or a list of fields to return + * _source_excludes?: string|array, // A list of fields to exclude from the returned _source field + * _source_includes?: string|array, // A list of fields to extract and return from the _source field + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1055,8 +1097,9 @@ public function knnSearch(array $params = []) * * @return Elasticsearch|Promise */ - public function mget(array $params = []) + public function mget(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['index'])) { $url = '/' . $this->encode($params['index']) . '/_mget'; @@ -1079,23 +1122,24 @@ public function mget(array $params = []) /** * Allows to execute several search operations in one request. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names to use as default - * search_type: enum, // Search operation type - * max_concurrent_searches: number, // Controls the maximum number of concurrent searches the multi search api will execute - * typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response - * pre_filter_shard_size: number, // A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. - * max_concurrent_shard_requests: number, // The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests - * rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response - * ccs_minimize_roundtrips: boolean, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The request definitions (metadata-search request definition pairs), separated by newlines + * index?: string|array, // A comma-separated list of index names to use as default + * search_type?: string, // Search operation type + * max_concurrent_searches?: int, // Controls the maximum number of concurrent searches the multi search api will execute + * typed_keys?: bool, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * pre_filter_shard_size?: int, // A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + * max_concurrent_shard_requests?: int, // The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + * rest_total_hits_as_int?: bool, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * ccs_minimize_roundtrips?: bool, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The request definitions (metadata-search request definition pairs), separated by newlines. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1104,11 +1148,12 @@ public function mget(array $params = []) * * @return Elasticsearch|Promise */ - public function msearch(array $params = []) + public function msearch(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_msearch'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_msearch'; $method = empty($params['body']) ? 'GET' : 'POST'; } else { $url = '/_msearch'; @@ -1128,21 +1173,22 @@ public function msearch(array $params = []) /** * Allows to execute several search template operations in one request. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names to use as default - * search_type: enum, // Search operation type - * typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response - * max_concurrent_searches: number, // Controls the maximum number of concurrent searches the multi search api will execute - * rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response - * ccs_minimize_roundtrips: boolean, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The request definitions (metadata-search request definition pairs), separated by newlines + * index?: string|array, // A comma-separated list of index names to use as default + * search_type?: string, // Search operation type + * typed_keys?: bool, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * max_concurrent_searches?: int, // Controls the maximum number of concurrent searches the multi search api will execute + * rest_total_hits_as_int?: bool, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * ccs_minimize_roundtrips?: bool, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The request definitions (metadata-search request definition pairs), separated by newlines. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1151,11 +1197,12 @@ public function msearch(array $params = []) * * @return Elasticsearch|Promise */ - public function msearchTemplate(array $params = []) + public function msearchTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_msearch/template'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_msearch/template'; $method = empty($params['body']) ? 'GET' : 'POST'; } else { $url = '/_msearch/template'; @@ -1175,28 +1222,29 @@ public function msearchTemplate(array $params = []) /** * Returns multiple termvectors in one request. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html + * @group serverless * * @param array{ - * index: string, // The index in which the document resides. - * ids: list, // A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body - * term_statistics: boolean, // Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - * field_statistics: boolean, // Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - * fields: list, // A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". - * offsets: boolean, // Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - * positions: boolean, // Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - * payloads: boolean, // Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - * preference: string, // Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". - * routing: string, // Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". - * realtime: boolean, // Specifies if requests are real-time as opposed to near-real-time (default: true). - * version: number, // Explicit version number for concurrency control - * version_type: enum, // Specific version type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. + * index?: string, // The index in which the document resides. + * ids?: string|array, // A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body + * term_statistics?: bool, // Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * field_statistics?: bool, // Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * fields?: string|array, // A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * offsets?: bool, // Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * positions?: bool, // Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * payloads?: bool, // Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". + * routing?: string, // Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * realtime?: bool, // Specifies if requests are real-time as opposed to near-real-time (default: true). + * version?: int, // Explicit version number for concurrency control + * version_type?: string, // Specific version type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1205,8 +1253,9 @@ public function msearchTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function mtermvectors(array $params = []) + public function mtermvectors(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { $url = '/' . $this->encode($params['index']) . '/_mtermvectors'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1228,21 +1277,23 @@ public function mtermvectors(array $params = []) /** * Open a point in time that can be used in subsequent searches * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names to open point in time; use `_all` or empty string to perform the operation on all indices - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * routing: string, // Specific routing value - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * keep_alive: string, // Specific the time to live for the point in time - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // An index_filter specified with the Query DSL + * index: string|array, // (REQUIRED) A comma-separated list of index names to open point in time; use `_all` or empty string to perform the operation on all indices + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * routing?: string, // Specific routing value + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * keep_alive?: string, // Specific the time to live for the point in time + * allow_partial_search_results?: bool, // Specify whether to tolerate shards missing when creating the point-in-time, or otherwise throw an exception. (default: false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // An index_filter specified with the Query DSL. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1252,13 +1303,14 @@ public function mtermvectors(array $params = []) * * @return Elasticsearch|Promise */ - public function openPointInTime(array $params = []) + public function openPointInTime(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','keep_alive'], $params); - $url = '/' . $this->encode($params['index']) . '/_pit'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_pit'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['preference','routing','ignore_unavailable','expand_wildcards','keep_alive','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['preference','routing','ignore_unavailable','expand_wildcards','keep_alive','allow_partial_search_results','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -1272,14 +1324,15 @@ public function openPointInTime(array $params = []) /** * Returns whether the cluster is running. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html + * @group serverless * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1288,8 +1341,9 @@ public function openPointInTime(array $params = []) * * @return Elasticsearch|Promise */ - public function ping(array $params = []) + public function ping(?array $params = null) { + $params = $params ?? []; $url = '/'; $method = 'HEAD'; @@ -1306,19 +1360,20 @@ public function ping(array $params = []) /** * Creates or updates a script. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) Script ID - * context: string, // Script context - * timeout: time, // Explicit operation timeout - * master_timeout: time, // Specify timeout for connection to master - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The document + * context?: string, // Script context + * timeout?: int|string, // Explicit operation timeout + * master_timeout?: int|string, // Specify timeout for connection to master + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The document. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1328,8 +1383,9 @@ public function ping(array $params = []) * * @return Elasticsearch|Promise */ - public function putScript(array $params = []) + public function putScript(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','body'], $params); if (isset($params['context'])) { $url = '/_scripts/' . $this->encode($params['id']) . '/' . $this->encode($params['context']); @@ -1352,20 +1408,21 @@ public function putScript(array $params = []) /** * Allows to evaluate the quality of ranked search results over a set of typical search queries * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * search_type: enum, // Search operation type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. + * index?: string|array, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * search_type?: string, // Search operation type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The ranking evaluation search definition, including search requests, document ratings and ranking metric definition.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1374,11 +1431,12 @@ public function putScript(array $params = []) * * @return Elasticsearch|Promise */ - public function rankEval(array $params = []) + public function rankEval(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_rank_eval'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_rank_eval'; $method = empty($params['body']) ? 'GET' : 'POST'; } else { $url = '/_rank_eval'; @@ -1400,23 +1458,24 @@ public function rankEval(array $params = []) * documents by a query, changing the destination index settings, or fetching the * documents from a remote cluster. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html + * @group serverless * * @param array{ - * refresh: boolean, // Should the affected indexes be refreshed? - * timeout: time, // Time each individual bulk request should wait for shards that are unavailable. - * wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * wait_for_completion: boolean, // Should the request should block until the reindex is complete. - * requests_per_second: number, // The throttle to set on this request in sub-requests per second. -1 means no throttle. - * scroll: time, // Control how long to keep the search context alive - * slices: number|string, // The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. - * max_docs: number, // Maximum number of documents to process (default: all documents) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The search definition using the Query DSL and the prototype for the index request. + * refresh?: bool, // Should the affected indexes be refreshed? + * timeout?: int|string, // Time each individual bulk request should wait for shards that are unavailable. + * wait_for_active_shards?: string, // Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * wait_for_completion?: bool, // Should the request should block until the reindex is complete. + * requests_per_second?: int, // The throttle to set on this request in sub-requests per second. -1 means no throttle. + * scroll?: int|string, // Control how long to keep the search context alive + * slices?: int|string, // The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + * max_docs?: int, // Maximum number of documents to process (default: all documents) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The search definition using the Query DSL and the prototype for the index request.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1425,8 +1484,9 @@ public function rankEval(array $params = []) * * @return Elasticsearch|Promise */ - public function reindex(array $params = []) + public function reindex(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); $url = '/_reindex'; $method = 'POST'; @@ -1445,16 +1505,16 @@ public function reindex(array $params = []) /** * Changes the number of requests per second for a particular Reindex operation. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html * * @param array{ * task_id: string, // (REQUIRED) The task id to rethrottle - * requests_per_second: number, // The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * requests_per_second?: int, // The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1464,8 +1524,9 @@ public function reindex(array $params = []) * * @return Elasticsearch|Promise */ - public function reindexRethrottle(array $params = []) + public function reindexRethrottle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['task_id','requests_per_second'], $params); $url = '/_reindex/' . $this->encode($params['task_id']) . '/_rethrottle'; $method = 'POST'; @@ -1483,16 +1544,17 @@ public function reindexRethrottle(array $params = []) /** * Allows to use the Mustache language to pre-render a search definition. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/render-search-template-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/render-search-template-api.html + * @group serverless * * @param array{ - * id: string, // The id of the stored search template - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The search definition template and its params + * id?: string, // The id of the stored search template + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The search definition template and its params. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1501,8 +1563,9 @@ public function reindexRethrottle(array $params = []) * * @return Elasticsearch|Promise */ - public function renderSearchTemplate(array $params = []) + public function renderSearchTemplate(?array $params = null) { + $params = $params ?? []; if (isset($params['id'])) { $url = '/_render/template/' . $this->encode($params['id']); $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1524,16 +1587,17 @@ public function renderSearchTemplate(array $params = []) /** * Allows an arbitrary script to be executed and a result to be returned * - * @see https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The script to execute + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The script to execute. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1542,8 +1606,9 @@ public function renderSearchTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function scriptsPainlessExecute(array $params = []) + public function scriptsPainlessExecute(?array $params = null) { + $params = $params ?? []; $url = '/_scripts/painless/_execute'; $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1561,18 +1626,19 @@ public function scriptsPainlessExecute(array $params = []) /** * Allows to retrieve a large numbers of results from a single search request. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll + * @group serverless * * @param array{ - * scroll_id: string, // The scroll ID - * scroll: time, // Specify how long a consistent view of the index should be maintained for scrolled search - * rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The scroll ID if not passed by URL or query parameter. + * scroll_id?: string, // The scroll ID + * scroll?: int|string, // Specify how long a consistent view of the index should be maintained for scrolled search + * rest_total_hits_as_int?: bool, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The scroll ID if not passed by URL or query parameter.. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1581,8 +1647,9 @@ public function scriptsPainlessExecute(array $params = []) * * @return Elasticsearch|Promise */ - public function scroll(array $params = []) + public function scroll(?array $params = null) { + $params = $params ?? []; if (isset($params['scroll_id'])) { $url = '/_search/scroll/' . $this->encode($params['scroll_id']); $method = empty($params['body']) ? 'GET' : 'POST'; @@ -1604,61 +1671,61 @@ public function scroll(array $params = []) /** * Returns results matching a query. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * analyzer: string, // The analyzer to use for the query string - * analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false) - * ccs_minimize_roundtrips: boolean, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution - * default_operator: enum, // The default operator for query string query (AND or OR) - * df: string, // The field to use as default where no field prefix is given in the query string - * explain: boolean, // Specify whether to return detailed information about score computation as part of a hit - * stored_fields: list, // A comma-separated list of stored fields to return as part of a hit - * docvalue_fields: list, // A comma-separated list of fields to return as the docvalue representation of a field for each hit - * from: number, // Starting offset (default: 0) - * force_synthetic_source: boolean, // Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * ignore_throttled: boolean, // Whether specified concrete, expanded or aliased indices should be ignored when throttled - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * q: string, // Query in the Lucene query string syntax - * routing: list, // A comma-separated list of specific routing values - * scroll: time, // Specify how long a consistent view of the index should be maintained for scrolled search - * search_type: enum, // Search operation type - * size: number, // Number of hits to return (default: 10) - * sort: list, // A comma-separated list of : pairs - * _source: list, // True or false to return the _source field or not, or a list of fields to return - * _source_excludes: list, // A list of fields to exclude from the returned _source field - * _source_includes: list, // A list of fields to extract and return from the _source field - * terminate_after: number, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - * stats: list, // Specific 'tag' of the request for logging and statistical purposes - * suggest_field: string, // Specify which field to use for suggestions - * suggest_mode: enum, // Specify suggest mode - * suggest_size: number, // How many suggestions to return in response - * suggest_text: string, // The source text for which the suggestions should be returned - * timeout: time, // Explicit operation timeout - * track_scores: boolean, // Whether to calculate and return scores even if they are not used for sorting - * track_total_hits: boolean|long, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. - * allow_partial_search_results: boolean, // Indicate if an error should be returned if there is a partial search failure or timeout - * typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response - * version: boolean, // Specify whether to return document version as part of a hit - * seq_no_primary_term: boolean, // Specify whether to return sequence number and primary term of the last modification of each hit - * request_cache: boolean, // Specify if request cache should be used for this request or not, defaults to index level setting - * batched_reduce_size: number, // The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. - * max_concurrent_shard_requests: number, // The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests - * pre_filter_shard_size: number, // A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. - * rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response - * min_compatible_shard_node: string, // The minimum compatible version that all shards involved in search should have for this request to be successful - * include_named_queries_score: boolean, // Indicates whether hit.matched_queries should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false) - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The search definition using the Query DSL + * index?: string|array, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * analyzer?: string, // The analyzer to use for the query string + * analyze_wildcard?: bool, // Specify whether wildcard and prefix queries should be analyzed (default: false) + * ccs_minimize_roundtrips?: bool, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + * default_operator?: string, // The default operator for query string query (AND or OR) + * df?: string, // The field to use as default where no field prefix is given in the query string + * explain?: bool, // Specify whether to return detailed information about score computation as part of a hit + * stored_fields?: string|array, // A comma-separated list of stored fields to return as part of a hit + * docvalue_fields?: string|array, // A comma-separated list of fields to return as the docvalue representation of a field for each hit + * from?: int, // Starting offset (default: 0) + * force_synthetic_source?: bool, // Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * ignore_throttled?: bool, // Whether specified concrete, expanded or aliased indices should be ignored when throttled + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * lenient?: bool, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * q?: string, // Query in the Lucene query string syntax + * routing?: string|array, // A comma-separated list of specific routing values + * scroll?: int|string, // Specify how long a consistent view of the index should be maintained for scrolled search + * search_type?: string, // Search operation type + * size?: int, // Number of hits to return (default: 10) + * sort?: string|array, // A comma-separated list of : pairs + * _source?: string|array, // True or false to return the _source field or not, or a list of fields to return + * _source_excludes?: string|array, // A list of fields to exclude from the returned _source field + * _source_includes?: string|array, // A list of fields to extract and return from the _source field + * terminate_after?: int, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * stats?: string|array, // Specific 'tag' of the request for logging and statistical purposes + * suggest_field?: string, // Specify which field to use for suggestions + * suggest_mode?: string, // Specify suggest mode + * suggest_size?: int, // How many suggestions to return in response + * suggest_text?: string, // The source text for which the suggestions should be returned + * timeout?: int|string, // Explicit operation timeout + * track_scores?: bool, // Whether to calculate and return scores even if they are not used for sorting + * track_total_hits?: bool|int, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. + * allow_partial_search_results?: bool, // Indicate if an error should be returned if there is a partial search failure or timeout + * typed_keys?: bool, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * version?: bool, // Specify whether to return document version as part of a hit + * seq_no_primary_term?: bool, // Specify whether to return sequence number and primary term of the last modification of each hit + * request_cache?: bool, // Specify if request cache should be used for this request or not, defaults to index level setting + * batched_reduce_size?: int, // The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + * max_concurrent_shard_requests?: int, // The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + * pre_filter_shard_size?: int, // A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + * rest_total_hits_as_int?: bool, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * include_named_queries_score?: bool, // Indicates whether hit.matched_queries should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false) + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The search definition using the Query DSL. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1667,16 +1734,17 @@ public function scroll(array $params = []) * * @return Elasticsearch|Promise */ - public function search(array $params = []) + public function search(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_search'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_search'; $method = empty($params['body']) ? 'GET' : 'POST'; } else { $url = '/_search'; $method = empty($params['body']) ? 'GET' : 'POST'; } - $url = $this->addQueryString($url, $params, ['analyzer','analyze_wildcard','ccs_minimize_roundtrips','default_operator','df','explain','stored_fields','docvalue_fields','from','force_synthetic_source','ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','lenient','preference','q','routing','scroll','search_type','size','sort','_source','_source_excludes','_source_includes','terminate_after','stats','suggest_field','suggest_mode','suggest_size','suggest_text','timeout','track_scores','track_total_hits','allow_partial_search_results','typed_keys','version','seq_no_primary_term','request_cache','batched_reduce_size','max_concurrent_shard_requests','pre_filter_shard_size','rest_total_hits_as_int','min_compatible_shard_node','include_named_queries_score','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['analyzer','analyze_wildcard','ccs_minimize_roundtrips','default_operator','df','explain','stored_fields','docvalue_fields','from','force_synthetic_source','ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','lenient','preference','q','routing','scroll','search_type','size','sort','_source','_source_excludes','_source_includes','terminate_after','stats','suggest_field','suggest_mode','suggest_size','suggest_text','timeout','track_scores','track_total_hits','allow_partial_search_results','typed_keys','version','seq_no_primary_term','request_cache','batched_reduce_size','max_concurrent_shard_requests','pre_filter_shard_size','rest_total_hits_as_int','include_named_queries_score','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -1690,28 +1758,29 @@ public function search(array $params = []) /** * Searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-vector-tile-api.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-vector-tile-api.html + * @group serverless * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * index: list, // (REQUIRED) Comma-separated list of data streams, indices, or aliases to search + * index: string|array, // (REQUIRED) Comma-separated list of data streams, indices, or aliases to search * field: string, // (REQUIRED) Field containing geospatial data to return * zoom: int, // (REQUIRED) Zoom level for the vector tile to search * x: int, // (REQUIRED) X coordinate for the vector tile to search * y: int, // (REQUIRED) Y coordinate for the vector tile to search - * exact_bounds: boolean, // If false, the meta layer's feature is the bounding box of the tile. If true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation. - * extent: int, // Size, in pixels, of a side of the vector tile. - * grid_precision: int, // Additional zoom levels available through the aggs layer. Accepts 0-8. - * grid_type: enum, // Determines the geometry type for features in the aggs layer. - * size: int, // Maximum number of features to return in the hits layer. Accepts 0-10000. - * track_total_hits: boolean|long, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. - * with_labels: boolean, // If true, the hits and aggs layers will contain additional point features with suggested label positions for the original features. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Search request body. + * exact_bounds?: bool, // If false, the meta layer's feature is the bounding box of the tile. If true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation. + * extent?: int, // Size, in pixels, of a side of the vector tile. + * grid_precision?: int, // Additional zoom levels available through the aggs layer. Accepts 0-8. + * grid_type?: string, // Determines the geometry type for features in the aggs layer. + * size?: int, // Maximum number of features to return in the hits layer. Accepts 0-10000. + * track_total_hits?: bool|int, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. + * with_labels?: bool, // If true, the hits and aggs layers will contain additional point features with suggested label positions for the original features. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Search request body.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1721,10 +1790,11 @@ public function search(array $params = []) * * @return Elasticsearch|Promise */ - public function searchMvt(array $params = []) + public function searchMvt(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index','field','zoom','x','y'], $params); - $url = '/' . $this->encode($params['index']) . '/_mvt/' . $this->encode($params['field']) . '/' . $this->encode($params['zoom']) . '/' . $this->encode($params['x']) . '/' . $this->encode($params['y']); + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_mvt/' . $this->encode($params['field']) . '/' . $this->encode($params['zoom']) . '/' . $this->encode($params['x']) . '/' . $this->encode($params['y']); $method = empty($params['body']) ? 'GET' : 'POST'; $url = $this->addQueryString($url, $params, ['exact_bounds','extent','grid_precision','grid_type','size','track_total_hits','with_labels','pretty','human','error_trace','source','filter_path']); @@ -1741,21 +1811,22 @@ public function searchMvt(array $params = []) /** * Returns information about the indices and shards that a search request would be executed against. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html * * @param array{ - * index: list, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * routing: string, // Specific routing value - * local: boolean, // Return local information, do not retrieve the state from master node (default: false) - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * index?: string|array, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * routing?: string, // Specific routing value + * local?: bool, // Return local information, do not retrieve the state from master node (default: false) + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * master_timeout?: int|string, // Explicit operation timeout for connection to master node + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1764,16 +1835,17 @@ public function searchMvt(array $params = []) * * @return Elasticsearch|Promise */ - public function searchShards(array $params = []) + public function searchShards(?array $params = null) { + $params = $params ?? []; if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_search_shards'; - $method = empty($params['body']) ? 'GET' : 'POST'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_search_shards'; + $method = 'GET'; } else { $url = '/_search_shards'; - $method = empty($params['body']) ? 'GET' : 'POST'; + $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['preference','routing','local','ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['preference','routing','local','ignore_unavailable','allow_no_indices','expand_wildcards','master_timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -1786,29 +1858,30 @@ public function searchShards(array $params = []) /** * Allows to use the Mustache language to pre-render a search definition. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html + * @group serverless * * @param array{ - * index: list, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * ignore_throttled: boolean, // Whether specified concrete, expanded or aliased indices should be ignored when throttled - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * routing: list, // A comma-separated list of specific routing values - * scroll: time, // Specify how long a consistent view of the index should be maintained for scrolled search - * search_type: enum, // Search operation type - * explain: boolean, // Specify whether to return detailed information about score computation as part of a hit - * profile: boolean, // Specify whether to profile the query execution - * typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response - * rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response - * ccs_minimize_roundtrips: boolean, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The search definition template and its params + * index?: string|array, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * ignore_throttled?: bool, // Whether specified concrete, expanded or aliased indices should be ignored when throttled + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * routing?: string|array, // A comma-separated list of specific routing values + * scroll?: int|string, // Specify how long a consistent view of the index should be maintained for scrolled search + * search_type?: string, // Search operation type + * explain?: bool, // Specify whether to return detailed information about score computation as part of a hit + * profile?: bool, // Specify whether to profile the query execution + * typed_keys?: bool, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * rest_total_hits_as_int?: bool, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * ccs_minimize_roundtrips?: bool, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The search definition template and its params. If body is a string must be a valid JSON. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -1817,11 +1890,12 @@ public function searchShards(array $params = []) * * @return Elasticsearch|Promise */ - public function searchTemplate(array $params = []) + public function searchTemplate(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['body'], $params); if (isset($params['index'])) { - $url = '/' . $this->encode($params['index']) . '/_search/template'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_search/template'; $method = empty($params['body']) ? 'GET' : 'POST'; } else { $url = '/_search/template'; @@ -1841,16 +1915,17 @@ public function searchTemplate(array $params = []) /** * The terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // field name, string which is the prefix expected in matching terms, timeout and size for max number of results + * index: string|array, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // field name, string which is the prefix expected in matching terms, timeout and size for max number of results. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1860,10 +1935,11 @@ public function searchTemplate(array $params = []) * * @return Elasticsearch|Promise */ - public function termsEnum(array $params = []) + public function termsEnum(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']) . '/_terms_enum'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_terms_enum'; $method = empty($params['body']) ? 'GET' : 'POST'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); @@ -1880,28 +1956,29 @@ public function termsEnum(array $params = []) /** * Returns information and statistics about terms in the fields of a particular document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html + * @group serverless * * @param array{ * index: string, // (REQUIRED) The index in which the document resides. - * id: string, // The id of the document, when not specified a doc param should be supplied. - * term_statistics: boolean, // Specifies if total term frequency and document frequency should be returned. - * field_statistics: boolean, // Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. - * fields: list, // A comma-separated list of fields to return. - * offsets: boolean, // Specifies if term offsets should be returned. - * positions: boolean, // Specifies if term positions should be returned. - * payloads: boolean, // Specifies if term payloads should be returned. - * preference: string, // Specify the node or shard the operation should be performed on (default: random). - * routing: string, // Specific routing value. - * realtime: boolean, // Specifies if request is real-time as opposed to near-real-time (default: true). - * version: number, // Explicit version number for concurrency control - * version_type: enum, // Specific version type - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // Define parameters and or supply a document to get termvectors for. See documentation. + * id?: string, // The id of the document, when not specified a doc param should be supplied. + * term_statistics?: bool, // Specifies if total term frequency and document frequency should be returned. + * field_statistics?: bool, // Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + * fields?: string|array, // A comma-separated list of fields to return. + * offsets?: bool, // Specifies if term offsets should be returned. + * positions?: bool, // Specifies if term positions should be returned. + * payloads?: bool, // Specifies if term payloads should be returned. + * preference?: string, // Specify the node or shard the operation should be performed on (default: random). + * routing?: string, // Specific routing value. + * realtime?: bool, // Specifies if request is real-time as opposed to near-real-time (default: true). + * version?: int, // Explicit version number for concurrency control + * version_type?: string, // Specific version type + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // Define parameters and or supply a document to get termvectors for. See documentation.. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1911,8 +1988,9 @@ public function termsEnum(array $params = []) * * @return Elasticsearch|Promise */ - public function termvectors(array $params = []) + public function termvectors(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); if (isset($params['id'])) { $url = '/' . $this->encode($params['index']) . '/_termvectors/' . $this->encode($params['id']); @@ -1935,29 +2013,31 @@ public function termvectors(array $params = []) /** * Updates a document with a script or partial document. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html + * @group serverless * * @param array{ * id: string, // (REQUIRED) Document ID * index: string, // (REQUIRED) The name of the index - * wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * _source: list, // True or false to return the _source field or not, or a list of fields to return - * _source_excludes: list, // A list of fields to exclude from the returned _source field - * _source_includes: list, // A list of fields to extract and return from the _source field - * lang: string, // The script language (default: painless) - * refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - * retry_on_conflict: number, // Specify how many times should the operation be retried when a conflict occurs (default: 0) - * routing: string, // Specific routing value - * timeout: time, // Explicit operation timeout - * if_seq_no: number, // only perform the update operation if the last operation that has changed the document has the specified sequence number - * if_primary_term: number, // only perform the update operation if the last operation that has changed the document has the specified primary term - * require_alias: boolean, // When true, requires destination is an alias. Default is false - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // (REQUIRED) The request definition requires either `script` or partial `doc` + * wait_for_active_shards?: string, // Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * _source?: string|array, // True or false to return the _source field or not, or a list of fields to return + * _source_excludes?: string|array, // A list of fields to exclude from the returned _source field + * _source_includes?: string|array, // A list of fields to extract and return from the _source field + * lang?: string, // The script language (default: painless) + * refresh?: string, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * retry_on_conflict?: int, // Specify how many times should the operation be retried when a conflict occurs (default: 0) + * routing?: string, // Specific routing value + * timeout?: int|string, // Explicit operation timeout + * if_seq_no?: int, // only perform the update operation if the last operation that has changed the document has the specified sequence number + * if_primary_term?: int, // only perform the update operation if the last operation that has changed the document has the specified primary term + * require_alias?: bool, // When true, requires destination is an alias. Default is false + * include_source_on_error?: bool, // True or false if to include the document source in the error message in case of parsing errors. Defaults to true. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body: string|array, // (REQUIRED) The request definition requires either `script` or partial `doc`. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1967,13 +2047,14 @@ public function termvectors(array $params = []) * * @return Elasticsearch|Promise */ - public function update(array $params = []) + public function update(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['id','index','body'], $params); $url = '/' . $this->encode($params['index']) . '/_update/' . $this->encode($params['id']); $method = 'POST'; - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','_source','_source_excludes','_source_includes','lang','refresh','retry_on_conflict','routing','timeout','if_seq_no','if_primary_term','require_alias','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['wait_for_active_shards','_source','_source_excludes','_source_includes','lang','refresh','retry_on_conflict','routing','timeout','if_seq_no','if_primary_term','require_alias','include_source_on_error','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -1988,47 +2069,48 @@ public function update(array $params = []) * Performs an update on every document in the index without changing the source, * for example to pick up a mapping change. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html + * @group serverless * * @param array{ - * index: list, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * analyzer: string, // The analyzer to use for the query string - * analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false) - * default_operator: enum, // The default operator for query string query (AND or OR) - * df: string, // The field to use as default where no field prefix is given in the query string - * from: number, // Starting offset (default: 0) - * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) - * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * conflicts: enum, // What to do when the update by query hits version conflicts? - * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. - * lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - * pipeline: string, // Ingest pipeline to set on index requests made by this action. (default: none) - * preference: string, // Specify the node or shard the operation should be performed on (default: random) - * q: string, // Query in the Lucene query string syntax - * routing: list, // A comma-separated list of specific routing values - * scroll: time, // Specify how long a consistent view of the index should be maintained for scrolled search - * search_type: enum, // Search operation type - * search_timeout: time, // Explicit timeout for each search request. Defaults to no timeout. - * max_docs: number, // Maximum number of documents to process (default: all documents) - * sort: list, // A comma-separated list of : pairs - * terminate_after: number, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - * stats: list, // Specific 'tag' of the request for logging and statistical purposes - * version: boolean, // Specify whether to return document version as part of a hit - * version_type: boolean, // Should the document increment the version number (internal) on hit or not (reindex) - * request_cache: boolean, // Specify if request cache should be used for this request or not, defaults to index level setting - * refresh: boolean, // Should the affected indexes be refreshed? - * timeout: time, // Time each individual bulk request should wait for shards that are unavailable. - * wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * scroll_size: number, // Size on the scroll request powering the update by query - * wait_for_completion: boolean, // Should the request should block until the update by query operation is complete. - * requests_per_second: number, // The throttle to set on this request in sub-requests per second. -1 means no throttle. - * slices: number|string, // The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The search definition using the Query DSL + * index: string|array, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * analyzer?: string, // The analyzer to use for the query string + * analyze_wildcard?: bool, // Specify whether wildcard and prefix queries should be analyzed (default: false) + * default_operator?: string, // The default operator for query string query (AND or OR) + * df?: string, // The field to use as default where no field prefix is given in the query string + * from?: int, // Starting offset (default: 0) + * ignore_unavailable?: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * allow_no_indices?: bool, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * conflicts?: string, // What to do when the update by query hits version conflicts? + * expand_wildcards?: string, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * lenient?: bool, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * pipeline?: string, // Ingest pipeline to set on index requests made by this action. (default: none) + * preference?: string, // Specify the node or shard the operation should be performed on (default: random) + * q?: string, // Query in the Lucene query string syntax + * routing?: string|array, // A comma-separated list of specific routing values + * scroll?: int|string, // Specify how long a consistent view of the index should be maintained for scrolled search + * search_type?: string, // Search operation type + * search_timeout?: int|string, // Explicit timeout for each search request. Defaults to no timeout. + * max_docs?: int, // Maximum number of documents to process (default: all documents) + * sort?: string|array, // A comma-separated list of : pairs + * terminate_after?: int, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * stats?: string|array, // Specific 'tag' of the request for logging and statistical purposes + * version?: bool, // Specify whether to return document version as part of a hit + * version_type?: bool, // Should the document increment the version number (internal) on hit or not (reindex) + * request_cache?: bool, // Specify if request cache should be used for this request or not, defaults to index level setting + * refresh?: bool, // Should the affected indexes be refreshed? + * timeout?: int|string, // Time each individual bulk request should wait for shards that are unavailable. + * wait_for_active_shards?: string, // Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * scroll_size?: int, // Size on the scroll request powering the update by query + * wait_for_completion?: bool, // Should the request should block until the update by query operation is complete. + * requests_per_second?: int, // The throttle to set on this request in sub-requests per second. -1 means no throttle. + * slices?: int|string, // The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. + * body?: string|array, // The search definition using the Query DSL. If body is a string must be a valid JSON. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2038,10 +2120,11 @@ public function update(array $params = []) * * @return Elasticsearch|Promise */ - public function updateByQuery(array $params = []) + public function updateByQuery(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['index'], $params); - $url = '/' . $this->encode($params['index']) . '/_update_by_query'; + $url = '/' . $this->encode($this->convertValue($params['index'])) . '/_update_by_query'; $method = 'POST'; $url = $this->addQueryString($url, $params, ['analyzer','analyze_wildcard','default_operator','df','from','ignore_unavailable','allow_no_indices','conflicts','expand_wildcards','lenient','pipeline','preference','q','routing','scroll','search_type','search_timeout','max_docs','sort','terminate_after','stats','version','version_type','request_cache','refresh','timeout','wait_for_active_shards','scroll_size','wait_for_completion','requests_per_second','slices','pretty','human','error_trace','source','filter_path']); @@ -2058,16 +2141,16 @@ public function updateByQuery(array $params = []) /** * Changes the number of requests per second for a particular Update By Query operation. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html * * @param array{ * task_id: string, // (REQUIRED) The task id to rethrottle - * requests_per_second: number, // The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. - * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) - * human: boolean, // Return human readable values for statistics. (DEFAULT: true) - * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) - * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - * filter_path: list, // A comma-separated list of filters used to reduce the response. + * requests_per_second?: int, // The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + * pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false) + * human?: bool, // Return human readable values for statistics. (DEFAULT: true) + * error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false) + * source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path?: string|array, // A comma-separated list of filters used to reduce the response. * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2077,8 +2160,9 @@ public function updateByQuery(array $params = []) * * @return Elasticsearch|Promise */ - public function updateByQueryRethrottle(array $params = []) + public function updateByQueryRethrottle(?array $params = null) { + $params = $params ?? []; $this->checkRequiredParameters(['task_id','requests_per_second'], $params); $url = '/_update_by_query/' . $this->encode($params['task_id']) . '/_rethrottle'; $method = 'POST'; diff --git a/src/Traits/EndpointTrait.php b/src/Traits/EndpointTrait.php index c248483f9..c043058ea 100644 --- a/src/Traits/EndpointTrait.php +++ b/src/Traits/EndpointTrait.php @@ -15,17 +15,17 @@ namespace Elastic\Elasticsearch\Traits; use Elastic\Elasticsearch\Client; +use Elastic\Elasticsearch\ClientInterface; use Elastic\Elasticsearch\Exception\ContentTypeException; use Elastic\Elasticsearch\Exception\MissingParameterException; -use Elastic\Elasticsearch\Utility; use Elastic\Transport\OpenTelemetry; use Elastic\Transport\Serializer\JsonSerializer; use Elastic\Transport\Serializer\NDJsonSerializer; use Http\Discovery\Psr17FactoryDiscovery; -use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ServerRequestInterface; use function http_build_query; +use function rawurlencode; use function strpos; use function sprintf; @@ -63,7 +63,7 @@ protected function isAssociativeArray(array $array): bool * * @param mixed $value */ - private function convertValue($value): string + protected function convertValue($value): string { // Convert a boolean value in 'true' or 'false' string if (is_bool($value)) { @@ -82,7 +82,7 @@ private function convertValue($value): string */ protected function encode($value): string { - return Utility::urlencode($this->convertValue($value)); + return rawurlencode($this->convertValue($value)); } /** @@ -129,7 +129,7 @@ protected function bodySerialize($body, string $contentType): string * * @param array|string $body */ - protected function createRequest(string $method, string $url, array $headers, $body = null): RequestInterface + protected function createRequest(string $method, string $url, array $headers, $body = null): ServerRequestInterface { $requestFactory = Psr17FactoryDiscovery::findServerRequestFactory(); $streamFactory = Psr17FactoryDiscovery::findStreamFactory(); @@ -147,7 +147,13 @@ protected function createRequest(string $method, string $url, array $headers, $b $content = is_string($body) ? $body : $this->bodySerialize($body, $headers['Content-Type']); $request = $request->withBody($streamFactory->createStream($content)); } - $headers = $this->buildCompatibilityHeaders($headers); + + $client = $this->client ?? $this; + if ($client instanceof ClientInterface && $client->getServerless()) { + $headers[Client::API_VERSION_HEADER] = Client::API_VERSION; + } else { + $headers = $this->buildCompatibilityHeaders($headers); + } // Headers foreach ($headers as $name => $value) { diff --git a/src/Traits/MessageResponseTrait.php b/src/Traits/MessageResponseTrait.php index faf0fc803..ad2f23419 100644 --- a/src/Traits/MessageResponseTrait.php +++ b/src/Traits/MessageResponseTrait.php @@ -29,6 +29,9 @@ public function getProtocolVersion(): string return $this->response->getProtocolVersion(); } + /** + * @return MessageInterface + */ public function withProtocolVersion($version): MessageInterface { return $this->response->withProtocolVersion($version); @@ -54,26 +57,41 @@ public function getHeaderLine(string $name): string return $this->response->getHeaderLine($name); } + /** + * @return MessageInterface + */ public function withHeader(string $name, $value): MessageInterface { return $this->response->withHeader($name, $value); } + /** + * @return MessageInterface + */ public function withAddedHeader(string $name, $value): MessageInterface { return $this->response->withAddedHeader($name, $value); } + /** + * @return MessageInterface + */ public function withoutHeader(string $name): MessageInterface { return $this->response->withoutHeader($name); } + /** + * @return StreamInterface + */ public function getBody(): StreamInterface { return $this->response->getBody(); } + /** + * @return MessageInterface + */ public function withBody(StreamInterface $body): MessageInterface { return $this->response->withBody($body); @@ -84,6 +102,9 @@ public function getStatusCode(): int return $this->response->getStatusCode(); } + /** + * @return ResponseInterface + */ public function withStatus(int $code, string $reasonPhrase = ''): ResponseInterface { return $this->response->withStatus($code, $reasonPhrase); diff --git a/src/Transport/Adapter/AdapterOptions.php b/src/Transport/Adapter/AdapterOptions.php index c3d2da0dd..d754a4fb7 100644 --- a/src/Transport/Adapter/AdapterOptions.php +++ b/src/Transport/Adapter/AdapterOptions.php @@ -22,6 +22,7 @@ final class AdapterOptions const HTTP_ADAPTERS = [ "GuzzleHttp\\Client" => "Elastic\\Elasticsearch\\Transport\\Adapter\\Guzzle", "Symfony\\Component\\HttpClient\\HttplugClient" => "Elastic\\Elasticsearch\\Transport\\Adapter\\Symfony", - "Symfony\\Component\\HttpClient\\Psr18Client" => "Elastic\\Elasticsearch\\Transport\\Adapter\\Symfony" + "Symfony\\Component\\HttpClient\\Psr18Client" => "Elastic\\Elasticsearch\\Transport\\Adapter\\Symfony", + "Elastic\\Transport\\Client\\Curl" => "Elastic\\Elasticsearch\\Transport\\Adapter\\ElasticCurl" ]; } \ No newline at end of file diff --git a/src/Transport/Adapter/ElasticCurl.php b/src/Transport/Adapter/ElasticCurl.php new file mode 100644 index 000000000..72ae3ebf8 --- /dev/null +++ b/src/Transport/Adapter/ElasticCurl.php @@ -0,0 +1,43 @@ + $value) { + switch ($key) { + case RequestOptions::SSL_CERT: + $curlConfig[CURLOPT_SSLCERT] = $value; + break; + case RequestOptions::SSL_KEY: + $curlConfig[CURLOPT_SSH_PRIVATE_KEYFILE] = $value; + break; + case RequestOptions::SSL_VERIFY: + $curlConfig[CURLOPT_SSL_VERIFYPEER] = $value; + break; + case RequestOptions::SSL_CA: + $curlConfig[CURLOPT_CAINFO] = $value; + } + } + $class = get_class($client); + return new $class(array_replace($clientOptions, $curlConfig)); + } +} \ No newline at end of file diff --git a/src/Transport/AsyncOnSuccess.php b/src/Transport/AsyncOnSuccess.php index 906b1efc3..c433089f1 100644 --- a/src/Transport/AsyncOnSuccess.php +++ b/src/Transport/AsyncOnSuccess.php @@ -14,16 +14,24 @@ namespace Elastic\Elasticsearch\Transport; +use Elastic\Elasticsearch\ClientInterface; use Elastic\Elasticsearch\Response\Elasticsearch; use Elastic\Transport\Async\OnSuccessInterface; use Psr\Http\Message\ResponseInterface; class AsyncOnSuccess implements OnSuccessInterface { + public function __construct(protected ?ClientInterface $client = null) + { + } + public function success(ResponseInterface $response, int $count): Elasticsearch { $result = new Elasticsearch; $result->setResponse($response, true); + if (isset($this->client)) { + $this->client->setServerless($result->isServerless()); + } return $result; } } \ No newline at end of file diff --git a/src/Transport/AsyncOnSuccessNoException.php b/src/Transport/AsyncOnSuccessNoException.php index 1b69a58a7..807d8b543 100644 --- a/src/Transport/AsyncOnSuccessNoException.php +++ b/src/Transport/AsyncOnSuccessNoException.php @@ -14,16 +14,24 @@ namespace Elastic\Elasticsearch\Transport; +use Elastic\Elasticsearch\ClientInterface; use Elastic\Elasticsearch\Response\Elasticsearch; use Elastic\Transport\Async\OnSuccessInterface; use Psr\Http\Message\ResponseInterface; class AsyncOnSuccessNoException implements OnSuccessInterface { + public function __construct(protected ?ClientInterface $client = null) + { + } + public function success(ResponseInterface $response, int $count): Elasticsearch { $result = new Elasticsearch; $result->setResponse($response, false); + if (isset($this->client)) { + $this->client->setServerless($result->isServerless()); + } return $result; } } \ No newline at end of file diff --git a/src/Utility.php b/src/Utility.php index d54185ce5..ed46b1b11 100644 --- a/src/Utility.php +++ b/src/Utility.php @@ -16,8 +16,6 @@ class Utility { - const ENV_URL_PLUS_AS_SPACE = 'ELASTIC_CLIENT_URL_PLUS_AS_SPACE'; - /** * Get the ENV variable with a thread safe fallback criteria * @see https://github.com/elastic/elasticsearch-php/issues/1237 @@ -29,23 +27,6 @@ public static function getEnv(string $env) return $_SERVER[$env] ?? $_ENV[$env] ?? getenv($env); } - /** - * Encode a string in URL using urlencode() or rawurlencode() - * according to ENV_URL_PLUS_AS_SPACE. - * If ENV_URL_PLUS_AS_SPACE is not defined or true use urlencode(), - * otherwise use rawurlencode() - * - * @see https://github.com/elastic/elasticsearch-php/issues/1278 - * @deprecated will be replaced by PHP function rawurlencode() - */ - public static function urlencode(string $url): string - { - $plusAsSpace = self::getEnv(self::ENV_URL_PLUS_AS_SPACE); - return $plusAsSpace === false || $plusAsSpace === 'true' - ? urlencode($url) - : rawurlencode($url); - } - /** * Remove all the characters not valid for a PHP variable name * The valid characters are: a-z, A-Z, 0-9 and _ (underscore) @@ -54,7 +35,7 @@ public static function urlencode(string $url): string public static function formatVariableName(string $var): string { // If the first character is a digit, we append the underscore - if (is_int($var[0])) { + if (is_numeric($var[0])) { $var = '_' . $var; } return preg_replace('/[^a-zA-Z0-9_]/', '', $var); diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 000000000..f5caab097 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,2 @@ +elasticsearch-clients-tests/ +Yaml/ \ No newline at end of file diff --git a/tests/BuildPHPUnitClass.php b/tests/BuildPHPUnitClass.php new file mode 100644 index 000000000..9a0e47e72 --- /dev/null +++ b/tests/BuildPHPUnitClass.php @@ -0,0 +1,439 @@ +yaml = yaml_parse($content, -1, $ndocs, [ + YAML_MAP_TAG => function($value, $tag, $flags) { + return empty($value) ? new stdClass : $value; + } + ]); + } catch (Throwable $e) { + throw new Exception(sprintf( + "YAML parse error file %s: %s", + $filename, + $e->getMessage() + )); + } + } + + public function build(): ?PhpNamespace + { + if (!$this->yaml[0]['requires'][$this->testGroup]) { + return null; + } + + $className = sprintf("%sTest", $this->normalizeFileName($this->filename)); + $namespace = new PhpNamespace(sprintf("Elastic\Elasticsearch\Tests\%s", $this->namespace)); + + $namespace + ->addUse(Utility::class) + ->addUse(Client::class) + ->addUse(ClientResponseException::class); + + $class = $namespace->addClass($className); + $class + ->setFinal() + ->setExtends(TestCase::class) + ->addComment(sprintf('@group %s', $this->testGroup)) + ->addComment('@generated This file is generated, please do not edit'); + + $class + ->addProperty('client') + ->setStatic(true) + ->setPrivate() + ->setType(Client::class); + + $class->addMethod('setUpBeforeClass') + ->setBody("self::\$client = Utility::getClient();\n") + ->setStatic(true) + ->setReturnType('void'); + + foreach ($this->yaml as $items) { + foreach ($items as $key => $values) { + switch ($key) { + case 'setup': + $class + ->addMethod('setUp') + ->setBody($this->buildBody($values)) + ->setReturnType('void'); + break; + case 'teardown': + $class + ->addMethod('tearDown') + ->setBody($this->buildBody($values)) + ->setReturnType('void'); + break; + case 'requires': + continue 2; + default: + $class + ->addMethod('test' . $this->normalizeClassName($key)) + ->setBody($this->buildBody($values)); + } + } + } + + return $namespace->add($class); + } + + protected function buildBody(array $body): string + { + $output = ''; + foreach ($body as $item) { + $action = key($item); + if (method_exists($this, $action)) { + $output .= $this->$action(current($item)); + } else { + throw new Exception(sprintf( + "I don't have the implementation of the %s feature in %s", + $action, + $this->filename + )); + } + } + return $output; + } + + protected function normalizeFileName(string $filename): string + { + $number = ''; + if (preg_match('/^(\d+)_/', basename($filename, '.yml'), $matches)) { + $number = $matches[1]; + } + $output = preg_replace('/[0-9]/', '', basename($filename, '.yml')); + $output = str_replace('_', '', ucwords($output, '_')); + return ucfirst($output.$number); + } + + protected function normalizeClassName(string $name): string + { + $output = str_replace(['.', ' ', ',','(',')','_', '|', '-'], '', ucwords($name, '.,_(- ')); + return ucfirst($output); + } + + protected function normalizeFunctionName(string $name): string + { + return lcfirst(str_replace('_', '', ucwords($name, '_'))); + } + + /** + * Parse the response key and returns the PHP code to + * get the key from the $response + * Examples: + * parseValue('events.0.event_id') => $response['events'][0]['event_id'] + * parseValue('nodes.$master.modules') => $response['nodes'][$master]['master]]['modules'] + */ + protected function parseValue(string $var): string + { + if ($var === '$body') { + return '$response->getBody()->getContents()'; + } + if ($var[0] === '$') { + list($first, $var) = explode('.', $var, 2); + $output = $first; + } else { + $output = '$response'; + } + foreach (explode('.', $var) as $item) { + if (is_numeric($item)) { + $output .= sprintf('[%d]', $item); + } elseif (is_string($item) && !empty($item)) { + if (substr($item, 0, 1) === '$') { + $output .= sprintf("[%s]", $item); + } else { + $output .= sprintf('[\'%s\']', $item); + } + } + } + return $output; + } + + protected function arrayToPhpCode(array|string|stdClass $arr): string { + $parts = []; + + if (is_string($arr)) { + return var_export($arr, true); + } + if ($arr instanceof stdClass) { + return '[(object)[]]'; + } + foreach ($arr as $key => $value) { + // Format the key + $formattedKey = is_numeric($key) ? $key : "'" . addslashes($key) . "'"; + + // Handle the value recursively + if (is_array($value)) { + $formattedValue = $this->arrayToPhpCode($value); // recursion + } elseif (is_string($value) && str_starts_with($value, '$')) { + $formattedValue = $value; // treat as variable + } else { + $formattedValue = var_export($value, true); + } + + $parts[] = "{$formattedKey} => {$formattedValue}"; + } + + return '[' . implode(', ', $parts) . ']'; + } + + /** + * ---------------------------------------------------------------------------------------- + * ACTIONS FOR TESTS + * ---------------------------------------------------------------------------------------- + */ + + protected function do(array $actions): string + { + $output = ''; + // catch + if (isset($actions['catch'])) { + $catch = $actions['catch']; + $output = "try {\n"; + unset($actions['catch']); + } + // headers + if (isset($actions['headers'])) { + // @todo implement the headers + return "\$this->markTestSkipped('Headers feature not supported');\n"; + } + foreach ($actions as $endpoint => $params) { + if (is_array($params)) { + // ignore + if (isset($params['ignore'])) { + if (is_array($params['ignore'])) { + $ignore = implode(',', $params['ignore']); + } else { + $ignore = $params['ignore']; + } + $output = "try {\n"; + unset($params['ignore']); + } + } + $method = str_replace('.', '()->', $endpoint); + $output .= sprintf( + "%s\$response = self::\$client->%s(\n", + isset($catch) || isset($ignore) ? "\t" : '', + $this->normalizeFunctionName($method) + ); + $output .= sprintf( + "%s%s", + isset($catch) || isset($ignore) ? "\t\t" : "\t", + $this->arrayToPhpCode($params) + ); + $output .= sprintf("%s\n);\n", isset($catch) || isset($ignore) ? "\t" : ''); + if (isset($ignore)) { + $output .= "} catch (ClientResponseException \$e) {\n"; + $output .= sprintf(" if (!in_array(\$e->getResponse()->getStatusCode(), [%s])) {\n", $ignore); + $output .= " throw \$e;\n"; + $output .= " }\n"; + $output .= "}\n"; + unset($ignore); + } + if (isset($catch)) { + $output .= "} catch (ClientResponseException \$e) {\n"; + $output .= sprintf("\t\$this->assertMatchesRegularExpression('%s', \$e->getMessage());\n", $catch); + $output .= "}\n"; + unset($catch); + } + } + return $output; + } + + protected function match(array $actions): string + { + $output = ''; + $key = $this->parseValue(key($actions)); + $value = current($actions); + switch(gettype($value)) { + case 'string': + if ($value[0] === '/') { + $output .= sprintf("\$this->assertMatchesRegularExpression('%s', %s);\n", $value, $key); + } elseif ($value[0] === '$') { + $output .= sprintf("\$this->assertEquals(%s, %s);\n", $value, $key); + } else { + $output .= sprintf("\$this->assertEquals('%s', %s);\n", $value, $key); + } + break; + case 'boolean': + $output .= sprintf("\$this->assertEquals(%s, %s);\n", $value ? 'true' : 'false', $key); + break; + case 'integer': + $output .= sprintf("\$this->assertEquals(%d, %s);\n", $value, $key); + break; + case 'double': + $output .= sprintf("\$this->assertEquals(%f, %s);\n", $value, $key); + break; + case 'array': + case 'object': + if (empty($value)) { + $output .= sprintf("\$this->assertEmpty(%s);\n", $key); + } else { + $output .= sprintf("\$this->assertEquals(%s, %s);\n", var_export($value, true), $key); + } + break; + default: + throw new Exception(sprintf( + "Type %s is not supported for %s => %s", + gettype($value), + $key, + var_export($value, true) + )); + } + return $output; + } + + protected function set(array $actions): string + { + $output = ''; + foreach ($actions as $key => $value) { + $output .= sprintf("\$%s = %s;\n", $value, $this->parseValue($key)); + } + return $output; + } + + /** + * @link https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test#is_true + */ + protected function is_true(string $action): string + { + if (empty($action)) { + return "\$this->assertEmpty(\$response->getBody()->getContents());\n"; + } elseif ('$body' === $action) { + return "\$this->assertNotEmpty(\$response->getBody()->getContents());\n"; + } else { + return sprintf( + "\$this->assertTrue(isset(%s) && %s);\n", + $this->parseValue($action), + $this->parseValue($action) + ); + } + } + + /** + * @link https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test#is_false + */ + protected function is_false(string $action): string + { + if (empty($action)) { + return "\$this->assertNotEmpty(\$response->getBody()->getContents());\n"; + } + $key = $this->parseValue($action); + return sprintf("\$this->assertTrue(!isset(%s) || !%s);\n", $key, $key); + } + + protected function length(array $actions): string + { + $key = $this->parseValue(key($actions)); + $value = current($actions); + $output = sprintf( + "\$_len_ = is_string(%s) ? strlen(%s) : (is_countable(%s) ? count(%s) : null);\n", + $key, + $key, + $key, + $key + ); + $output .= sprintf("\$this->assertEquals(%d, \$_len_);\n", $value); + return $output; + } + + protected function gte(array $actions): string + { + $key = $this->parseValue(key($actions)); + $value = current($actions); + return sprintf("\$this->assertGreaterThanOrEqual(%s, %d);\n", $key, $value); + } + + protected function gt(array $actions): string + { + $key = $this->parseValue(key($actions)); + $value = current($actions); + return sprintf("\$this->assertGreaterThan(%s, %d);\n", $key, $value); + } + + protected function lte(array $actions): string + { + $key = $this->parseValue(key($actions)); + $value = current($actions); + return sprintf("\$this->assertLessThanOrEqual(%s, %d);\n", $key, $value); + } + + protected function lt(array $actions): string + { + $key = $this->parseValue(key($actions)); + $value = current($actions); + return sprintf("\$this->assertLessThan(%s, %d);\n", $key, $value); + } + + protected function skip(array $actions): string + { + // @todo to be implemented + return ''; + } + + protected function contains(array $actions): string + { + $key = $this->parseValue(key($actions)); + $value = current($actions); + if (is_array($value)) { + return sprintf( + "\$this->assertEquals(%s, array_intersect_assoc(%s, %s));\n", + var_export($value, true), + $key, + var_export($value, true) + ); + } elseif (is_string($value)) { + return sprintf("\$this->assertStringContainsString('%s', %s);\n", $value, $key); + } + throw new Exception(sprintf( + "I cannot parse the contains feature with key %s and value %s", + $key, + var_export($value, true) + )); + } + + protected function exists(string $action): string + { + return sprintf( + "\$this->assertTrue(isset(%s));\n", + $this->parseValue($action) + ); + } +} \ No newline at end of file diff --git a/tests/ClientBuilderTest.php b/tests/ClientBuilderTest.php index fb1bab26b..08a38cba0 100644 --- a/tests/ClientBuilderTest.php +++ b/tests/ClientBuilderTest.php @@ -19,6 +19,7 @@ use Elastic\Elasticsearch\Exception\AuthenticationException; use Elastic\Elasticsearch\Exception\ConfigException; use Elastic\Elasticsearch\Exception\InvalidArgumentException; +use Elastic\Transport\Exception\CloudIdParseException; use Elastic\Transport\NodePool\NodePoolInterface; use Http\Client\HttpAsyncClient; use Nyholm\Psr7\Factory\Psr17Factory; @@ -52,7 +53,7 @@ public function testCreate() $this->assertInstanceOf(ClientBuilder::class, $this->builder); } - public function getConfig() + public static function getConfig() { return [ [[ @@ -227,36 +228,11 @@ public function testSetElasticCloudId() $this->assertEquals($this->builder, $result); } - public function getCloudIdExamples() + public function testSetElasticCloudIdThrowsException() { - return [ - ['cluster:d2VzdGV1cm9wZS5henVyZS5lbGFzdGljLWNsb3VkLmNvbTo5MjQzJGM2NjM3ZjMxMmM1MjQzY2RhN2RlZDZlOTllM2QyYzE5JA==', 'c6637f312c5243cda7ded6e99e3d2c19.westeurope.azure.elastic-cloud.com', 9243], - ['cluster:d2VzdGV1cm9wZS5henVyZS5lbGFzdGljLWNsb3VkLmNvbSRlN2RlOWYxMzQ1ZTQ0OTAyODNkOTAzYmU1YjZmOTE5ZSQ=', 'e7de9f1345e4490283d903be5b6f919e.westeurope.azure.elastic-cloud.com', null], - ['cluster:d2VzdGV1cm9wZS5henVyZS5lbGFzdGljLWNsb3VkLmNvbSQ4YWY3ZWUzNTQyMGY0NThlOTAzMDI2YjQwNjQwODFmMiQyMDA2MTU1NmM1NDA0OTg2YmZmOTU3ZDg0YTZlYjUxZg==', '8af7ee35420f458e903026b4064081f2.westeurope.azure.elastic-cloud.com', null] - ]; - } - - /** - * @dataProvider getCloudIdExamples - */ - public function testSetCloudIdWithExamples(string $cloudId, string $url, ?int $port) - { - $this->builder->setElasticCloudId($cloudId); - - $response = $this->psr17Factory->createResponse(200); - $this->httpClient->method('sendRequest') - ->willReturn($response); - $this->builder->setHttpClient($this->httpClient); - - $client = $this->builder->build(); - $this->assertInstanceOf(Client::class, $client); - - $transport = $client->getTransport(); - $request = $this->psr17Factory->createRequest('GET', ''); - $transport->sendRequest($request); - - $this->assertEquals($url, $transport->getLastRequest()->getUri()->getHost()); - $this->assertEquals($port, $transport->getLastRequest()->getUri()->getPort()); + $this->builder->setElasticCloudId('xxx'); + $this->expectException(CloudIdParseException::class); + $client = $this->builder->build(); } public function testSetRetries() diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 01443594e..c584c45fc 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -19,7 +19,6 @@ use Elastic\Elasticsearch\Exception\ClientResponseException; use Elastic\Elasticsearch\Exception\ServerResponseException; use Elastic\Elasticsearch\Response\Elasticsearch; -use Elastic\Transport\NodePool\NodePoolInterface; use Elastic\Transport\Transport; use Elastic\Transport\TransportBuilder; use Http\Mock\Client as MockClient; @@ -193,4 +192,57 @@ public function testSendRequestWithAsyncWillReturnElasticsearch() $this->assertInstanceOf(Promise::class, $result); $this->assertInstanceOf(Elasticsearch::class, $result->wait()); } + + public function testSetServerless() + { + $this->client->setServerless(true); + $this->assertTrue($this->client->getServerless()); + } + + public function testServerlessIsDefaultFalse() + { + $this->assertFalse($this->client->getServerless()); + } + + public function testIsServerlessTrueWhenReponseFromServerless() + { + $request = $this->psr17Factory->createRequest('GET', 'localhost:9200'); + $response = $this->psr17Factory->createResponse(200) + ->withHeader('X-Elastic-Product', 'Elasticsearch') + ->withHeader(Client::API_VERSION_HEADER, Client::API_VERSION); + $this->httpClient->addResponse($response); + + $result = $this->client->sendRequest($request); + $this->assertTrue($this->client->getServerless()); + } + + public function testIsServerlessTrueWhenReponseFromServerlessWithAsyncOnSuccess() + { + $request = $this->psr17Factory->createRequest('GET', 'localhost:9200'); + $response = $this->psr17Factory->createResponse(200) + ->withHeader('X-Elastic-Product', 'Elasticsearch') + ->withHeader(Client::API_VERSION_HEADER, Client::API_VERSION); + $this->httpClient->addResponse($response); + + $this->client->setAsync(true); + $result = $this->client->sendRequest($request); + $this->assertInstanceOf(Promise::class, $result); + $result->wait(); + $this->assertTrue($this->client->getServerless()); + } + + public function testIsServerlessTrueWhenReponseFromServerlessWithAsyncOnSuccessNoException() + { + $request = $this->psr17Factory->createRequest('HEAD', 'localhost:9200'); + $response = $this->psr17Factory->createResponse(200) + ->withHeader('X-Elastic-Product', 'Elasticsearch') + ->withHeader(Client::API_VERSION_HEADER, Client::API_VERSION); + $this->httpClient->addResponse($response); + + $this->client->setAsync(true); + $result = $this->client->sendRequest($request); + $this->assertInstanceOf(Promise::class, $result); + $result->wait(); + $this->assertTrue($this->client->getServerless()); + } } \ No newline at end of file diff --git a/tests/Integration/AliasTest.php b/tests/Integration/AliasTest.php new file mode 100644 index 000000000..ddca13c3b --- /dev/null +++ b/tests/Integration/AliasTest.php @@ -0,0 +1,110 @@ +client = Utility::getClient(); + } + + public static function getIndexNames(): array + { + $data = []; + foreach (self::NAME_INDICES as $index) { + $data[] = [$index]; + } + return $data; + } + + /** + * @dataProvider getIndexNames + */ + public function testCreateIndex(string $index) + { + $response = $this->client->indices()->create([ + 'index' => $index + ]); + $this->assertEquals(200, $response->getStatusCode()); + } + + /** + * @depends testCreateIndex + */ + public function testCreateAlias() + { + $response = $this->client->indices()->putAlias([ + 'index' => self::NAME_INDICES, + 'name' => self::NAME_ALIAS + ]); + $this->assertEquals(200, $response->getStatusCode()); + } + + /** + * @depends testCreateAlias + */ + public function testGetAlias() + { + $response = $this->client->indices()->getAlias([ + 'index' => self::NAME_INDICES + ]); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals(3, count($response->asArray())); + $aliases = array_keys($response->asArray()); + sort($aliases); + $this->assertEquals(self::NAME_INDICES, $aliases); + } + + /** + * @depends testCreateAlias + */ + public function testDeleteAlias() + { + $response = $this->client->indices()->deleteAlias([ + 'index' => self::NAME_INDICES, + 'name' => self::NAME_ALIAS + ]); + $this->assertEquals(200, $response->getStatusCode()); + } + + /** + * @depends testCreateIndex + */ + public function testDeleteIndex() + { + $response = $this->client->indices()->delete([ + 'index' => self::NAME_INDICES + ]); + $this->assertEquals(200, $response->getStatusCode()); + } +} \ No newline at end of file diff --git a/tests/Integration/BasicTest.php b/tests/Integration/BasicTest.php index 0ddc0971a..2a3e23e4a 100644 --- a/tests/Integration/BasicTest.php +++ b/tests/Integration/BasicTest.php @@ -41,7 +41,7 @@ public function testInfo() /** * Get the stock market values */ - public function getDocuments(): array + public static function getDocuments(): array { $docs = []; foreach (file(__DIR__ . '/stocks.csv', FILE_IGNORE_NEW_LINES) as $line) { diff --git a/tests/Response/ElasticsearchTest.php b/tests/Response/ElasticsearchTest.php index 1a3e30827..dd48f4acb 100644 --- a/tests/Response/ElasticsearchTest.php +++ b/tests/Response/ElasticsearchTest.php @@ -15,6 +15,7 @@ namespace Elastic\Elasticsearch\Tests\Response; use DateTime; +use Elastic\Elasticsearch\Client; use Elastic\Elasticsearch\Exception\ArrayAccessException; use Elastic\Elasticsearch\Exception\ClientResponseException; use Elastic\Elasticsearch\Exception\ProductCheckException; @@ -297,4 +298,23 @@ public function testMapToCustomClass() $this->assertEquals(DateTime::class, get_class($iterator[0]->b)); $this->assertEquals('', $iterator[0]->c); } + + public function testIsServerlessFalseByDefault() + { + $this->assertFalse($this->elasticsearch->isServerless()); + } + + public function testIsServerlessTrueWithServerlessResponse() + { + $this->elasticsearch->setResponse( + $this->response200->withHeader(Client::API_VERSION_HEADER, Client::API_VERSION) + ); + $this->assertTrue($this->elasticsearch->isServerless()); + } + + public function testIsServerlessFalseIfNotServerlessResponse() + { + $this->elasticsearch->setResponse($this->response200); + $this->assertFalse($this->elasticsearch->isServerless()); + } } \ No newline at end of file diff --git a/tests/Traits/EndpointTraitTest.php b/tests/Traits/EndpointTraitTest.php index d6e6dc73c..2d4abd0b9 100644 --- a/tests/Traits/EndpointTraitTest.php +++ b/tests/Traits/EndpointTraitTest.php @@ -15,16 +15,23 @@ namespace Elastic\Elasticsearch\Tests\Traits; use Elastic\Elasticsearch\Client; +use Elastic\Elasticsearch\ClientInterface; use Elastic\Elasticsearch\Exception\ContentTypeException; use Elastic\Elasticsearch\Exception\MissingParameterException; use Elastic\Elasticsearch\Traits\EndpointTrait; +use Elastic\Transport\TransportBuilder; +use Http\Mock\Client as MockClient; use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; class EndpointTraitTest extends TestCase { + protected ClientInterface $client; + use EndpointTrait; - public function getQueryStrings(): array + public static function getQueryStrings(): array { return [ ['http://localhost:9200', ['refresh' => true], ['refresh'], 'http://localhost:9200?refresh=true'], @@ -43,7 +50,7 @@ public function testAddQueryString(string $url, array $params, array $keys, stri $this->assertEquals($expected, $result); } - public function getBodySerialized(): array + public static function getBodySerialized(): array { return [ [[ 'foo' => 'bar'], 'application/json', '{"foo":"bar"}'], @@ -66,7 +73,7 @@ public function testBodySerializeUnknownContentTypeThrowsException() $this->bodySerialize(['foo' => 'bar'], 'Unknown-content-type'); } - public function getCompatibilityHeaders() + public static function getCompatibilityHeaders() { return [ [['Content-Type' => 'application/json'], ['Content-Type' => sprintf(Client::API_COMPATIBILITY_HEADER, 'application', 'json')]], @@ -96,7 +103,7 @@ public function testBuildCompatibilityHeaders(array $input, array $expected) $this->assertEquals($expected, $this->buildCompatibilityHeaders($input)); } - public function getRequestParts(): array + public static function getRequestParts(): array { return [ [ 'GET', 'http://localhost:9200', ['Foo' => 'bar', 'Content-Type' => 'application/json'], []], @@ -133,7 +140,7 @@ public function testCreateRequest(string $method, string $url, array $headers, $ } } - public function getRequiredParams(): array + public static function getRequiredParams(): array { return [ [['index'], ['index' => '1'], false], @@ -153,4 +160,42 @@ public function testCheckRequiredParameters(array $required, array $params, bool $this->checkRequiredParameters($required, $params); } } + + public function testCreateRequestContainsApiVersionIfServerlessTrue() + { + $logger = new NullLogger(); + $httpClient = new MockClient(); + + $transport = TransportBuilder::create() + ->setClient($httpClient) + ->build(); + + $this->client = new Client($transport, $logger); + $this->client->setServerless(true); + + $request = $this->createRequest('GET', 'localhost:9200', []); + + $this->assertEquals(Client::API_VERSION, $request->getHeader(Client::API_VERSION_HEADER)[0]); + } + + public function testCreateRequestContainsCompatibilityModeIfServerlessFalse() + { + $logger = new NullLogger(); + $httpClient = new MockClient(); + + $transport = TransportBuilder::create() + ->setClient($httpClient) + ->build(); + + $this->client = new Client($transport, $logger); + $this->client->setServerless(false); + + $request = $this->createRequest('GET', 'localhost:9200', [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + ]); + + $this->assertEquals(sprintf(Client::API_COMPATIBILITY_HEADER, 'application', 'json'), $request->getHeader('Content-Type')[0]); + $this->assertEquals(sprintf(Client::API_COMPATIBILITY_HEADER, 'application', 'json'), $request->getHeader('Accept')[0]); + } } \ No newline at end of file diff --git a/tests/Transport/Adapter/ElasticCurlTest.php b/tests/Transport/Adapter/ElasticCurlTest.php new file mode 100644 index 000000000..f172a61c2 --- /dev/null +++ b/tests/Transport/Adapter/ElasticCurlTest.php @@ -0,0 +1,64 @@ +curlAdapter = new ElasticCurl; + $this->client = $this->createStub(ClientInterface::class); + } + + public function testSetConfigWithEmptyArray() + { + $result = $this->curlAdapter->setConfig($this->client, [], []); + $this->assertInstanceOf(ClientInterface::class, $result); + } + + public function testSetConfigWithSslCert() + { + $client = $this->curlAdapter->setConfig(new Curl(), [ RequestOptions::SSL_CERT => 'test'], []); + $this->assertInstanceOf(Curl::class, $client); + } + + public function testSetConfigWithSslKey() + { + $client = $this->curlAdapter->setConfig(new Curl(), [ RequestOptions::SSL_KEY => 'test'], []); + $this->assertInstanceOf(Curl::class, $client); + } + + public function testSetConfigWithSslVerify() + { + $client = $this->curlAdapter->setConfig(new Curl(), [ RequestOptions::SSL_VERIFY => false], []); + $this->assertInstanceOf(Curl::class, $client); + } + + public function testSetConfigWithSslCa() + { + $client = $this->curlAdapter->setConfig(new Curl(), [ RequestOptions::SSL_CA => 'test'], []); + $this->assertInstanceOf(Curl::class, $client); + } +} \ No newline at end of file diff --git a/tests/Transport/AsyncOnSuccessNoExceptionTest.php b/tests/Transport/AsyncOnSuccessNoExceptionTest.php index 8ab66dadd..764140009 100644 --- a/tests/Transport/AsyncOnSuccessNoExceptionTest.php +++ b/tests/Transport/AsyncOnSuccessNoExceptionTest.php @@ -12,7 +12,7 @@ */ declare(strict_types = 1); -namespace Elastic\Elasticsearch\Tests; +namespace Elastic\Elasticsearch\Tests\Transport; use Elastic\Elasticsearch\Response\Elasticsearch; use Elastic\Elasticsearch\Transport\AsyncOnSuccessNoException; diff --git a/tests/Transport/AsyncOnSuccessTest.php b/tests/Transport/AsyncOnSuccessTest.php index 301f101f8..5776ec476 100644 --- a/tests/Transport/AsyncOnSuccessTest.php +++ b/tests/Transport/AsyncOnSuccessTest.php @@ -12,7 +12,7 @@ */ declare(strict_types = 1); -namespace Elastic\Elasticsearch\Tests; +namespace Elastic\Elasticsearch\Tests\Transport; use Elastic\Elasticsearch\Exception\ClientResponseException; use Elastic\Elasticsearch\Exception\ServerResponseException; diff --git a/tests/Utility.php b/tests/Utility.php index 45ea0a562..fbccb4e4b 100644 --- a/tests/Utility.php +++ b/tests/Utility.php @@ -78,6 +78,12 @@ public static function getHost(): ?string */ public static function getClient(): Client { + if (getenv('TEST_SUITE') === 'serverless' || getenv('TEST_SUITE') === 'cloud') { + return ClientBuilder::create() + ->setHosts([self::getHost()]) + ->setApiKey(getenv('ELASTIC_API_KEY')) + ->build(); + } if (getenv('TEST_SUITE') === 'free') { return ClientBuilder::create() ->setHosts([self::getHost()]) diff --git a/tests/UtilityTest.php b/tests/UtilityTest.php deleted file mode 100644 index f81e14f5a..000000000 --- a/tests/UtilityTest.php +++ /dev/null @@ -1,94 +0,0 @@ -assertEquals('true', Utility::getEnv(Utility::ENV_URL_PLUS_AS_SPACE)); - } - - public function testGetEnvWithDollarEnv() - { - $_ENV[Utility::ENV_URL_PLUS_AS_SPACE] = 'true'; - $this->assertEquals('true', Utility::getEnv(Utility::ENV_URL_PLUS_AS_SPACE)); - } - - public function testGetEnvWithPutEnv() - { - putenv(Utility::ENV_URL_PLUS_AS_SPACE . '=true'); - $this->assertEquals('true', Utility::getEnv(Utility::ENV_URL_PLUS_AS_SPACE)); - } - - public function testUrlWithPlusAsDefault() - { - $url = Utility::urlencode('bar baz'); - $this->assertEquals('bar+baz', $url); - } - - public function testUrlWithPlusWithDollarServer() - { - $_SERVER[Utility::ENV_URL_PLUS_AS_SPACE] = 'true'; - $url = Utility::urlencode('bar baz'); - $this->assertEquals('bar+baz', $url); - } - - public function testUrlWithPlusWithDollarEnv() - { - $_ENV[Utility::ENV_URL_PLUS_AS_SPACE] = 'true'; - $url = Utility::urlencode('bar baz'); - $this->assertEquals('bar+baz', $url); - } - - public function testUrlWithPlusWithPutEnv() - { - putenv(Utility::ENV_URL_PLUS_AS_SPACE . '=true'); - $url = Utility::urlencode('bar baz'); - $this->assertEquals('bar+baz', $url); - } - - public function testUrlWith2BWithDollarServer() - { - $_SERVER[Utility::ENV_URL_PLUS_AS_SPACE] = 'false'; - $url = Utility::urlencode('bar baz'); - $this->assertEquals('bar%20baz', $url); - } - - public function testUrlWith2BWithDollarEnv() - { - $_ENV[Utility::ENV_URL_PLUS_AS_SPACE] = 'false'; - $url = Utility::urlencode('bar baz'); - $this->assertEquals('bar%20baz', $url); - } - - public function testUrlWith2BWithPutEnv() - { - putenv(Utility::ENV_URL_PLUS_AS_SPACE . '=false'); - $url = Utility::urlencode('bar baz'); - $this->assertEquals('bar%20baz', $url); - } -} \ No newline at end of file diff --git a/tests/build_es_tests.php b/tests/build_es_tests.php new file mode 100644 index 000000000..7ba7e0d25 --- /dev/null +++ b/tests/build_es_tests.php @@ -0,0 +1,121 @@ + \n\n", basename(__FILE__)); + printf("where is the directory containing the elasticsearch-client-tests,\n"); + printf(" if the test group: serverless or stack\n"); + printf("and is the output folder containing the PHPUnit tests generated.\n"); + exit(1); +} +if ($argv[1][0] !== '/') { + $testFolder = sprintf("%s/%s", getcwd(), $argv[1]); +} +if (!is_dir($testFolder)) { + printf("Error: the folder %s does not exist!\n", $testFolder); + exit(1); +} + +$testGroup = strtolower($argv[2]); +if (!in_array($testGroup, ['serverless', 'stack'])) { + printf("Error: the test group %s is not valid, it must be one of [%s]\n", implode(',', TEST_GROUP)); + exit(1); +} + +if ($argv[1][0] !== '/') { + $outputFolder = sprintf("%s/%s", getcwd(), $argv[3]); +} +if (!is_dir($outputFolder)) { + mkdir($outputFolder); +} +if (!isFolderEmpty($outputFolder)) { + printf("Error: the folder %s exists and it's not empty!\n", $outputFolder); + exit(1); +} + +$testToSkip = []; +if (is_file(__DIR__ . '/' . TEST_TO_SKIP)) { + $testToSkip = require __DIR__ . '/' . TEST_TO_SKIP; +} + +$it = new RecursiveDirectoryIterator($testFolder); +// Iterate over the Yaml test files +foreach (new RecursiveIteratorIterator($it) as $file) { + + + // Check for folder and create a new one in $outputFolder + if ($file->isDir()) { + continue; + } + + if ($file->getExtension() !== 'yml') { + continue; + } + + // Check for test to be skipped + $relativePath = substr($file->getPathname(), strlen($testFolder)+1); + if (in_array($relativePath, $testToSkip)) { + printf("Skipped: %s\n", $file->getPathname()); + continue; + } + + $folderName = normalizeName(basename(dirname($file->getPathname()))); + $unitTestFolder = $folderName === 'Tests' ? $outputFolder : sprintf("%s/%s", $outputFolder, $folderName); + if (!is_dir($unitTestFolder)) { + mkdir($unitTestFolder); + } + $namespace = $folderName === 'Tests' ? basename($outputFolder) : sprintf("%s\%s", basename($outputFolder), $folderName); + $test = new BuildPHPUnitClass($file->getPathname(), $testGroup, $namespace); + $unitTest = $test->build(); + if (empty($unitTest)) { + printf("Skipped (not %s): %s\n", $testGroup, $file->getPathname()); + continue; + } + $phpCode = (string) $unitTest; + $classes = $unitTest->getClasses(); + $testFileName = sprintf("%s/%s.php", $unitTestFolder, key($classes)); + file_put_contents($testFileName, sprintf("getPathname(), + $e->getMessage() + )); + } +} \ No newline at end of file diff --git a/tests/test_to_skip.php b/tests/test_to_skip.php new file mode 100644 index 000000000..5002e3031 --- /dev/null +++ b/tests/test_to_skip.php @@ -0,0 +1,75 @@ + $value) { if (method_exists($this, $key)) { - $this->$key($value, $vars); + if (!empty($value)) { + $this->$key($value, $vars); + } } else { // headers if (!empty($this->headers)) { diff --git a/util/YamlTests.php b/util/YamlTests.php index 555ec8f89..64a9b7f5c 100644 --- a/util/YamlTests.php +++ b/util/YamlTests.php @@ -52,16 +52,24 @@ class YamlTests 'Cat\Templates\_10_BasicTest::FilteredTemplates' => 'regex mismatch', 'Cat\Templates\_10_BasicTest::SelectColumns' => 'regex mismatch', 'FieldCaps\_50_Fieldtype_FilterTest::*' => 'Bool mismatch', + 'Indices\Create\_20_Synthetic_SourceTest::*' => 'Malformed request', 'Indices\GetAlias\_10_BasicTest::GetAliasAgainstClosedIndices' => 'Failed asserting that true is false', 'Indices\GetIndexTemplate\_10_BasicTest::*' => 'Bool mismatch', 'Indices\PutTemplate\_10_BasicTest::PutTemplateCreate' => 'index_template [test] already exists', 'Indices\Refresh\_10_BasicTest::IndicesRefreshTestEmptyArray' => 'empty array?', 'Indices\ResolveCluster\_10_Basic_Resolve_ClusterTest::TestResolveClusterOptionalParamsAreAccepted' => 'Bool mismatch', 'Indices\SimulateIndexTemplate\_10_BasicTest::SimulateIndexTemplateWithIndexNotMatchingAnyTemplate' => 'Bool mismatch', + 'Indices\ValidateQuery\_10_SynonymsTest::ValidateQueryWithSynonyms' => 'Failed asserting that two strings are equal', + 'IngestGeoip\_20_Geoip_ProcessorTest::*' => 'Undefined array key "geoip"', + 'IngestGeoip\_30_Geoip_StatsTest::TestGeoipStats' => 'Undefined array key "_arbitrary_key_"', + 'IngestGeoip\_50_Ip_Lookup_ProcessorTest::TestIp_locationProcessorWithDefaults' => 'Undefined array key "ip_location"', + 'Search\Suggest\_20_PhraseTest::BreaksTiesBySortingTerms' => 'body not supported', + 'Search\_330_Fetch_FieldsTest::TestWithSubobjectsAuto' => 'unknown subobjects value: auto', 'Search\Vectors\_90_Sparse_VectorTest::SparseVectorIn800X8110' => 'Undefined array key error', 'Snapshot\Create\_10_BasicTest::CreateASnapshot' => 'Invalid snapshot name [test_snapshot]', 'Snapshot\Create\_10_BasicTest::CreateASnapshotAndCleanUpRepository' => 'Invalid snapshot name [test_snapshot]', 'Tsdb\_20_MappingTest::UnsupportedMetricTypePosition' => 'Fixed in Elasticsearch 8.9', + ]; const SKIPPED_TEST_XPACK = [ @@ -117,6 +125,7 @@ class YamlTests 'SearchableSnapshots\_20_Synthetic_SourceTest::*' => 'no_shard_available_action_exception', 'ServiceAccounts\_10_BasicTest::TestServiceAccountTokens' => 'Count mismatch', 'Snapshot\_10_BasicTest::CreateASourceOnlySnapshotAndThenRestoreIt' => 'Snapshot name already exists', + 'Snapshot\_10_BasicTest::FailedToSnapshotIndicesWithSyntheticSource' => 'Failed asserting that 1 matches expected 0', 'Snapshot\_20_Operator_Privileges_DisabledTest::OperatorOnlySettingsCanBeSetAndRestoredByNonoperatorUserWhenOperatorPrivilegesIsDisabled' => 'Count mismatch', 'Spatial\_130_Geo_Shape_RuntimeTest::GetMapping' => 'Escape string issue', 'Sql\_SqlTest::PagingThroughResults' => 'Mismatch values', @@ -265,7 +274,7 @@ public function build(): array self::TEMPLATE_FUNCTION_SKIPPED, [ ':name' => $functionName, - ':skipped_msg' => $skip[$skippedAllTest] + ':skipped_msg' => addslashes($skip[$skippedAllTest]) ] ); } elseif (isset($skip[$skippedTest])) { @@ -273,7 +282,7 @@ public function build(): array self::TEMPLATE_FUNCTION_SKIPPED, [ ':name' => $functionName, - ':skipped_msg' => $skip[$skippedTest] + ':skipped_msg' => addslashes($skip[$skippedTest]) ] ); } else {