Skip to content
Open
Show file tree
Hide file tree
Changes from 13 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
58 changes: 0 additions & 58 deletions Gax/src/GPBType.php

This file was deleted.

47 changes: 6 additions & 41 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;
use Google\ApiCore\Middleware\CredentialsWrapperMiddleware;
use Google\ApiCore\Middleware\FixedHeaderMiddleware;
use Google\ApiCore\Middleware\OperationsMiddleware;
Expand All @@ -50,6 +49,7 @@
use Google\ApiCore\Transport\RestTransport;
use Google\ApiCore\Transport\TransportInterface;
use Google\Auth\FetchAuthTokenInterface;
use Google\LongRunning\Client\OperationsClient;
use Google\LongRunning\Operation;
use Google\Protobuf\Internal\Message;
use GuzzleHttp\Promise\PromiseInterface;
Expand Down Expand Up @@ -84,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 @@ -174,7 +173,7 @@ public static function getServiceScopes(): array
*
* @experimental
*/
public function close()
public function close(): void
{
$this->transport->close();
}
Expand Down Expand Up @@ -294,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 @@ -330,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 @@ -454,7 +433,7 @@ private function createTransport(

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

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

/**
Expand Down Expand Up @@ -792,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 @@ -1071,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';
}
}
119 changes: 119 additions & 0 deletions Gax/src/IamProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php
declare(strict_types=1);

/*
* Copyright 2026 Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

namespace Google\ApiCore;

use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\Iam\V1\SetIamPolicyRequest;
use Google\Cloud\Iam\V1\TestIamPermissionsRequest;
use Google\Cloud\Iam\V1\TestIamPermissionsResponse;

/**
* Interface implemented by GAPIC service clients that expose IAM policy
* management methods (`getIamPolicy`, `setIamPolicy`, and `testIamPermissions`).
*/
interface IamProviderInterface
{
/**
* Gets the access control policy for a resource. Returns an empty policy
* if the resource exists and does not have a policy set.
*
* @param GetIamPolicyRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see \Google\ApiCore\RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see \Google\ApiCore\RetrySettings} for example usage.
* }
*
* @return Policy
*
* @throws ApiException Thrown if the API call fails.
*/
public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy;

/**
* Sets the access control policy on the specified resource. Replaces
* any existing policy.
*
* Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
* errors.
*
* @param SetIamPolicyRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see \Google\ApiCore\RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see \Google\ApiCore\RetrySettings} for example usage.
* }
*
* @return Policy
*
* @throws ApiException Thrown if the API call fails.
*/
public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy;

/**
* Returns permissions that a caller has on the specified resource. If the
* resource does not exist, this will return an empty set of
* permissions, not a `NOT_FOUND` error.
*
* Note: This operation is designed to be used for building
* permission-aware UIs and command-line tools, not for authorization
* checking. This operation may "fail open" without warning.
*
* @param TestIamPermissionsRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see \Google\ApiCore\RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see \Google\ApiCore\RetrySettings} for example usage.
* }
*
* @return TestIamPermissionsResponse
*
* @throws ApiException Thrown if the API call fails.
*/
public function testIamPermissions(
TestIamPermissionsRequest $request,
array $callOptions = []
): TestIamPermissionsResponse;
}
Loading
Loading