From f33b51b5d03413bdc1c8cfb134cec234f36fe920 Mon Sep 17 00:00:00 2001 From: dblock Date: Mon, 12 Aug 2024 09:13:20 -0400 Subject: [PATCH] Transform query param into a body param. Signed-off-by: dblock --- CHANGELOG.md | 1 + src/OpenSearch/Namespaces/SqlNamespace.php | 22 +++++++++++++++---- util/EndpointProxies/sql/closeCursorProxy.php | 22 +++++++++++++++---- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91135eb4..b3bf6527 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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@597ed8d](https://github.com/opensearch-project/opensearch-api-specification/commit/597ed8d73c0b72743ed90fd9694ad9ba511d5be7) - Updated opensearch-php APIs to reflect [opensearch-api-specification@ecf3921](https://github.com/opensearch-project/opensearch-api-specification/commit/ecf39215e18d9edeba1d048b2ba22a172844ae6c) ### Security ### Dependencies diff --git a/src/OpenSearch/Namespaces/SqlNamespace.php b/src/OpenSearch/Namespaces/SqlNamespace.php index 8265001a..72a00412 100644 --- a/src/OpenSearch/Namespaces/SqlNamespace.php +++ b/src/OpenSearch/Namespaces/SqlNamespace.php @@ -169,13 +169,27 @@ public function settings(array $params = []) $endpoint->setBody($body); return $this->performRequest($endpoint); - } - /** + } /** * Proxy function to closeCursor() to prevent BC break. * This API will be removed in a future version. Use 'close' API instead. + * Note that the SQL close API takes the cursor in the body. + * + * $params['cursor'] = (string) The cursor given by the server + * + * @param array{'cursor': string} $params Associative array of parameters + * @return array */ - public function closeCursor(array $params = []) + public function closeCursor(array $params): array { - return $this->close($params); + $endpointBuilder = $this->endpoints; + + /** @var AbstractEndpoint $endpoint */ + $endpoint = $endpointBuilder('Sql\Close'); + $endpoint->setBody(array_filter([ + 'cursor' => $this->extractArgument($params, 'cursor'), + ])); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); } } diff --git a/util/EndpointProxies/sql/closeCursorProxy.php b/util/EndpointProxies/sql/closeCursorProxy.php index c0e7f0b1..fa770c5c 100644 --- a/util/EndpointProxies/sql/closeCursorProxy.php +++ b/util/EndpointProxies/sql/closeCursorProxy.php @@ -1,13 +1,27 @@ close($params); + $endpointBuilder = $this->endpoints; + + /** @var AbstractEndpoint $endpoint */ + $endpoint = $endpointBuilder('Sql\Close'); + $endpoint->setBody(array_filter([ + 'cursor' => $this->extractArgument($params, 'cursor'), + ])); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); } EOD;