Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit dda1a26

Browse files
committed
Updated API endpoints
1 parent 8991080 commit dda1a26

33 files changed

+2090
-1002
lines changed

src/ClientBuilder.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
use Elastic\Transport\Exception\NoAsyncClientException;
2727
use Elastic\Transport\Transport;
2828
use Elastic\Transport\TransportBuilder;
29-
use GuzzleHttp\Client as GuzzleHttpClient;
3029
use Http\Client\HttpAsyncClient;
3130
use Psr\Http\Client\ClientInterface;
3231
use Psr\Log\LoggerInterface;
@@ -136,7 +135,7 @@ public static function create(): ClientBuilder
136135
* ignore unknown settings
137136
* @throws ConfigException
138137
*/
139-
public static function fromConfig(array $config, bool $quiet = false): ClientInterface
138+
public static function fromConfig(array $config, bool $quiet = false): ServerlessClientInterface
140139
{
141140
$builder = new static;
142141
foreach ($config as $key => $value) {
@@ -281,14 +280,14 @@ public function setHttpClientOptions(array $options): ClientBuilder
281280
/**
282281
* Build and returns the Client object
283282
*/
284-
public function build(): Client
283+
public function build(): ServerlessClientInterface
285284
{
286285
// Transport builder
287286
$builder = TransportBuilder::create();
288287

289288
// Set the default hosts if empty
290289
if (empty($this->host)) {
291-
throw new MissingParameterException('You need specify the serverleess endpoint (host)');
290+
throw new MissingParameterException('You need specify the serverless endpoint (host)');
292291
}
293292
$builder->setHosts([$this->host]);
294293

src/Endpoints/AsyncSearch.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class AsyncSearch extends AbstractEndpoint
4949
*/
5050
public function delete(string $id, array $params = []): Elasticsearch|Promise
5151
{
52-
$url = $this->encode("/_async_search/{$id}");
52+
$url = '/_async_search/' . $this->encode($id) . '';
5353
$method = 'DELETE';
5454
$url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
5555
$headers = [
@@ -83,7 +83,7 @@ public function delete(string $id, array $params = []): Elasticsearch|Promise
8383
*/
8484
public function get(string $id, array $params = []): Elasticsearch|Promise
8585
{
86-
$url = $this->encode("/_async_search/{$id}");
86+
$url = '/_async_search/' . $this->encode($id) . '';
8787
$method = 'GET';
8888
$url = $this->addQueryString($url, $params, [
8989
'keep_alive',
@@ -123,7 +123,7 @@ public function get(string $id, array $params = []): Elasticsearch|Promise
123123
*/
124124
public function status(string $id, array $params = []): Elasticsearch|Promise
125125
{
126-
$url = $this->encode("/_async_search/status/{$id}");
126+
$url = '/_async_search/status/' . $this->encode($id) . '';
127127
$method = 'GET';
128128
$url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
129129
$headers = [
@@ -207,7 +207,7 @@ public function submit(
207207
{
208208
$index = $this->convertValue($index);
209209
if (isset($index)) {
210-
$url = $this->encode("/{$index}/_async_search");
210+
$url = '/' . $this->encode($index) . '/_async_search';
211211
$method = 'POST';
212212
} else {
213213
$url = "/_async_search";

src/Endpoints/Cat.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function aliases(string|array $name = null, array $params = []): Elastics
5252
{
5353
$name = $this->convertValue($name);
5454
if (isset($name)) {
55-
$url = $this->encode("/_cat/aliases/{$name}");
55+
$url = '/_cat/aliases/' . $this->encode($name) . '';
5656
$method = 'GET';
5757
} else {
5858
$url = "/_cat/aliases";
@@ -95,7 +95,7 @@ public function aliases(string|array $name = null, array $params = []): Elastics
9595
public function componentTemplates(string $name = null, array $params = []): Elasticsearch|Promise
9696
{
9797
if (isset($name)) {
98-
$url = $this->encode("/_cat/component_templates/{$name}");
98+
$url = '/_cat/component_templates/' . $this->encode($name) . '';
9999
$method = 'GET';
100100
} else {
101101
$url = "/_cat/component_templates";
@@ -133,7 +133,7 @@ public function count(string|array $index = null, array $params = []): Elasticse
133133
{
134134
$index = $this->convertValue($index);
135135
if (isset($index)) {
136-
$url = $this->encode("/_cat/count/{$index}");
136+
$url = '/_cat/count/' . $this->encode($index) . '';
137137
$method = 'GET';
138138
} else {
139139
$url = "/_cat/count";
@@ -207,7 +207,7 @@ public function indices(string|array $index = null, array $params = []): Elastic
207207
{
208208
$index = $this->convertValue($index);
209209
if (isset($index)) {
210-
$url = $this->encode("/_cat/indices/{$index}");
210+
$url = '/_cat/indices/' . $this->encode($index) . '';
211211
$method = 'GET';
212212
} else {
213213
$url = "/_cat/indices";
@@ -260,7 +260,7 @@ public function indices(string|array $index = null, array $params = []): Elastic
260260
public function mlDataFrameAnalytics(string $id = null, array $params = []): Elasticsearch|Promise
261261
{
262262
if (isset($id)) {
263-
$url = $this->encode("/_cat/ml/data_frame/analytics/{$id}");
263+
$url = '/_cat/ml/data_frame/analytics/' . $this->encode($id) . '';
264264
$method = 'GET';
265265
} else {
266266
$url = "/_cat/ml/data_frame/analytics";
@@ -311,7 +311,7 @@ public function mlDataFrameAnalytics(string $id = null, array $params = []): Ela
311311
public function mlDatafeeds(string $datafeed_id = null, array $params = []): Elasticsearch|Promise
312312
{
313313
if (isset($datafeed_id)) {
314-
$url = $this->encode("/_cat/ml/datafeeds/{$datafeed_id}");
314+
$url = '/_cat/ml/datafeeds/' . $this->encode($datafeed_id) . '';
315315
$method = 'GET';
316316
} else {
317317
$url = "/_cat/ml/datafeeds";
@@ -362,7 +362,7 @@ public function mlDatafeeds(string $datafeed_id = null, array $params = []): Ela
362362
public function mlJobs(string $job_id = null, array $params = []): Elasticsearch|Promise
363363
{
364364
if (isset($job_id)) {
365-
$url = $this->encode("/_cat/ml/anomaly_detectors/{$job_id}");
365+
$url = '/_cat/ml/anomaly_detectors/' . $this->encode($job_id) . '';
366366
$method = 'GET';
367367
} else {
368368
$url = "/_cat/ml/anomaly_detectors";
@@ -392,14 +392,14 @@ public function mlJobs(string $job_id = null, array $params = []): Elasticsearch
392392
*
393393
* @see https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/cat-trained-model.html
394394
*
395-
* @param string $model_id The ID of the trained models stats to fetch
395+
* @param string $model_id A unique identifier for the trained model.
396396
* @param array{
397-
* 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)
398-
* bytes: string, // The unit in which to display byte values
399-
* h: string|array, // Comma-separated list of column names to display
400-
* s: string|array, // Comma-separated list of column names or column aliases to sort by
401-
* from: integer, // skips a number of trained models
402-
* size: integer, // specifies a max number of trained models to get
397+
* allow_no_match: bool, // Specifies what to do when the request: contains wildcard expressions and there are no models that match; contains the `_all` string or no identifiers and there are no matches; contains wildcard expressions and there are only partial matches.If `true`, the API returns an empty array when there are no matches and the subset of results when there are partial matches.If `false`, the API returns a 404 status code when there are no matches or only partial matches.
398+
* bytes: string, // The unit used to display byte values.
399+
* h: string|array, // A comma-separated list of column names to display.
400+
* s: string|array, // A comma-separated list of column names or aliases used to sort the response.
401+
* from: integer, // Skips the specified number of transforms.
402+
* size: integer, // The maximum number of transforms to display.
403403
* pretty: bool, // Pretty format the returned JSON response. (DEFAULT: false)
404404
* human: bool, // Return human readable values for statistics. (DEFAULT: true)
405405
* error_trace: bool, // Include the stack trace of returned errors. (DEFAULT: false)
@@ -415,7 +415,7 @@ public function mlJobs(string $job_id = null, array $params = []): Elasticsearch
415415
public function mlTrainedModels(string $model_id = null, array $params = []): Elasticsearch|Promise
416416
{
417417
if (isset($model_id)) {
418-
$url = $this->encode("/_cat/ml/trained_models/{$model_id}");
418+
$url = '/_cat/ml/trained_models/' . $this->encode($model_id) . '';
419419
$method = 'GET';
420420
} else {
421421
$url = "/_cat/ml/trained_models";
@@ -446,14 +446,15 @@ public function mlTrainedModels(string $model_id = null, array $params = []): El
446446
*
447447
* @see https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/cat-transforms.html
448448
*
449-
* @param string $transform_id The id of the transform for which to get stats. '_all' or '*' implies all transforms
449+
* @param string $transform_id A transform identifier or a wildcard expression.
450+
* If you do not specify one of these options, the API returns information for all transforms.
450451
* @param array{
451-
* 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)
452-
* from: integer, // skips a number of transform configs, defaults to 0
452+
* allow_no_match: bool, // Specifies what to do when the request: contains wildcard expressions and there are no transforms that match; contains the `_all` string or no identifiers and there are no matches; contains wildcard expressions and there are only partial matches.If `true`, it returns an empty transforms array when there are no matches and the subset of results when there are partial matches.If `false`, the request returns a 404 status code when there are no matches or only partial matches.
453+
* from: integer, // Skips the specified number of transforms.
453454
* h: string|array, // Comma-separated list of column names to display.
454-
* s: string|array, // Comma-separated list of column names or column aliases used to sort theresponse.
455-
* time: string, // Unit used to display time values.
456-
* size: integer, // specifies a max number of transforms to get, defaults to 100
455+
* s: string|array, // Comma-separated list of column names or column aliases used to sort the response.
456+
* time: string, // The unit used to display time values.
457+
* size: integer, // The maximum number of transforms to obtain.
457458
* pretty: bool, // Pretty format the returned JSON response. (DEFAULT: false)
458459
* human: bool, // Return human readable values for statistics. (DEFAULT: true)
459460
* error_trace: bool, // Include the stack trace of returned errors. (DEFAULT: false)
@@ -469,7 +470,7 @@ public function mlTrainedModels(string $model_id = null, array $params = []): El
469470
public function transforms(string $transform_id = null, array $params = []): Elasticsearch|Promise
470471
{
471472
if (isset($transform_id)) {
472-
$url = $this->encode("/_cat/transforms/{$transform_id}");
473+
$url = '/_cat/transforms/' . $this->encode($transform_id) . '';
473474
$method = 'GET';
474475
} else {
475476
$url = "/_cat/transforms";

0 commit comments

Comments
 (0)