Skip to content

Commit

Permalink
Updated opensearch-php to reflect the latest OpenSearch API spec (202…
Browse files Browse the repository at this point in the history
…5-01-17)

Signed-off-by: GitHub <[email protected]>
  • Loading branch information
dblock authored Jan 17, 2025
1 parent 274adf2 commit 582dfcc
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed PHP 8.4 deprecations
- Fixed outdated tests
### Updated APIs
- Updated opensearch-php APIs to reflect [opensearch-api-specification@c571230](https://github.com/opensearch-project/opensearch-api-specification/commit/c571230ff84f0c930440e9ef1f4b376c0425f5c6)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@1422af3](https://github.com/opensearch-project/opensearch-api-specification/commit/1422af3cddc8140fe9c3d59ee0205b278e193bb9)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@2395cb4](https://github.com/opensearch-project/opensearch-api-specification/commit/2395cb472ec5581656aac184f7b20548cd5b06ac)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@ebe0f8a](https://github.com/opensearch-project/opensearch-api-specification/commit/ebe0f8a885f7db7e882d160c101055a5aa70a707)
Expand Down
45 changes: 45 additions & 0 deletions src/OpenSearch/Endpoints/Ml/GetAllTools.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class GetAllTools extends AbstractEndpoint
{
public function getURI(): string
{
return "/_plugins/_ml/tools";
}

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

public function getMethod(): string
{
return 'GET';
}
}
62 changes: 62 additions & 0 deletions src/OpenSearch/Endpoints/Ml/GetTool.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?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 GetTool extends AbstractEndpoint
{
protected $tool_name;

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

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

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

public function setToolName($tool_name): static
{
if (is_null($tool_name)) {
return $this;
}
$this->tool_name = $tool_name;

return $this;
}
}
55 changes: 55 additions & 0 deletions src/OpenSearch/Endpoints/Ml/SearchTasks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class SearchTasks extends AbstractEndpoint
{
public function getURI(): string
{
return "/_plugins/_ml/tasks/_search";
}

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

public function getMethod(): string
{
return isset($this->body) ? 'POST' : 'GET';
}

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

return $this;
}
}
67 changes: 67 additions & 0 deletions src/OpenSearch/Namespaces/MlNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,26 @@ public function getAllMessages(array $params = [])
return $this->performRequest($endpoint);
}

/**
* Get tools.
*
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
* $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 "-".
*
* @param array $params Associative array of parameters
* @return array
*/
public function getAllTools(array $params = [])
{
$endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetAllTools::class);
$endpoint->setParams($params);

return $this->performRequest($endpoint);
}

/**
* Retrieves a controller.
*
Expand Down Expand Up @@ -589,6 +609,30 @@ public function getTask(array $params = [])
return $this->performRequest($endpoint);
}

/**
* Get tools.
*
* $params['tool_name'] = (string)
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
* $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 "-".
*
* @param array $params Associative array of parameters
* @return array
*/
public function getTool(array $params = [])
{
$tool_name = $this->extractArgument($params, 'tool_name');

$endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetTool::class);
$endpoint->setParams($params);
$endpoint->setToolName($tool_name);

return $this->performRequest($endpoint);
}

/**
* Deploys a model.
*
Expand Down Expand Up @@ -849,6 +893,29 @@ public function searchModels(array $params = [])
return $this->performRequest($endpoint);
}

/**
* Searches for tasks.
*
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
* $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 "-".
*
* @param array $params Associative array of parameters
* @return array
*/
public function searchTasks(array $params = [])
{
$body = $this->extractArgument($params, 'body');

$endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\SearchTasks::class);
$endpoint->setParams($params);
$endpoint->setBody($body);

return $this->performRequest($endpoint);
}

/**
* Trains a model synchronously.
*
Expand Down

0 comments on commit 582dfcc

Please sign in to comment.