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-12)

Signed-off-by: GitHub <noreply@github.com>
  • Loading branch information
dblock committed Aug 12, 2024
1 parent 6511e9c commit 1f6f5b5
Show file tree
Hide file tree
Showing 35 changed files with 1,835 additions and 75 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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@cb320b5](https://github.com/opensearch-project/opensearch-api-specification/commit/cb320b5482551c4f28afa26ff0d1653332699722)
### Security
### Dependencies

Expand Down
2 changes: 0 additions & 2 deletions samples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@
$info = $client->info();

echo "{$info['version']['distribution']}: {$info['version']['number']}\n";

?>
42 changes: 42 additions & 0 deletions src/OpenSearch/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
use OpenSearch\Namespaces\MonitoringNamespace;
use OpenSearch\Namespaces\NodesNamespace;
use OpenSearch\Namespaces\NotificationsNamespace;
use OpenSearch\Namespaces\ObservabilityNamespace;
use OpenSearch\Namespaces\PplNamespace;
use OpenSearch\Namespaces\QueryNamespace;
use OpenSearch\Namespaces\RemoteStoreNamespace;
use OpenSearch\Namespaces\RollupsNamespace;
use OpenSearch\Namespaces\SearchPipelineNamespace;
Expand Down Expand Up @@ -138,6 +141,21 @@ class Client
*/
protected $notifications;

/**
* @var ObservabilityNamespace
*/
protected $observability;

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

/**
* @var QueryNamespace
*/
protected $query;

/**
* @var RemoteStoreNamespace
*/
Expand Down Expand Up @@ -212,6 +230,9 @@ 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->observability = new ObservabilityNamespace($transport, $endpoint);
$this->ppl = new PplNamespace($transport, $endpoint);
$this->query = new QueryNamespace($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 +1757,27 @@ public function notifications(): NotificationsNamespace
{
return $this->notifications;
}
/**
* Returns the observability namespace
*/
public function observability(): ObservabilityNamespace
{
return $this->observability;
}
/**
* Returns the ppl namespace
*/
public function ppl(): PplNamespace
{
return $this->ppl;
}
/**
* Returns the query namespace
*/
public function query(): QueryNamespace
{
return $this->query;
}
/**
* 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
15 changes: 15 additions & 0 deletions src/OpenSearch/Endpoints/Nodes/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@
*/
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";
}
Expand Down Expand Up @@ -65,6 +70,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
55 changes: 55 additions & 0 deletions src/OpenSearch/Endpoints/Observability/CreateObject.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\Observability;

use OpenSearch\Endpoints\AbstractEndpoint;

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

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

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

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

return $this;
}
}
62 changes: 62 additions & 0 deletions src/OpenSearch/Endpoints/Observability/DeleteObject.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\Observability;

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

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

public function getURI(): string
{
$object_id = $this->object_id ?? null;
if (isset($object_id)) {
return "/_plugins/_observability/object/$object_id";
}
throw new RuntimeException('Missing parameter for the endpoint observability.delete_object');
}

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

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

public function setObjectId($object_id): DeleteObject
{
if (isset($object_id) !== true) {
return $this;
}
$this->object_id = $object_id;

return $this;
}
}
47 changes: 47 additions & 0 deletions src/OpenSearch/Endpoints/Observability/DeleteObjects.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\Observability;

use OpenSearch\Endpoints\AbstractEndpoint;

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

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

public function getMethod(): string
{
return 'DELETE';
}
}
45 changes: 45 additions & 0 deletions src/OpenSearch/Endpoints/Observability/GetLocalstats.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\Observability;

use OpenSearch\Endpoints\AbstractEndpoint;

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

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

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

0 comments on commit 1f6f5b5

Please sign in to comment.