Skip to content

Commit 3e4d93c

Browse files
committed
Updated API to ES 8.11.0
1 parent 80712d4 commit 3e4d93c

File tree

8 files changed

+319
-14
lines changed

8 files changed

+319
-14
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
## Release 8.11.0
2+
3+
- Added 5 new EXPERIMENTAL APIs:
4+
- `Esql.query `
5+
- API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/esql.query.json
6+
- Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-query-api.html
7+
- `Inference.deleteModel`
8+
- API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.delete_model.json
9+
- Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html
10+
- `Inference.getModel`
11+
- API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.get_model.json
12+
- Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html
13+
- `Inference.inference`
14+
- API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.inference.json
15+
- Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html
16+
- `Inference.putModel`
17+
- API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.put_model.json
18+
- Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html
19+
120
## Release 8.10.0
221

322
- Added 10 new APIs: 8 EXPERIMENTAL and 2 stable:

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
final class Client implements ClientInterface
2929
{
3030
const CLIENT_NAME = 'es';
31-
const VERSION = '8.10.0';
31+
const VERSION = '8.11.0';
3232
const API_COMPATIBILITY_HEADER = '%s/vnd.elasticsearch+%s; compatible-with=8';
3333

3434
use ClientEndpointsTrait;

src/Endpoints/Esql.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/**
4+
* Elasticsearch PHP Client
5+
*
6+
* @link https://github.com/elastic/elasticsearch-php
7+
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
8+
* @license https://opensource.org/licenses/MIT MIT License
9+
*
10+
* Licensed to Elasticsearch B.V under one or more agreements.
11+
* Elasticsearch B.V licenses this file to you under the MIT License.
12+
* See the LICENSE file in the project root for more information.
13+
*/
14+
15+
declare(strict_types=1);
16+
17+
namespace Elastic\Elasticsearch\Endpoints;
18+
19+
use Elastic\Elasticsearch\Exception\ClientResponseException;
20+
use Elastic\Elasticsearch\Exception\MissingParameterException;
21+
use Elastic\Elasticsearch\Exception\ServerResponseException;
22+
use Elastic\Elasticsearch\Response\Elasticsearch;
23+
use Elastic\Transport\Exception\NoNodeAvailableException;
24+
use Http\Promise\Promise;
25+
26+
/**
27+
* @generated This file is generated, please do not edit
28+
*/
29+
class Esql extends AbstractEndpoint
30+
{
31+
/**
32+
* Executes an ESQL request
33+
*
34+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-query-api.html
35+
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
36+
*
37+
* @param array{
38+
* format: string, // a short version of the Accept header, e.g. json, yaml
39+
* delimiter: string, // The character to use between values within a CSV row. Only valid for the csv format.
40+
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
41+
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
42+
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
43+
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
44+
* filter_path: list, // A comma-separated list of filters used to reduce the response.
45+
* 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.
46+
* } $params
47+
*
48+
* @throws NoNodeAvailableException if all the hosts are offline
49+
* @throws ClientResponseException if the status code of response is 4xx
50+
* @throws ServerResponseException if the status code of response is 5xx
51+
*
52+
* @return Elasticsearch|Promise
53+
*/
54+
public function query(array $params = [])
55+
{
56+
$this->checkRequiredParameters(['body'], $params);
57+
$url = '/_query';
58+
$method = 'POST';
59+
60+
$url = $this->addQueryString($url, $params, ['format','delimiter','pretty','human','error_trace','source','filter_path']);
61+
$headers = [
62+
'Accept' => 'application/json',
63+
'Content-Type' => 'application/json',
64+
];
65+
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
66+
}
67+
}

src/Endpoints/Indices.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ public function deleteDataStream(array $params = [])
502502
/**
503503
* Deletes an index template.
504504
*
505-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
505+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-template.html
506506
*
507507
* @param array{
508508
* name: string, // (REQUIRED) The name of the template
@@ -539,7 +539,7 @@ public function deleteIndexTemplate(array $params = [])
539539
/**
540540
* Deletes an index template.
541541
*
542-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
542+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-template-v1.html
543543
*
544544
* @param array{
545545
* name: string, // (REQUIRED) The name of the template
@@ -741,7 +741,7 @@ public function existsAlias(array $params = [])
741741
/**
742742
* Returns information about whether a particular index template exists.
743743
*
744-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
744+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/index-templates.html
745745
*
746746
* @param array{
747747
* name: string, // (REQUIRED) The name of the template
@@ -779,7 +779,7 @@ public function existsIndexTemplate(array $params = [])
779779
/**
780780
* Returns information about whether a particular index template exists.
781781
*
782-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
782+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-template-exists-v1.html
783783
*
784784
* @param array{
785785
* name: list, // (REQUIRED) The comma separated names of the index templates
@@ -1194,7 +1194,7 @@ public function getFieldMapping(array $params = [])
11941194
/**
11951195
* Returns an index template.
11961196
*
1197-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
1197+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-template.html
11981198
*
11991199
* @param array{
12001200
* name: string, // A pattern that returned template names must match
@@ -1328,7 +1328,7 @@ public function getSettings(array $params = [])
13281328
/**
13291329
* Returns an index template.
13301330
*
1331-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
1331+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-template-v1.html
13321332
*
13331333
* @param array{
13341334
* name: list, // The comma separated names of the index templates
@@ -1594,7 +1594,7 @@ public function putDataLifecycle(array $params = [])
15941594
/**
15951595
* Creates or updates an index template.
15961596
*
1597-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
1597+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-template.html
15981598
*
15991599
* @param array{
16001600
* name: string, // (REQUIRED) The name of the template
@@ -1724,7 +1724,7 @@ public function putSettings(array $params = [])
17241724
/**
17251725
* Creates or updates an index template.
17261726
*
1727-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
1727+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates-v1.html
17281728
*
17291729
* @param array{
17301730
* name: string, // (REQUIRED) The name of the template
@@ -2088,7 +2088,7 @@ public function shrink(array $params = [])
20882088
/**
20892089
* Simulate matching the given index name against the index templates in the system
20902090
*
2091-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
2091+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-index.html
20922092
*
20932093
* @param array{
20942094
* name: string, // (REQUIRED) The name of the index (it must be a concrete index name)
@@ -2129,7 +2129,7 @@ public function simulateIndexTemplate(array $params = [])
21292129
/**
21302130
* Simulate resolving the given template name or body
21312131
*
2132-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html
2132+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-template.html
21332133
*
21342134
* @param array{
21352135
* name: string, // The name of the index template

src/Endpoints/Inference.php

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
<?php
2+
3+
/**
4+
* Elasticsearch PHP Client
5+
*
6+
* @link https://github.com/elastic/elasticsearch-php
7+
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
8+
* @license https://opensource.org/licenses/MIT MIT License
9+
*
10+
* Licensed to Elasticsearch B.V under one or more agreements.
11+
* Elasticsearch B.V licenses this file to you under the MIT License.
12+
* See the LICENSE file in the project root for more information.
13+
*/
14+
15+
declare(strict_types=1);
16+
17+
namespace Elastic\Elasticsearch\Endpoints;
18+
19+
use Elastic\Elasticsearch\Exception\ClientResponseException;
20+
use Elastic\Elasticsearch\Exception\MissingParameterException;
21+
use Elastic\Elasticsearch\Exception\ServerResponseException;
22+
use Elastic\Elasticsearch\Response\Elasticsearch;
23+
use Elastic\Transport\Exception\NoNodeAvailableException;
24+
use Http\Promise\Promise;
25+
26+
/**
27+
* @generated This file is generated, please do not edit
28+
*/
29+
class Inference extends AbstractEndpoint
30+
{
31+
/**
32+
* Delete model in the Inference API
33+
*
34+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html
35+
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
36+
*
37+
* @param array{
38+
* task_type: string, // (REQUIRED) The model task type
39+
* model_id: string, // (REQUIRED) The model Id
40+
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
41+
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
42+
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
43+
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
44+
* filter_path: list, // A comma-separated list of filters used to reduce the response.
45+
* } $params
46+
*
47+
* @throws MissingParameterException if a required parameter is missing
48+
* @throws NoNodeAvailableException if all the hosts are offline
49+
* @throws ClientResponseException if the status code of response is 4xx
50+
* @throws ServerResponseException if the status code of response is 5xx
51+
*
52+
* @return Elasticsearch|Promise
53+
*/
54+
public function deleteModel(array $params = [])
55+
{
56+
$this->checkRequiredParameters(['task_type','model_id'], $params);
57+
$url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']);
58+
$method = 'DELETE';
59+
60+
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
61+
$headers = [
62+
'Accept' => 'application/json',
63+
];
64+
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
65+
}
66+
67+
68+
/**
69+
* Get a model in the Inference API
70+
*
71+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html
72+
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
73+
*
74+
* @param array{
75+
* task_type: string, // (REQUIRED) The model task type
76+
* model_id: string, // (REQUIRED) The model Id
77+
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
78+
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
79+
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
80+
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
81+
* filter_path: list, // A comma-separated list of filters used to reduce the response.
82+
* } $params
83+
*
84+
* @throws MissingParameterException if a required parameter is missing
85+
* @throws NoNodeAvailableException if all the hosts are offline
86+
* @throws ClientResponseException if the status code of response is 4xx
87+
* @throws ServerResponseException if the status code of response is 5xx
88+
*
89+
* @return Elasticsearch|Promise
90+
*/
91+
public function getModel(array $params = [])
92+
{
93+
$this->checkRequiredParameters(['task_type','model_id'], $params);
94+
$url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']);
95+
$method = 'GET';
96+
97+
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
98+
$headers = [
99+
'Accept' => 'application/json',
100+
];
101+
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
102+
}
103+
104+
105+
/**
106+
* Perform inference on a model
107+
*
108+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html
109+
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
110+
*
111+
* @param array{
112+
* task_type: string, // (REQUIRED) The model task type
113+
* model_id: string, // (REQUIRED) The model Id
114+
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
115+
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
116+
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
117+
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
118+
* filter_path: list, // A comma-separated list of filters used to reduce the response.
119+
* body: array, // The inference payload
120+
* } $params
121+
*
122+
* @throws MissingParameterException if a required parameter is missing
123+
* @throws NoNodeAvailableException if all the hosts are offline
124+
* @throws ClientResponseException if the status code of response is 4xx
125+
* @throws ServerResponseException if the status code of response is 5xx
126+
*
127+
* @return Elasticsearch|Promise
128+
*/
129+
public function inference(array $params = [])
130+
{
131+
$this->checkRequiredParameters(['task_type','model_id'], $params);
132+
$url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']);
133+
$method = 'POST';
134+
135+
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
136+
$headers = [
137+
'Accept' => 'application/json',
138+
'Content-Type' => 'application/json',
139+
];
140+
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
141+
}
142+
143+
144+
/**
145+
* Configure a model for use in the Inference API
146+
*
147+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html
148+
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
149+
*
150+
* @param array{
151+
* task_type: string, // (REQUIRED) The model task type
152+
* model_id: string, // (REQUIRED) The model Id
153+
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
154+
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
155+
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
156+
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
157+
* filter_path: list, // A comma-separated list of filters used to reduce the response.
158+
* body: array, // The model's task and service settings
159+
* } $params
160+
*
161+
* @throws MissingParameterException if a required parameter is missing
162+
* @throws NoNodeAvailableException if all the hosts are offline
163+
* @throws ClientResponseException if the status code of response is 4xx
164+
* @throws ServerResponseException if the status code of response is 5xx
165+
*
166+
* @return Elasticsearch|Promise
167+
*/
168+
public function putModel(array $params = [])
169+
{
170+
$this->checkRequiredParameters(['task_type','model_id'], $params);
171+
$url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']);
172+
$method = 'PUT';
173+
174+
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
175+
$headers = [
176+
'Accept' => 'application/json',
177+
'Content-Type' => 'application/json',
178+
];
179+
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
180+
}
181+
}

0 commit comments

Comments
 (0)