Skip to content

Commit

Permalink
Updated API to ES 8.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Nov 9, 2023
1 parent 80712d4 commit 3e4d93c
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 14 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## Release 8.11.0

- Added 5 new EXPERIMENTAL APIs:
- `Esql.query `
- API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/esql.query.json
- Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-query-api.html
- `Inference.deleteModel`
- API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.delete_model.json
- Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html
- `Inference.getModel`
- API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.get_model.json
- Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html
- `Inference.inference`
- API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.inference.json
- Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html
- `Inference.putModel`
- API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.put_model.json
- Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html

## Release 8.10.0

- Added 10 new APIs: 8 EXPERIMENTAL and 2 stable:
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
final class Client implements ClientInterface
{
const CLIENT_NAME = 'es';
const VERSION = '8.10.0';
const VERSION = '8.11.0';
const API_COMPATIBILITY_HEADER = '%s/vnd.elasticsearch+%s; compatible-with=8';

use ClientEndpointsTrait;
Expand Down
67 changes: 67 additions & 0 deletions src/Endpoints/Esql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

/**
* Elasticsearch PHP Client
*
* @link https://github.com/elastic/elasticsearch-php
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license https://opensource.org/licenses/MIT MIT License
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the MIT License.
* See the LICENSE file in the project root for more information.
*/

declare(strict_types=1);

namespace Elastic\Elasticsearch\Endpoints;

use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;

/**
* @generated This file is generated, please do not edit
*/
class Esql extends AbstractEndpoint
{
/**
* Executes an ESQL request
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-query-api.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
* delimiter: string, // The character to use between values within a CSV row. Only valid for the csv format.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that 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 `time_zone` to specify an execution time zone and `columnar` to format the answer.
* } $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 query(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
$url = '/_query';
$method = 'POST';

$url = $this->addQueryString($url, $params, ['format','delimiter','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));
}
}
20 changes: 10 additions & 10 deletions src/Endpoints/Indices.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public function deleteDataStream(array $params = [])
/**
* Deletes an index template.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-template.html
*
* @param array{
* name: string, // (REQUIRED) The name of the template
Expand Down Expand Up @@ -539,7 +539,7 @@ public function deleteIndexTemplate(array $params = [])
/**
* Deletes an index template.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-template-v1.html
*
* @param array{
* name: string, // (REQUIRED) The name of the template
Expand Down Expand Up @@ -741,7 +741,7 @@ public function existsAlias(array $params = [])
/**
* Returns information about whether a particular index template exists.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/index-templates.html
*
* @param array{
* name: string, // (REQUIRED) The name of the template
Expand Down Expand Up @@ -779,7 +779,7 @@ 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-templates.html
* @see 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
Expand Down Expand Up @@ -1194,7 +1194,7 @@ public function getFieldMapping(array $params = [])
/**
* Returns an index template.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-template.html
*
* @param array{
* name: string, // A pattern that returned template names must match
Expand Down Expand Up @@ -1328,7 +1328,7 @@ public function getSettings(array $params = [])
/**
* Returns an index template.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
* @see 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
Expand Down Expand Up @@ -1594,7 +1594,7 @@ public function putDataLifecycle(array $params = [])
/**
* Creates or updates an index template.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-template.html
*
* @param array{
* name: string, // (REQUIRED) The name of the template
Expand Down Expand Up @@ -1724,7 +1724,7 @@ public function putSettings(array $params = [])
/**
* Creates or updates an index template.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates-v1.html
*
* @param array{
* name: string, // (REQUIRED) The name of the template
Expand Down Expand Up @@ -2088,7 +2088,7 @@ 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-templates.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-index.html
*
* @param array{
* name: string, // (REQUIRED) The name of the index (it must be a concrete index name)
Expand Down Expand Up @@ -2129,7 +2129,7 @@ public function simulateIndexTemplate(array $params = [])
/**
* Simulate resolving the given template name or body
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-template.html
*
* @param array{
* name: string, // The name of the index template
Expand Down
181 changes: 181 additions & 0 deletions src/Endpoints/Inference.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<?php

/**
* Elasticsearch PHP Client
*
* @link https://github.com/elastic/elasticsearch-php
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license https://opensource.org/licenses/MIT MIT License
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the MIT License.
* See the LICENSE file in the project root for more information.
*/

declare(strict_types=1);

namespace Elastic\Elasticsearch\Endpoints;

use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;

/**
* @generated This file is generated, please do not edit
*/
class Inference extends AbstractEndpoint
{
/**
* Delete model in the Inference API
*
* @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
*
* @param array{
* task_type: string, // (REQUIRED) The model task type
* model_id: string, // (REQUIRED) The model 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.
* } $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 deleteModel(array $params = [])
{
$this->checkRequiredParameters(['task_type','model_id'], $params);
$url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']);
$method = 'DELETE';

$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}


/**
* Get a model in the Inference API
*
* @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
*
* @param array{
* task_type: string, // (REQUIRED) The model task type
* model_id: string, // (REQUIRED) The model 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.
* } $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 getModel(array $params = [])
{
$this->checkRequiredParameters(['task_type','model_id'], $params);
$url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']);
$method = 'GET';

$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}


/**
* Perform inference on a model
*
* @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
*
* @param array{
* task_type: string, // (REQUIRED) The model task type
* model_id: string, // (REQUIRED) The model 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.
* body: array, // The inference payload
* } $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 inference(array $params = [])
{
$this->checkRequiredParameters(['task_type','model_id'], $params);
$url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']);
$method = 'POST';

$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));
}


/**
* Configure a model 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
*
* @param array{
* task_type: string, // (REQUIRED) The model task type
* model_id: string, // (REQUIRED) The model 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.
* body: array, // The model's task and service settings
* } $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 putModel(array $params = [])
{
$this->checkRequiredParameters(['task_type','model_id'], $params);
$url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_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));
}
}
Loading

0 comments on commit 3e4d93c

Please sign in to comment.