Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated opensearch-php to reflect the latest OpenSearch API spec #243

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
- Fixed PHP 8.4 deprecations
### Updated APIs
- Updated opensearch-php APIs to reflect [opensearch-api-specification@3d88921](https://github.com/opensearch-project/opensearch-api-specification/commit/3d88921265d1dfeacc64e4bd05c8b3837bc0e0aa)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@ebe0f8a](https://github.com/opensearch-project/opensearch-api-specification/commit/ebe0f8a885f7db7e882d160c101055a5aa70a707)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@398481e](https://github.com/opensearch-project/opensearch-api-specification/commit/398481e5bd1cc590d947c35379c47096f2114f00)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@6bb1fed](https://github.com/opensearch-project/opensearch-api-specification/commit/6bb1fed0a2c7cf094a5ecfdb01f0306a4b9f8eba)
Expand Down
3 changes: 1 addition & 2 deletions src/OpenSearch/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ public function reindex(array $params = [])
}

/**
* Changes the number of requests per second for a particular Reindex operation.
* Changes the number of requests per second for a particular reindex operation.
*
* $params['task_id'] = (string) Identifier for the task. (Required)
* $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second.
Expand Down Expand Up @@ -1400,7 +1400,6 @@ public function scriptsPainlessExecute(array $params = [])
* $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
* $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
* $params['body'] = (array) The scroll ID if not passed by URL or query parameter.
*
* @param array $params Associative array of parameters
* @return array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'flat_settings',
'local',
'master_timeout',
'pretty',
Expand Down
10 changes: 0 additions & 10 deletions src/OpenSearch/Endpoints/Indices/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,4 @@ public function getMethod(): string
{
return 'POST';
}

public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
}
$this->body = $body;

return $this;
}
}
67 changes: 49 additions & 18 deletions src/OpenSearch/Endpoints/Ml/Predict.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,67 @@
use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Predict extends AbstractEndpoint
{
/**
* @return string[]
*/
protected $algorithm_name;
protected $model_id;

public function getURI(): string
{
$algorithm_name = $this->algorithm_name ?? null;
$model_id = $this->model_id ?? null;
if (isset($algorithm_name) && isset($model_id)) {
return "/_plugins/_ml/_predict/$algorithm_name/$model_id";
}
throw new RuntimeException('Missing parameter for the endpoint ml.predict');
}

public function getParamWhitelist(): array
{
return [];
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

/**
* @return string
*/
public function getURI(): string
public function getMethod(): string
{
return 'POST';
}

public function setBody($body): static
{
if ($this->id) {
return "/_plugins/_ml/models/$this->id/_predict";
if (isset($body) !== true) {
return $this;
}
$this->body = $body;

throw new RuntimeException(
'id is required for predict'
);
return $this;
}

public function setAlgorithmName($algorithm_name): static
{
if (isset($algorithm_name) !== true) {
return $this;
}
$this->algorithm_name = $algorithm_name;

return $this;
}

/**
* @return string
*/
public function getMethod(): string
public function setModelId($model_id): static
{
return 'POST';
if (isset($model_id) !== true) {
return $this;
}
$this->model_id = $model_id;

return $this;
}
}
72 changes: 72 additions & 0 deletions src/OpenSearch/Endpoints/Ml/Train.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\Ml;

use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Train extends AbstractEndpoint
{
protected $algorithm_name;

public function getURI(): string
{
$algorithm_name = $this->algorithm_name ?? null;
if (isset($algorithm_name)) {
return "/_plugins/_ml/_train/$algorithm_name";
}
throw new RuntimeException('Missing parameter for the endpoint ml.train');
}

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'POST';
}

public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
}
$this->body = $body;

return $this;
}

public function setAlgorithmName($algorithm_name): static
{
if (isset($algorithm_name) !== true) {
return $this;
}
$this->algorithm_name = $algorithm_name;

return $this;
}
}
72 changes: 72 additions & 0 deletions src/OpenSearch/Endpoints/Ml/TrainPredict.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\Ml;

use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class TrainPredict extends AbstractEndpoint
{
protected $algorithm_name;

public function getURI(): string
{
$algorithm_name = $this->algorithm_name ?? null;
if (isset($algorithm_name)) {
return "/_plugins/_ml/_train_predict/$algorithm_name";
}
throw new RuntimeException('Missing parameter for the endpoint ml.train_predict');
}

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'POST';
}

public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
}
$this->body = $body;

return $this;
}

public function setAlgorithmName($algorithm_name): static
{
if (isset($algorithm_name) !== true) {
return $this;
}
$this->algorithm_name = $algorithm_name;

return $this;
}
}
Loading
Loading