Skip to content

Commit

Permalink
Add a proxy for closeCursor for backwards-compatibility.
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 7d46b11 commit fba7d20
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion util/ClientEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function renderClass(): string
$useNamespace = '';

// The following namespaces do not have OpenSearch API specifications
$patchnamespaces = ['async_search', 'searchable_snapshots', 'ssl', 'sql', 'data_frame_transform_deprecated', 'monitoring'];
$patchnamespaces = ['async_search', 'searchable_snapshots', 'ssl', 'data_frame_transform_deprecated', 'monitoring'];
$this->namespace = array_unique(array_merge($this->namespace, $patchnamespaces));
sort($this->namespace);

Expand Down
27 changes: 27 additions & 0 deletions util/EndpointProxies/sql/closeCursorProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

return <<<'EOD'
/**
* 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): array
{
$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 fba7d20

Please sign in to comment.