Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
800d1b8
feat(Gax): add ServiceInterface, LongRunningOperationProviderInterfac…
bshaffer Sep 30, 2026
4fa51eb
feat(Gax)!: remove V1 GAPIC backwards compatibility and deprecated cl…
bshaffer Oct 1, 2026
33e0d23
test(Gax): add interface tests, PHPDocs, and DeprecatedOperationsClie…
bshaffer Oct 1, 2026
add48e7
Merge branch 'gax-service-interfaces' into gax-v2-remove-deprecations
bshaffer Oct 1, 2026
ef0053d
fix(Gax): keep createOperationsClient private and use ReflectionMetho…
bshaffer Oct 1, 2026
dc9bb56
Merge branch 'gax-service-interfaces' into gax-v2-remove-deprecations
bshaffer Oct 1, 2026
2a1cc79
test(Gax): update CustomOperationClient mock signature for V2
bshaffer Oct 1, 2026
43cb2f3
test(Logging): replace deprecated Google\ApiCore\GPBType with Google\…
bshaffer Oct 1, 2026
8ebed50
chore(Gax): remove audience from CallOptions and test audience overri…
bshaffer Oct 5, 2026
0e68422
Merge remote-tracking branch 'origin/main' into gax-service-interfaces
bshaffer Nov 12, 2026
a034f94
Merge branch 'gax-service-interfaces' into gax-v2-remove-deprecations
bshaffer Nov 12, 2026
c5183aa
test(Gax): avoid PHP 8.5 null array offset deprecation in GapicV2Surf…
bshaffer Nov 12, 2026
76e421f
Merge branch 'gax-service-interfaces' into gax-v2-remove-deprecations
bshaffer Nov 12, 2026
f60493e
chore: mark GPBType, GPBLabel, and V1 LongRunning OperationsClient as…
bshaffer Nov 13, 2026
353ed5b
Merge branch 'gax-service-interfaces' into gax-v2-remove-deprecations
bshaffer Nov 13, 2026
7dc6735
chore(Gax): mark new client interfaces as experimental and internal
bshaffer Nov 16, 2026
88d17ea
Merge branch 'gax-service-interfaces' into gax-v2-remove-deprecations
bshaffer Nov 16, 2026
1a7e5b3
Merge branch 'main' into gax-v2-remove-deprecations
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
2 changes: 1 addition & 1 deletion Gax/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"guzzlehttp/promises": "^2.0.3||^3.0",
"guzzlehttp/psr7": "^2.6.3||^3.0",
"google/common-protos": "^4.9",
"google/longrunning": "~0.4",
"google/longrunning": "~0.4||^1.0",
"ramsey/uuid": "^4.2.3"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/*
* Copyright 2018 Google LLC
* All rights reserved.
Expand Down Expand Up @@ -34,12 +36,8 @@

/**
* Provides helper methods for service address handling.
*
* @deprecated
* @todo (dwsupplee) serviceAddress is deprecated now in favor of
* apiEndpoint. Rename the trait/method in our next major release.
*/
trait ServiceAddressTrait
trait ApiEndpointTrait
{
private static $defaultPort = 443;

Expand All @@ -48,7 +46,7 @@ trait ServiceAddressTrait
* @return array
* @throws ValidationException
*/
private static function normalizeServiceAddress(string $apiEndpoint)
private static function normalizeApiEndpoint(string $apiEndpoint)
{
$components = explode(':', $apiEndpoint);
if (count($components) == 2) {
Expand Down
35 changes: 9 additions & 26 deletions Gax/src/ClientOptionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,15 @@ private function buildClientOptions(array|ClientOptions $options)
$options['transportConfig']['grpc-fallback']['logger'] = $options['logger'] ?? null;
}

// These calls do not apply to "New Surface" clients.
if ($this->isBackwardsCompatibilityMode()) {
$preModifiedOptions = $options;
$this->modifyClientOptions($options);
// NOTE: this is required to ensure backwards compatiblity with $options['apiEndpoint']
if ($options['apiEndpoint'] !== $preModifiedOptions['apiEndpoint']) {
$apiEndpoint = $options['apiEndpoint'];
}

// serviceAddress is now deprecated and acts as an alias for apiEndpoint
if (isset($options['serviceAddress'])) {
$apiEndpoint = $this->pluck('serviceAddress', $options, false);
}
} else {
// Ads is using this method in their new surface clients, so we need to call it.
// However, this method is not used anywhere else for the new surface clients
// @TODO: Remove this in GAX V2
$this->modifyClientOptions($options);
$preModifiedOptions = $options;
$this->modifyClientOptions($options);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is removed in #9752 but we leave it here so we can separate these into two more easily-reviewable PRs

// NOTE: this is required to ensure backwards compatiblity with $options['apiEndpoint']
if ($options['apiEndpoint'] !== $preModifiedOptions['apiEndpoint']) {
$apiEndpoint = $options['apiEndpoint'];
}
// serviceAddress is now deprecated and acts as an alias for apiEndpoint
if (isset($options['serviceAddress'])) {
$apiEndpoint = $this->pluck('serviceAddress', $options, false);
}
// If an API endpoint is different form the default, ensure the "audience" does not conflict
// with the custom endpoint by setting "user defined" scopes.
Expand Down Expand Up @@ -366,14 +357,6 @@ protected function modifyClientOptions(array &$options)
// Do nothing - this method exists to allow option modification by partial veneers.
}

/**
* @internal
*/
private function isBackwardsCompatibilityMode(): bool
{
return false;
}

/**
* @param null|false|LoggerInterface $logger
* @param string $options
Expand Down
45 changes: 0 additions & 45 deletions Gax/src/GPBLabel.php

This file was deleted.

60 changes: 0 additions & 60 deletions Gax/src/GPBType.php

This file was deleted.

47 changes: 4 additions & 43 deletions Gax/src/GapicClientTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

namespace Google\ApiCore;

use Google\ApiCore\LongRunning\OperationsClient as DeprecatedOperationsClient;
use Google\ApiCore\Middleware\CredentialsWrapperMiddleware;
use Google\ApiCore\Middleware\FixedHeaderMiddleware;
use Google\ApiCore\Middleware\OperationsMiddleware;
Expand Down Expand Up @@ -85,7 +84,6 @@ trait GapicClientTrait
Call::CLIENT_STREAMING_CALL => 'startClientStreamingCall',
Call::SERVER_STREAMING_CALL => 'startServerStreamingCall',
];
private bool $backwardsCompatibilityMode;

/**
* Add a middleware to the call stack by providing a callable which will be
Expand Down Expand Up @@ -295,20 +293,8 @@ private function setClientOptions(array $options)
// Therefore, we need to remove it from the $options array before
// creating the ClientOptions.
$hasEmulator = $this->pluck('hasEmulator', $options, false) ?? false;
if ($this->isBackwardsCompatibilityMode()) {
if (is_string($options['clientConfig'])) {
// perform validation for V1 surfaces which is done in the
// ClientOptions class for v2 surfaces.
$options['clientConfig'] = json_decode(
file_get_contents($options['clientConfig']),
true
);
self::validateFileExists($options['descriptorsConfigPath']);
}
} else {
// cast to ClientOptions for new surfaces only
$options = new ClientOptions($options);
}
// cast to ClientOptions for new surfaces only
$options = new ClientOptions($options);
$this->serviceName = $options['serviceName'];
$this->retrySettings = RetrySettings::load(
$this->serviceName,
Expand All @@ -331,14 +317,6 @@ private function setClientOptions(array $options)
}
$this->agentHeader = AgentHeader::buildAgentHeader($headerInfo);

// Set "client_library_name" depending on client library surface being used
$userAgentHeader = sprintf(
'gcloud-php-%s/%s',
$this->isBackwardsCompatibilityMode() ? 'legacy' : 'new',
$options['gapicVersion']
);
$this->agentHeader['User-Agent'] = [$userAgentHeader];

self::validateFileExists($options['descriptorsConfigPath']);

$descriptors = require($options['descriptorsConfigPath']);
Expand Down Expand Up @@ -455,7 +433,7 @@ private function createTransport(

/**
* @param array $options
* @return DeprecatedOperationsClient|OperationsClient|object
* @return OperationsClient|object
*/
private function createOperationsClient(array $options)
{
Expand All @@ -471,12 +449,7 @@ private function createOperationsClient(array $options)
}

// operationsClientClass option
$defaultClass = $this->isBackwardsCompatibilityMode()
? DeprecatedOperationsClient::class
: OperationsClient::class;
$operationsClientClass = $this->pluck('operationsClientClass', $options, false)
?: $defaultClass;
return new $operationsClientClass($options);
return new OperationsClient($options);
}

/**
Expand Down Expand Up @@ -796,9 +769,6 @@ private function configureCallConstructionOptions(string $methodName, array $opt
*/
private function configureCallOptions(array $optionalArgs): array
{
if ($this->isBackwardsCompatibilityMode()) {
return $optionalArgs;
}
// cast to CallOptions for new surfaces only
return (new CallOptions($optionalArgs))->toArray();
}
Expand Down Expand Up @@ -1075,13 +1045,4 @@ protected function modifyStreamingCallable(callable &$callable)
{
// Do nothing - this method exists to allow callable modification by partial veneers.
}

/**
* @internal
*/
private function isBackwardsCompatibilityMode(): bool
{
return $this->backwardsCompatibilityMode
?? $this->backwardsCompatibilityMode = substr(__CLASS__, -11) === 'GapicClient';
}
}
33 changes: 5 additions & 28 deletions Gax/src/OperationResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
use Google\LongRunning\DeleteOperationRequest;
use Google\LongRunning\GetOperationRequest;
use Google\LongRunning\Operation;
use Google\LongRunning\OperationsClient as LegacyOperationsClient;
use Google\Protobuf\Any;
use Google\Protobuf\Internal\Message;
use Google\Rpc\Status;
Expand Down Expand Up @@ -67,7 +66,6 @@ class OperationResponse
const DEFAULT_POLLING_MULTIPLIER = 2;
const DEFAULT_MAX_POLLING_INTERVAL = 60000;
const DEFAULT_MAX_POLLING_DURATION = 0;
private const NEW_CLIENT_NAMESPACE = '\\Client\\';

private string $operationName;
private ?object $operationsClient;
Expand Down Expand Up @@ -277,8 +275,7 @@ public function reload()
throw new ValidationException('Cannot call reload() on a deleted operation');
}

$requestClass = $this->isNewSurfaceOperationsClient() ? $this->getOperationRequest : null;
$this->lastProtoResponse = $this->operationsCall($this->getOperationMethod, $requestClass);
$this->lastProtoResponse = $this->operationsCall($this->getOperationMethod, $this->getOperationRequest);
}

/**
Expand Down Expand Up @@ -403,8 +400,7 @@ public function cancel()
throw new LogicException('The cancel operation is not supported by this API');
}

$requestClass = $this->isNewSurfaceOperationsClient() ? $this->cancelOperationRequest : null;
$this->operationsCall($this->cancelOperationMethod, $requestClass);
$this->operationsCall($this->cancelOperationMethod, $this->cancelOperationRequest);
}

/**
Expand All @@ -424,8 +420,7 @@ public function delete()
throw new LogicException('The delete operation is not supported by this API');
}

$requestClass = $this->isNewSurfaceOperationsClient() ? $this->deleteOperationRequest : null;
$this->operationsCall($this->deleteOperationMethod, $requestClass);
$this->operationsCall($this->deleteOperationMethod, $this->deleteOperationRequest);
$this->deleted = true;
}

Expand Down Expand Up @@ -471,22 +466,10 @@ public function getMetadata()
* Call the operations client to perform an operation.
*
* @param string $method The method to call on the operations client.
* @param string|null $requestClass The request class to use for the call.
* Will be null for legacy operations clients.
* @param string $requestClass The request class to use for the call.
*/
private function operationsCall(string $method, ?string $requestClass)
private function operationsCall(string $method, string $requestClass)
{
// V1 GAPIC clients have an empty $requestClass
if (empty($requestClass)) {
if ($this->additionalArgs) {
return $this->operationsClient->$method(
$this->getName(),
...array_values($this->additionalArgs)
);
}
return $this->operationsClient->$method($this->getName());
}

if (!method_exists($requestClass, 'build')) {
throw new LogicException('Request class must support the static build method');
}
Expand Down Expand Up @@ -530,10 +513,4 @@ private function hasProtoResponse()
{
return !is_null($this->lastProtoResponse);
}

private function isNewSurfaceOperationsClient(): bool
{
return !$this->operationsClient instanceof LegacyOperationsClient
&& false !== strpos(get_class($this->operationsClient), self::NEW_CLIENT_NAMESPACE);
}
}
10 changes: 0 additions & 10 deletions Gax/src/Options/CallOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,6 @@ public function setTransportOptions(array $transportOptions): self
return $this;
}

/**
* @deprecated use CallOptions::setTransportOptions
*/
public function setTransportSpecificOptions(array $transportSpecificOptions): self
{
$this->setTransportOptions($transportSpecificOptions);

return $this;
}

/**
* @param RetrySettings|array|null $retrySettings
*
Expand Down
Loading
Loading