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
…4-08-09)

Signed-off-by: GitHub <[email protected]>
  • Loading branch information
dblock authored Aug 9, 2024
1 parent afee32d commit 60dcdba
Show file tree
Hide file tree
Showing 20 changed files with 804 additions and 87 deletions.
1 change: 1 addition & 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/)
### Removed
### Fixed
### Updated APIs
- Updated opensearch-php APIs to reflect [opensearch-api-specification@ecf3921](https://github.com/opensearch-project/opensearch-api-specification/commit/ecf39215e18d9edeba1d048b2ba22a172844ae6c)
### Security
### Dependencies

Expand Down
14 changes: 14 additions & 0 deletions src/OpenSearch/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use OpenSearch\Namespaces\MonitoringNamespace;
use OpenSearch\Namespaces\NodesNamespace;
use OpenSearch\Namespaces\NotificationsNamespace;
use OpenSearch\Namespaces\PplNamespace;
use OpenSearch\Namespaces\RemoteStoreNamespace;
use OpenSearch\Namespaces\RollupsNamespace;
use OpenSearch\Namespaces\SearchPipelineNamespace;
Expand Down Expand Up @@ -138,6 +139,11 @@ class Client
*/
protected $notifications;

/**
* @var PplNamespace
*/
protected $ppl;

/**
* @var RemoteStoreNamespace
*/
Expand Down Expand Up @@ -212,6 +218,7 @@ public function __construct(Transport $transport, callable $endpoint, array $reg
$this->monitoring = new MonitoringNamespace($transport, $endpoint);
$this->nodes = new NodesNamespace($transport, $endpoint);
$this->notifications = new NotificationsNamespace($transport, $endpoint);
$this->ppl = new PplNamespace($transport, $endpoint);
$this->remoteStore = new RemoteStoreNamespace($transport, $endpoint);
$this->rollups = new RollupsNamespace($transport, $endpoint);
$this->searchPipeline = new SearchPipelineNamespace($transport, $endpoint);
Expand Down Expand Up @@ -1736,6 +1743,13 @@ public function notifications(): NotificationsNamespace
{
return $this->notifications;
}
/**
* Returns the ppl namespace
*/
public function ppl(): PplNamespace
{
return $this->ppl;
}
/**
* Returns the remoteStore namespace
*/
Expand Down
1 change: 1 addition & 0 deletions src/OpenSearch/Endpoints/Indices/Exists.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function getParamWhitelist(): array
{
return [
'allow_no_indices',
'cluster_manager_timeout',
'expand_wildcards',
'flat_settings',
'ignore_unavailable',
Expand Down
22 changes: 10 additions & 12 deletions src/OpenSearch/Endpoints/Indices/PutAlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

namespace OpenSearch\Endpoints\Indices;

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

/**
Expand All @@ -33,19 +32,18 @@ class PutAlias extends AbstractEndpoint

public function getURI(): string
{
if (isset($this->index) !== true) {
throw new RuntimeException(
'index is required for put_alias'
);
$name = $this->name ?? null;
$index = $this->index ?? null;
if (isset($index) && isset($name)) {
return "/$index/_alias/$name";
}
$index = $this->index;
if (isset($this->name) !== true) {
throw new RuntimeException(
'name is required for put_alias'
);
if (isset($index)) {
return "/$index/_alias";
}
$name = $this->name;
return "/$index/_alias/$name";
if (isset($name)) {
return "/_alias/$name";
}
return "/_alias";
}

public function getParamWhitelist(): array
Expand Down
21 changes: 15 additions & 6 deletions src/OpenSearch/Endpoints/Nodes/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,21 @@
*/
class Info extends AbstractEndpoint
{
protected $node_id_or_metric;
protected $metric;
protected $node_id;

public function getURI(): string
{
$node_id_or_metric = $this->node_id_or_metric ?? null;
$metric = $this->metric ?? null;
$node_id = $this->node_id ?? null;
if (isset($node_id_or_metric)) {
return "/_nodes/$node_id_or_metric";
}
if (isset($node_id) && isset($metric)) {
return "/_nodes/$node_id/$metric";
}
if (isset($node_id)) {
return "/_nodes/$node_id";
}
if (isset($metric)) {
return "/_nodes/$metric";
}
return "/_nodes";
}

Expand All @@ -65,6 +64,16 @@ public function getMethod(): string
return 'GET';
}

public function setNodeIdOrMetric($node_id_or_metric): Info
{
if (isset($node_id_or_metric) !== true) {
return $this;
}
$this->node_id_or_metric = $node_id_or_metric;

return $this;
}

public function setMetric($metric): Info
{
if (isset($metric) !== true) {
Expand Down
57 changes: 57 additions & 0 deletions src/OpenSearch/Endpoints/Ppl/Explain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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\Ppl;

use OpenSearch\Endpoints\AbstractEndpoint;

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

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

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

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

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

use OpenSearch\Endpoints\AbstractEndpoint;

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

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

public function getMethod(): string
{
return 'GET';
}
}
57 changes: 57 additions & 0 deletions src/OpenSearch/Endpoints/Ppl/PostStats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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\Ppl;

use OpenSearch\Endpoints\AbstractEndpoint;

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

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

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

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

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

use OpenSearch\Endpoints\AbstractEndpoint;

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

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

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

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

return $this;
}
}
Loading

0 comments on commit 60dcdba

Please sign in to comment.