Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated opensearch-php to reflect the latest OpenSearch API spec #238

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
- Fixed PHP 8.4 deprecations
### Updated APIs
- Updated opensearch-php APIs to reflect [opensearch-api-specification@6bb1fed](https://github.com/opensearch-project/opensearch-api-specification/commit/6bb1fed0a2c7cf094a5ecfdb01f0306a4b9f8eba)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@07e329e](https://github.com/opensearch-project/opensearch-api-specification/commit/07e329e8d01fd0576de6a0a3c35412fd5a9163db)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@1db1840](https://github.com/opensearch-project/opensearch-api-specification/commit/1db184063a463c5180a2cc824b1efc1aeebfd5eb)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@cb320b5](https://github.com/opensearch-project/opensearch-api-specification/commit/cb320b5482551c4f28afa26ff0d1653332699722)
Expand Down
266 changes: 140 additions & 126 deletions src/OpenSearch/Client.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/AsynchronousSearch/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getMethod(): string
return 'POST';
}

public function setBody($body): Search
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand Down
3 changes: 2 additions & 1 deletion src/OpenSearch/Endpoints/Bulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getMethod(): string
return 'POST';
}

public function setBody($body): Bulk
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand All @@ -89,4 +89,5 @@ public function setBody($body): Bulk
}
return $this;
}

}
3 changes: 2 additions & 1 deletion src/OpenSearch/Endpoints/BulkStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getMethod(): string
return 'PUT';
}

public function setBody($body): BulkStream
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand All @@ -85,4 +85,5 @@ public function setBody($body): BulkStream
}
return $this;
}

}
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cat/Aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getMethod(): string
return 'GET';
}

public function setName($name): Aliases
public function setName($name): static
{
if (isset($name) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cat/Allocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getMethod(): string
return 'GET';
}

public function setNodeId($node_id): Allocation
public function setNodeId($node_id): static
{
if (isset($node_id) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cat/Fielddata.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getMethod(): string
return 'GET';
}

public function setFields($fields): Fielddata
public function setFields($fields): static
{
if (isset($fields) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cat/PitSegments.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getMethod(): string
return 'GET';
}

public function setBody($body): PitSegments
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cat/Snapshots.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getMethod(): string
return 'GET';
}

public function setRepository($repository): Snapshots
public function setRepository($repository): static
{
if (isset($repository) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cat/Templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getMethod(): string
return 'GET';
}

public function setName($name): Templates
public function setName($name): static
{
if (isset($name) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cat/ThreadPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getMethod(): string
return 'GET';
}

public function setThreadPoolPatterns($thread_pool_patterns): ThreadPool
public function setThreadPoolPatterns($thread_pool_patterns): static
{
if (isset($thread_pool_patterns) !== true) {
return $this;
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSearch/Endpoints/ClearScroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getMethod(): string
return 'DELETE';
}

public function setBody($body): ClearScroll
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand All @@ -69,7 +69,7 @@ public function setBody($body): ClearScroll
return $this;
}

public function setScrollId($scroll_id): ClearScroll
public function setScrollId($scroll_id): static
{
if (isset($scroll_id) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cluster/AllocationExplain.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getMethod(): string
return isset($this->body) ? 'POST' : 'GET';
}

public function setBody($body): AllocationExplain
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getMethod(): string
return 'DELETE';
}

public function setName($name): DeleteComponentTemplate
public function setName($name): static
{
if (isset($name) !== true) {
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getMethod(): string
return 'DELETE';
}

public function setBody($body): DeleteWeightedRouting
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getMethod(): string
return 'HEAD';
}

public function setName($name): ExistsComponentTemplate
public function setName($name): static
{
if (isset($name) !== true) {
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function getMethod(): string
return 'GET';
}

public function setName($name): GetComponentTemplate
public function setName($name): static
{
if (isset($name) !== true) {
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getMethod(): string
return 'GET';
}

public function setAwarenessAttributeName($awareness_attribute_name): GetDecommissionAwareness
public function setAwarenessAttributeName($awareness_attribute_name): static
{
if (isset($awareness_attribute_name) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cluster/GetWeightedRouting.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getMethod(): string
return 'GET';
}

public function setAttribute($attribute): GetWeightedRouting
public function setAttribute($attribute): static
{
if (isset($attribute) !== true) {
return $this;
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSearch/Endpoints/Cluster/PutComponentTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getMethod(): string
return 'PUT';
}

public function setBody($body): PutComponentTemplate
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand All @@ -70,7 +70,7 @@ public function setBody($body): PutComponentTemplate
return $this;
}

public function setName($name): PutComponentTemplate
public function setName($name): static
{
if (isset($name) !== true) {
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getMethod(): string
return 'PUT';
}

public function setAwarenessAttributeName($awareness_attribute_name): PutDecommissionAwareness
public function setAwarenessAttributeName($awareness_attribute_name): static
{
if (isset($awareness_attribute_name) !== true) {
return $this;
Expand All @@ -62,7 +62,7 @@ public function setAwarenessAttributeName($awareness_attribute_name): PutDecommi
return $this;
}

public function setAwarenessAttributeValue($awareness_attribute_value): PutDecommissionAwareness
public function setAwarenessAttributeValue($awareness_attribute_value): static
{
if (isset($awareness_attribute_value) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cluster/PutSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getMethod(): string
return 'PUT';
}

public function setBody($body): PutSettings
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSearch/Endpoints/Cluster/PutWeightedRouting.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getMethod(): string
return 'PUT';
}

public function setBody($body): PutWeightedRouting
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand All @@ -60,7 +60,7 @@ public function setBody($body): PutWeightedRouting
return $this;
}

public function setAttribute($attribute): PutWeightedRouting
public function setAttribute($attribute): static
{
if (isset($attribute) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cluster/Reroute.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getMethod(): string
return 'POST';
}

public function setBody($body): Reroute
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Cluster/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getMethod(): string
return 'GET';
}

public function setMetric($metric): State
public function setMetric($metric): static
{
if (isset($metric) !== true) {
return $this;
Expand Down
38 changes: 37 additions & 1 deletion src/OpenSearch/Endpoints/Cluster/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@
*/
class Stats extends AbstractEndpoint
{
protected $index_metric;
protected $metric;
protected $node_id;

public function getURI(): string
{
$index_metric = $this->index_metric ?? null;
$metric = $this->metric ?? null;
$node_id = $this->node_id ?? null;
if (isset($metric) && isset($index_metric) && isset($node_id)) {
return "/_cluster/stats/$metric/$index_metric/nodes/$node_id";
}
if (isset($metric) && isset($node_id)) {
return "/_cluster/stats/$metric/nodes/$node_id";
}
if (isset($node_id)) {
return "/_cluster/stats/nodes/$node_id";
}
Expand All @@ -57,7 +67,33 @@ public function getMethod(): string
return 'GET';
}

public function setNodeId($node_id): Stats
public function setIndexMetric($index_metric): static
{
if (isset($index_metric) !== true) {
return $this;
}
if (is_array($index_metric) === true) {
$index_metric = implode(",", $index_metric);
}
$this->index_metric = $index_metric;

return $this;
}

public function setMetric($metric): static
{
if (isset($metric) !== true) {
return $this;
}
if (is_array($metric) === true) {
$metric = implode(",", $metric);
}
$this->metric = $metric;

return $this;
}

public function setNodeId($node_id): static
{
if (isset($node_id) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getMethod(): string
return isset($this->body) ? 'POST' : 'GET';
}

public function setBody($body): Count
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getMethod(): string
return 'PUT';
}

public function setBody($body): Create
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getMethod(): string
return 'DELETE';
}

public function setIndexUuid($index_uuid): DeleteDanglingIndex
public function setIndexUuid($index_uuid): static
{
if (isset($index_uuid) !== true) {
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getMethod(): string
return 'POST';
}

public function setIndexUuid($index_uuid): ImportDanglingIndex
public function setIndexUuid($index_uuid): static
{
if (isset($index_uuid) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/DeleteByQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getMethod(): string
return 'POST';
}

public function setBody($body): DeleteByQuery
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/DeleteByQueryRethrottle.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getMethod(): string
return 'POST';
}

public function setTaskId($task_id): DeleteByQueryRethrottle
public function setTaskId($task_id): static
{
if (isset($task_id) !== true) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch/Endpoints/DeletePit.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getMethod(): string
return 'DELETE';
}

public function setBody($body): DeletePit
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
Expand Down
Loading
Loading