Skip to content

Commit

Permalink
Generate API
Browse files Browse the repository at this point in the history
  • Loading branch information
kimpepper committed Feb 10, 2025
1 parent f29cea3 commit 3b92dc5
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Security
### Dependencies
### Updated APIs
- Updated opensearch-php APIs to reflect [opensearch-api-specification@22483a2](https://github.com/opensearch-project/opensearch-api-specification/commit/22483a2bdfe1022611b1de7db5f45af9289a8654)

## [2.4.1]
### Added
Expand Down Expand Up @@ -47,6 +48,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed PHP 8.4 deprecations ([#229](https://github.com/opensearch-project/opensearch-php/pull/229))
- Fixed outdated tests ([#245](https://github.com/opensearch-project/opensearch-php/pull/245))
### Updated APIs
- Updated opensearch-php APIs to reflect [opensearch-api-specification@22483a2](https://github.com/opensearch-project/opensearch-api-specification/commit/22483a2bdfe1022611b1de7db5f45af9289a8654)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@b9dcb25](https://github.com/opensearch-project/opensearch-api-specification/commit/b9dcb251d551e90ecfc416ba134efe83cbcbc1b3)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@9df46f8](https://github.com/opensearch-project/opensearch-api-specification/commit/9df46f8134641ae5b429e3e9269858c7cb27e4f0)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@592336a](https://github.com/opensearch-project/opensearch-api-specification/commit/592336afb88844f0c5785ba4b085dba3884ac580)
Expand Down
27 changes: 26 additions & 1 deletion src/OpenSearch/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class Client

/**
* @var AsyncSearchNamespace
*
* @deprecated in 2.4.1 and will be removed in 3.0.0.
*/
protected $asyncSearch;

Expand All @@ -165,6 +167,8 @@ class Client

/**
* @var DataFrameTransformDeprecatedNamespace
*
* @deprecated in 2.4.1 and will be removed in 3.0.0.
*/
protected $dataFrameTransformDeprecated;

Expand Down Expand Up @@ -210,6 +214,8 @@ class Client

/**
* @var MonitoringNamespace
*
* @deprecated in 2.4.1 and will be removed in 3.0.0.
*/
protected $monitoring;

Expand Down Expand Up @@ -260,6 +266,8 @@ class Client

/**
* @var SearchableSnapshotsNamespace
*
* @deprecated in 2.4.1 and will be removed in 3.0.0.
*/
protected $searchableSnapshots;

Expand All @@ -285,6 +293,8 @@ class Client

/**
* @var SslNamespace
*
* @deprecated in 2.4.1 and will be removed in 3.0.0.
*/
protected $ssl;

Expand Down Expand Up @@ -340,11 +350,13 @@ public function __construct(
// @phpstan-ignore property.deprecated
$this->endpoints = $endpoints;
$this->endpointFactory = $endpointFactory;
// @phpstan-ignore new.deprecated, property.deprecated
$this->asyncSearch = new AsyncSearchNamespace($transport, $this->endpointFactory);
$this->asynchronousSearch = new AsynchronousSearchNamespace($transport, $this->endpointFactory);
$this->cat = new CatNamespace($transport, $this->endpointFactory);
$this->cluster = new ClusterNamespace($transport, $this->endpointFactory);
$this->danglingIndices = new DanglingIndicesNamespace($transport, $this->endpointFactory);
// @phpstan-ignore new.deprecated, property.deprecated
$this->dataFrameTransformDeprecated = new DataFrameTransformDeprecatedNamespace($transport, $this->endpointFactory);
$this->flowFramework = new FlowFrameworkNamespace($transport, $this->endpointFactory);
$this->indices = new IndicesNamespace($transport, $this->endpointFactory);
Expand All @@ -354,6 +366,7 @@ public function __construct(
$this->knn = new KnnNamespace($transport, $this->endpointFactory);
$this->list = new ListNamespace($transport, $this->endpointFactory);
$this->ml = new MlNamespace($transport, $this->endpointFactory);
// @phpstan-ignore new.deprecated, property.deprecated
$this->monitoring = new MonitoringNamespace($transport, $this->endpointFactory);
$this->nodes = new NodesNamespace($transport, $this->endpointFactory);
$this->notifications = new NotificationsNamespace($transport, $this->endpointFactory);
Expand All @@ -364,11 +377,13 @@ public function __construct(
$this->replication = new ReplicationNamespace($transport, $this->endpointFactory);
$this->rollups = new RollupsNamespace($transport, $this->endpointFactory);
$this->searchPipeline = new SearchPipelineNamespace($transport, $this->endpointFactory);
// @phpstan-ignore new.deprecated, property.deprecated
$this->searchableSnapshots = new SearchableSnapshotsNamespace($transport, $this->endpointFactory);
$this->security = new SecurityNamespace($transport, $this->endpointFactory);
$this->sm = new SmNamespace($transport, $this->endpointFactory);
$this->snapshot = new SnapshotNamespace($transport, $this->endpointFactory);
$this->sql = new SqlNamespace($transport, $this->endpointFactory);
// @phpstan-ignore new.deprecated, property.deprecated
$this->ssl = new SslNamespace($transport, $this->endpointFactory);
$this->tasks = new TasksNamespace($transport, $this->endpointFactory);
$this->transforms = new TransformsNamespace($transport, $this->endpointFactory);
Expand Down Expand Up @@ -666,7 +681,7 @@ public function deleteByQuery(array $params = [])
/**
* Changes the number of requests per second for a particular Delete By Query operation.
*
* $params['task_id'] = (number) The ID for the task. (Required)
* $params['task_id'] = (string) The ID for the task. (Required)
* $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second.
* $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)
Expand Down Expand Up @@ -1844,6 +1859,8 @@ public function deletePointInTime(array $params = [])
}
/**
* Returns the asyncSearch namespace
*
* @deprecated in 2.4.2 and will be removed in 3.0.0.
*/
public function asyncSearch(): AsyncSearchNamespace
{
Expand Down Expand Up @@ -1879,6 +1896,8 @@ public function danglingIndices(): DanglingIndicesNamespace
}
/**
* Returns the dataFrameTransformDeprecated namespace
*
* @deprecated in 2.4.2 and will be removed in 3.0.0.
*/
public function dataFrameTransformDeprecated(): DataFrameTransformDeprecatedNamespace
{
Expand Down Expand Up @@ -1942,6 +1961,8 @@ public function ml(): MlNamespace
}
/**
* Returns the monitoring namespace
*
* @deprecated in 2.4.2 and will be removed in 3.0.0.
*/
public function monitoring(): MonitoringNamespace
{
Expand Down Expand Up @@ -2012,6 +2033,8 @@ public function searchPipeline(): SearchPipelineNamespace
}
/**
* Returns the searchableSnapshots namespace
*
* @deprecated in 2.4.2 and will be removed in 3.0.0.
*/
public function searchableSnapshots(): SearchableSnapshotsNamespace
{
Expand Down Expand Up @@ -2047,6 +2070,8 @@ public function sql(): SqlNamespace
}
/**
* Returns the ssl namespace
*
* @deprecated in 2.4.2 and will be removed in 3.0.0.
*/
public function ssl(): SslNamespace
{
Expand Down
72 changes: 72 additions & 0 deletions src/OpenSearch/Endpoints/Ml/ExecuteAlgorithm.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\Exception\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

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

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

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

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

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

return $this;
}

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

return $this;
}
}
27 changes: 27 additions & 0 deletions src/OpenSearch/Namespaces/MlNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OpenSearch\Endpoints\Ml\DeleteTask;
use OpenSearch\Endpoints\Ml\DeployModel;
use OpenSearch\Endpoints\Ml\ExecuteAgent;
use OpenSearch\Endpoints\Ml\ExecuteAlgorithm;
use OpenSearch\Endpoints\Ml\GetAgent;
use OpenSearch\Endpoints\Ml\GetAllMemories;
use OpenSearch\Endpoints\Ml\GetAllMessages;
Expand Down Expand Up @@ -380,6 +381,32 @@ public function executeAgent(array $params = [])
return $this->performRequest($endpoint);
}

/**
* Execute an algorithm.
*
* $params['algorithm_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 executeAlgorithm(array $params = [])
{
$algorithm_name = $this->extractArgument($params, 'algorithm_name');
$body = $this->extractArgument($params, 'body');

$endpoint = $this->endpointFactory->getEndpoint(ExecuteAlgorithm::class);
$endpoint->setParams($params);
$endpoint->setAlgorithmName($algorithm_name);
$endpoint->setBody($body);

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

/**
* Get an agent.
*
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Namespaces/TasksNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TasksNamespace extends AbstractNamespace
/**
* Cancels a task, if it can be cancelled through an API.
*
* $params['task_id'] = (number) ID of the task.
* $params['task_id'] = (string) ID of the task.
* $params['actions'] = (any) Comma-separated list or wildcard expression of actions used to limit the request.
* $params['nodes'] = (array) Comma-separated list of node IDs or names used to limit the request.
* $params['parent_task_id'] = (string) Parent task ID used to limit the tasks.
Expand Down

0 comments on commit 3b92dc5

Please sign in to comment.