diff --git a/.ci/jobs/elastic+elasticsearch-php+6.8.x.yml b/.ci/jobs/elastic+elasticsearch-php+8.4.yml similarity index 56% rename from .ci/jobs/elastic+elasticsearch-php+6.8.x.yml rename to .ci/jobs/elastic+elasticsearch-php+8.4.yml index 50455c049..27f516b81 100644 --- a/.ci/jobs/elastic+elasticsearch-php+6.8.x.yml +++ b/.ci/jobs/elastic+elasticsearch-php+8.4.yml @@ -1,12 +1,12 @@ --- - job: - name: elastic+elasticsearch-php+6.8.x - display-name: 'elastic / elasticsearch-php # 6.8.x' - description: Testing the elasticsearch-php 6.8.x branch. + name: elastic+elasticsearch-php+8.4 + display-name: 'elastic / elasticsearch-php # 8.4' + description: Testing the elasticsearch-php 8.4 branch. parameters: - string: name: branch_specifier - default: refs/heads/6.8.x + default: refs/heads/8.4 description: the Git branch specifier to build (<branchName>, <tagName>, <commitId>, etc.) triggers: diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index e0da51323..2dd495a1f 100644 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -1,6 +1,6 @@ --- STACK_VERSION: - - 8.4.0-SNAPSHOT + - 8.4-SNAPSHOT PHP_VERSION: - 8.1-cli diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 80c34b56e..800c5bd11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: matrix: php-version: [7.4, 8.0, 8.1] os: [ubuntu-latest] - es-version: [8.4.0-SNAPSHOT] + es-version: [8.4-SNAPSHOT] steps: - name: Checkout diff --git a/README.md b/README.md index 6494965d2..f85f86be1 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ This is the official PHP client for - [Search a document](#search-a-document) - [Delete a document](#delete-a-document) - [Versioning](#versioning) -- [Backward Incompatible Changes](#backward-incompatible-changes-) +- [Backward Incompatible Changes](#backward-incompatible-changes-boom) - [Mock the Elasticsearch client](#mock-the-elasticsearch-client) - [FAQ](#faq-) - [Contribute](#contribute-) @@ -118,7 +118,7 @@ docker run --name es01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elasti This command creates an `elastic` Docker network and start Elasticsearch using the port `9200` (default). -When you run the docker imnage a password is generated for the `elastic` user +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 Elasticsearch. @@ -384,7 +384,7 @@ section of PHP-HTTP documentation. ### Where do I report issues with the client? If something is not working as expected, please open an -[issue](https://github.com/elastic/elasticsearh-php/issues/new). +[issue](https://github.com/elastic/elasticsearch-php/issues/new). ### Where else can I go to get help? diff --git a/docs/installation.asciidoc b/docs/installation.asciidoc index 371c76304..0b3b35f3c 100644 --- a/docs/installation.asciidoc +++ b/docs/installation.asciidoc @@ -29,7 +29,7 @@ create this object, as follows: -------------------------- require 'vendor/autoload.php'; -$client = Elasticsearch\ClientBuilder::create()->build(); +$client = Elastic\Elasticsearch\ClientBuilder::create()->build(); -------------------------- + Client instantiation is performed with a static helper function `create()`. This diff --git a/src/Endpoints/Ml.php b/src/Endpoints/Ml.php index a8fdceac4..a8d7e408a 100644 --- a/src/Endpoints/Ml.php +++ b/src/Endpoints/Ml.php @@ -2340,6 +2340,7 @@ public function startDatafeed(array $params = []) * * @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. * number_of_allocations: int, // The number of model allocations on each node where the model is deployed. * threads_per_allocation: int, // The number of threads used by each model allocation during inference. * queue_capacity: int, // Controls how many inference requests are allowed in the queue at a time. @@ -2365,7 +2366,7 @@ public function startTrainedModelDeployment(array $params = []) $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/deployment/_start'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['number_of_allocations','threads_per_allocation','queue_capacity','timeout','wait_for','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['cache_size','number_of_allocations','threads_per_allocation','queue_capacity','timeout','wait_for','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Endpoints/Security.php b/src/Endpoints/Security.php index 6eabb624a..83349b0b2 100644 --- a/src/Endpoints/Security.php +++ b/src/Endpoints/Security.php @@ -1908,6 +1908,43 @@ 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 + * + * @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. + * } $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 updateApiKey(array $params = []) + { + $this->checkRequiredParameters(['id'], $params); + $url = '/_security/api_key/' . $this->encode($params['id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + /** * Update application specific data for the user profile of the given unique ID. * diff --git a/src/Endpoints/Snapshot.php b/src/Endpoints/Snapshot.php index 6f9b13b49..f2732da66 100644 --- a/src/Endpoints/Snapshot.php +++ b/src/Endpoints/Snapshot.php @@ -272,6 +272,13 @@ public function deleteRepository(array $params = []) * 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) @@ -293,7 +300,7 @@ public function get(array $params = []) $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']); $method = 'GET'; - $url = $this->addQueryString($url, $params, ['master_timeout','ignore_unavailable','index_names','index_details','include_repository','verbose','pretty','human','error_trace','source','filter_path']); + $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']); $headers = [ 'Accept' => 'application/json', ]; diff --git a/src/Traits/ClientEndpointsTrait.php b/src/Traits/ClientEndpointsTrait.php index 7e434d6ac..ac2ed6123 100644 --- a/src/Traits/ClientEndpointsTrait.php +++ b/src/Traits/ClientEndpointsTrait.php @@ -629,6 +629,7 @@ public function fieldCaps(array $params = []) * @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 @@ -659,7 +660,7 @@ public function get(array $params = []) $url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']); $method = 'GET'; - $url = $this->addQueryString($url, $params, ['stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['force_synthetic_source','stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -943,6 +944,7 @@ public function knnSearch(array $params = []) * * @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 @@ -975,7 +977,7 @@ public function mget(array $params = []) $url = '/_mget'; $method = empty($params['body']) ? 'GET' : 'POST'; } - $url = $this->addQueryString($url, $params, ['stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['force_synthetic_source','stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -1499,6 +1501,7 @@ public function scroll(array $params = []) * 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) @@ -1556,7 +1559,7 @@ public function search(array $params = []) $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','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','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','min_compatible_shard_node','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/util/YamlTests.php b/util/YamlTests.php index 42e0d67cf..655bc3ef7 100644 --- a/util/YamlTests.php +++ b/util/YamlTests.php @@ -35,7 +35,8 @@ class YamlTests const YAML_FILES_TO_OMIT = [ 'platinum/eql/10_basic.yml', // use of _internal APIs - 'free/cluster.desired_nodes/10_basic.yml', + 'free/cluster.desired_nodes/10_basic.yml', + 'free/cluster.desired_nodes/20_dry_run.yml', 'free/health/' ];