Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
71f53fc
feat(Gax)!: refactor OperationResponse with OperationsClientInterface…
bshaffer Sep 30, 2026
938d16c
Merge branch 'gax-v2-client-options' into gax-v2-operation-response
bshaffer Oct 1, 2026
604f5ae
fix(Gax,Spanner): fix php-cs-fixer imports, DocFX @see FQCNs, and Spa…
bshaffer Oct 1, 2026
fd2dfb9
Merge branch 'gax-v2-client-options' into gax-v2-operation-response
bshaffer Oct 1, 2026
953f704
test(Gax): add unit tests for OperationsClientInterface and CustomOpe…
bshaffer Oct 1, 2026
eb46522
Merge branch 'gax-v2-client-options' into gax-v2-operation-response
bshaffer Oct 1, 2026
6581d26
test(Spanner): stub OperationResponse::getLastProtoResponse in snippe…
bshaffer Oct 1, 2026
6794439
Merge branch 'gax-v2-client-options' into gax-v2-operation-response
bshaffer Oct 5, 2026
c2db3e5
chore(Gax): add TODO for removing OperationsClient check
bshaffer Nov 6, 2026
387853c
fix(Gax): preserve custom operation message in getLastProtoResponse
bshaffer Nov 6, 2026
57286ba
refactor(Gax): simplify lastProtoResponse in CustomOperationsClient
bshaffer Nov 6, 2026
7c6551e
revert: remove CustomOperationsClient to preserve GAPIC LRO BC
bshaffer Nov 6, 2026
3ca49f4
feat(Gax): add OperationsClientWrapperInterface and restore CustomOpe…
bshaffer Nov 6, 2026
94be853
refactor(Gax): simplify OperationsClientWrapperInterface to getOperat…
bshaffer Nov 6, 2026
ccb8e66
Merge branch 'gax-v2-client-options' into gax-v2-operation-response
bshaffer Nov 12, 2026
53ded20
test(Gax): return Operation from getOperation mock in testAdditionalA…
bshaffer Nov 12, 2026
b2be3c5
Merge branch 'gax-v2-client-options' into gax-v2-operation-response
bshaffer Nov 13, 2026
1e99d6b
Merge branch 'gax-v2-client-options' into gax-v2-operation-response
bshaffer Nov 13, 2026
3d207f6
chore(Gax): typehint getLastProtoResponse(): ?Message and getOperatio…
bshaffer Nov 13, 2026
43921f6
Merge branch 'gax-v2-client-options' into gax-v2-operation-response
bshaffer Nov 16, 2026
ae122b2
Merge branch 'gax-v2-client-options' into gax-v2-operation-response
bshaffer Nov 18, 2026
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
56 changes: 36 additions & 20 deletions Core/tests/Unit/LongRunning/OperationResponseTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
namespace Google\Cloud\Core\Tests\Unit\LongRunning;

use Google\ApiCore\OperationResponse;
use Google\ApiCore\OperationsClientInterface;
use Google\ApiCore\Serializer;
use Google\Cloud\Core\LongRunning\OperationResponseTrait;
use Google\Cloud\Core\LongRunning\LongRunningOperation;
use Google\Cloud\Core\LongRunning\LongRunningConnectionInterface;
use Google\LongRunning\Operation;
use Google\Protobuf\Any;
use Google\Rpc\Status;
use Prophecy\Argument;
use Google\Cloud\Audit\RequestMetadata;
use Google\Cloud\Audit\AuthorizationInfo;
Expand All @@ -43,6 +47,7 @@ class OperationResponseTraitTest extends TestCase
const OPERATION_NAME = 'test-operation';

private $serializer;
private $operationsClient;
private $lroResponseMappers = [
[
'typeUrl' => self::METADATA_TYPE,
Expand All @@ -61,6 +66,7 @@ public function setUp(): void
return json_decode($json, true);
});
$this->serializer = $serializer->reveal();
$this->operationsClient = $this->prophesize(OperationsClientInterface::class)->reveal();
}

public function testOperationWithResponse()
Expand All @@ -74,7 +80,11 @@ public function testOperationWithResponse()
'caller_ip' => '127.8.9.10', // Sic(!)
]);
$response = new Response(self::METADATA_TYPE, $meta, self::RESULT_TYPE, $result);
$operation = new OperationResponse(self::OPERATION_NAME, null, ['lastProtoResponse' => $response]);
$operation = new OperationResponse(
self::OPERATION_NAME,
$this->operationsClient,
['lastProtoResponse' => $response]
);
$got = $this->operationToArray($operation, $this->serializer, $this->lroResponseMappers);

$expected = [
Expand All @@ -95,17 +105,20 @@ public function testOperationWithResponse()

public function testOperationWithError()
{
$error = new AuthorizationInfo([
'resource' => 'any',
'permission' => 'all',
'granted' => true,
$error = new Status([
'code' => 1,
'message' => 'error',
]);
$meta = new RequestMetadata([
'caller_ip' => '127.8.9.10', // Sic(!)
]);
$response = new Response(self::METADATA_TYPE, $meta);
$response->error = $error;
$operation = new OperationResponse(self::OPERATION_NAME, null, ['lastProtoResponse' => $response]);
$operation = new OperationResponse(
self::OPERATION_NAME,
$this->operationsClient,
['lastProtoResponse' => $response]
);
$got = $this->operationToArray($operation, $this->serializer, $this->lroResponseMappers);

$expected = [
Expand All @@ -115,9 +128,8 @@ public function testOperationWithError()
'typeUrl' => self::METADATA_TYPE,
],
'error' => [
'resource' => 'any',
'permission' => 'all',
'granted' => true,
'code' => 1,
'message' => 'error',
],
'response' => null,
];
Expand All @@ -126,7 +138,7 @@ public function testOperationWithError()

public function testNullProtoResponse()
{
$operation = new OperationResponse(self::OPERATION_NAME, null);
$operation = new OperationResponse(self::OPERATION_NAME, $this->operationsClient);
$got = $this->operationToArray($operation, $this->serializer, $this->lroResponseMappers);
$this->assertNull($got);
}
Expand All @@ -142,7 +154,11 @@ public function testLroCallable()
'caller_ip' => '127.8.9.10',
]);
$response = new Response(self::METADATA_TYPE, $meta, self::RESULT_TYPE, $result);
$operation = new OperationResponse(self::OPERATION_NAME, null, ['lastProtoResponse' => $response]);
$operation = new OperationResponse(
self::OPERATION_NAME,
$this->operationsClient,
['lastProtoResponse' => $response]
);

$connection = $this->prophesize(LongRunningConnectionInterface::class);
$t = $this;
Expand All @@ -166,7 +182,7 @@ public function testLroCallable()

//@codingStandardsIgnoreStart

class Value
class Value extends Any
{
public $value;

Expand All @@ -175,13 +191,13 @@ public function __construct($value = null)
$this->value = $value;
}

public function getValue()
public function getValue(): string
{
return $this->value;
return (string) $this->value;
}
}

class Response extends \Google\Protobuf\Internal\Message
class Response extends Operation
{
public $metadataType;
public $metadata;
Expand All @@ -199,27 +215,27 @@ public function __construct($metaType, $metadata, $respType = null, $response =
}
}

public function getResponse()
public function getResponse(): ?Any
{
return new Value($this->response);
}

public function getMetadata()
public function getMetadata(): ?Any
{
return new Value($this->metadata);
}

public function getDone()
public function getDone(): bool
{
return (isset($this->response) or isset($this->error));
}

public function getError()
public function getError(): ?Status
{
return $this->error;
}

public function serializeToJsonString($options = 0)
public function serializeToJsonString($options = 0): string
{
$result = [
'done' => true,
Expand Down
8 changes: 8 additions & 0 deletions Gax/MIGRATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@ Update your `google/gax` dependency to `^2.0`:
- Added `declare(strict_types=1)` across all `Google\ApiCore` files.
- Added native parameter, property, and return type declarations across all `Google\ApiCore` classes, interfaces (`TransportInterface`, `MiddlewareInterface`, `ResourceTemplateInterface`, `ServerStreamingCallInterface`, `ResumableUploadTransportInterface`, `HeaderCredentialsInterface`), and traits.
- **`PathTemplate::__construct(string $path)`** now requires a non-null `string`.
- **`OperationResponse`**:
- `__construct(string $operationName, object $operationsClient, array $options = [])` now requires non-null `$operationName` (`string`) and `$operationsClient` (`object`).
- `getName()` now returns non-nullable `string`.
- `getError()` now returns `?Google\Rpc\Status`.
- `getLastProtoResponse()` now returns `?Google\LongRunning\Operation`.
- `getOperationsClient()` now returns `Google\LongRunning\Client\OperationsClient|Google\ApiCore\OperationsClientInterface`.
- Custom operations clients (e.g., Compute's `ZoneOperationsClient`) and custom operation options are now encapsulated in `Google\ApiCore\CustomOperationsClient` (implementing `Google\ApiCore\OperationsClientInterface`), which normalizes custom operation proto responses into `Google\LongRunning\Operation`.

Loading
Loading