Skip to content

Commit

Permalink
Transform query param into a body param.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Aug 12, 2024
1 parent 05472bf commit f33b51b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 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@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
Expand Down
22 changes: 18 additions & 4 deletions src/OpenSearch/Namespaces/SqlNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Check failure on line 187 in src/OpenSearch/Namespaces/SqlNamespace.php

View workflow job for this annotation

GitHub Actions / PHPStan

PHPDoc tag @var for variable $endpoint contains unknown class OpenSearch\Namespaces\AbstractEndpoint.

Check failure on line 187 in src/OpenSearch/Namespaces/SqlNamespace.php

View workflow job for this annotation

GitHub Actions / PHPStan

PHPDoc tag @var for variable $endpoint contains unknown class OpenSearch\Namespaces\AbstractEndpoint.
$endpoint->setBody(array_filter([

Check failure on line 188 in src/OpenSearch/Namespaces/SqlNamespace.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to method setBody() on an unknown class OpenSearch\Namespaces\AbstractEndpoint.

Check failure on line 188 in src/OpenSearch/Namespaces/SqlNamespace.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to method setBody() on an unknown class OpenSearch\Namespaces\AbstractEndpoint.
'cursor' => $this->extractArgument($params, 'cursor'),
]));
$endpoint->setParams($params);

Check failure on line 191 in src/OpenSearch/Namespaces/SqlNamespace.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to method setParams() on an unknown class OpenSearch\Namespaces\AbstractEndpoint.

Check failure on line 191 in src/OpenSearch/Namespaces/SqlNamespace.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to method setParams() on an unknown class OpenSearch\Namespaces\AbstractEndpoint.

return $this->performRequest($endpoint);

Check failure on line 193 in src/OpenSearch/Namespaces/SqlNamespace.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #1 $endpoint of method OpenSearch\Namespaces\AbstractNamespace::performRequest() expects OpenSearch\Endpoints\AbstractEndpoint, OpenSearch\Namespaces\AbstractEndpoint given.

Check failure on line 193 in src/OpenSearch/Namespaces/SqlNamespace.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #1 $endpoint of method OpenSearch\Namespaces\AbstractNamespace::performRequest() expects OpenSearch\Endpoints\AbstractEndpoint, OpenSearch\Namespaces\AbstractEndpoint given.
}
}
22 changes: 18 additions & 4 deletions util/EndpointProxies/sql/closeCursorProxy.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
<?php

return <<<'EOD'
/**
* Proxy function to closeCursor() to prevent BC break.
* 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);
}
EOD;

0 comments on commit f33b51b

Please sign in to comment.