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

Signed-off-by: GitHub <[email protected]>
  • Loading branch information
dblock authored Aug 2, 2024
1 parent afee32d commit 01edf32
Show file tree
Hide file tree
Showing 12 changed files with 368 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@b67104c](https://github.com/opensearch-project/opensearch-api-specification/commit/b67104c30e515702df88bba9c173d04033d07a45)
### Security
### Dependencies

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/Sql/Close.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\Sql;

use OpenSearch\Endpoints\AbstractEndpoint;

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

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

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

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

return $this;
}
}
31 changes: 27 additions & 4 deletions src/OpenSearch/Endpoints/Sql/Explain.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
Expand All @@ -15,20 +17,41 @@

use OpenSearch\Endpoints\AbstractEndpoint;

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

public function getURI(): string
public function getParamWhitelist(): array
{
return '/_plugins/_sql/_explain';
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/Sql/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\Sql;

use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class GetStats extends AbstractEndpoint
{
public function getURI(): string
{
return "/_plugins/_sql/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/Sql/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\Sql;

use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class PostStats extends AbstractEndpoint
{
public function getURI(): string
{
return "/_plugins/_sql/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;
}
}
31 changes: 27 additions & 4 deletions src/OpenSearch/Endpoints/Sql/Query.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
Expand All @@ -15,20 +17,41 @@

use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Query extends AbstractEndpoint
{
public function getParamWhitelist(): array
public function getURI(): string
{
return ['format'];
return "/_plugins/_sql";
}

public function getURI(): string
public function getParamWhitelist(): array
{
return '/_plugins/_sql';
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 01edf32

Please sign in to comment.