Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 8 additions & 4 deletions Gax/src/GapicClientTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

namespace Google\ApiCore;

use Google\ApiCore\LongRunning\OperationsClient;
use Google\ApiCore\LongRunning\OperationsClient as DeprecatedOperationsClient;
use Google\ApiCore\Middleware\CredentialsWrapperMiddleware;
use Google\ApiCore\Middleware\FixedHeaderMiddleware;
use Google\ApiCore\Middleware\OperationsMiddleware;
Expand All @@ -50,6 +50,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 @@ -174,7 +175,7 @@ public static function getServiceScopes(): array
*
* @experimental
*/
public function close()
public function close(): void
{
$this->transport->close();
}
Expand Down Expand Up @@ -454,7 +455,7 @@ private function createTransport(

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

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

Expand Down
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;
}
64 changes: 64 additions & 0 deletions Gax/src/LongRunningOperationProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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\LongRunning\Client\OperationsClient;

/**
* Interface implemented by GAPIC service clients that support standard
* Google Cloud Long-Running Operations (LROs).
*/
interface LongRunningOperationProviderInterface
{
/**
* Resume an existing long running operation that was previously started by a long
* running API method. If $methodName is not provided, or does not match a long
* running API method, then the operation can still be resumed, but the
* OperationResponse object will not deserialize the final response.
*
* @param string $operationName The name of the long running operation
* @param string|null $methodName The name of the method used to start the operation
*
* @return OperationResponse
*/
public function resumeOperation(string $operationName, ?string $methodName = null): OperationResponse;

/**
* Return an OperationsClient object with the same endpoint as $this.
*
* @return OperationsClient
*/
public function getOperationsClient(): OperationsClient;
}
123 changes: 123 additions & 0 deletions Gax/src/ServiceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?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;

/**
* Interface implemented by all GAPIC service clients, defining common lifecycle,
* scope, and middleware configuration methods.
*/
interface ServiceInterface
{
/**
* Add a middleware to the call stack by providing a callable which will be
* invoked at the start of each call, and will return an instance of
* {@see \Google\ApiCore\Middleware\MiddlewareInterface} when invoked.
*
* The callable must have the following method signature:
*
* callable(MiddlewareInterface): MiddlewareInterface
*
* An implementation may look something like this:
* ```
* $client->addMiddleware(function (MiddlewareInterface $handler) {
* return new class ($handler) implements MiddlewareInterface {
* public function __construct(private MiddlewareInterface $handler) {
* }
*
* public function __invoke(Call $call, array $options) {
* // modify call and options (pre-request)
* $response = ($this->handler)($call, $options);
* // modify the response (post-request)
* return $response;
* }
* };
* });
* ```
*
* @param callable $middlewareCallable A callable which returns an instance
* of {@see \Google\ApiCore\Middleware\MiddlewareInterface} when invoked with a
* MiddlewareInterface instance as its first argument.
* @return void
*/
public function addMiddleware(callable $middlewareCallable): void;

/**
* Prepend a middleware to the call stack by providing a callable which will be
* invoked at the end of each call, and will return an instance of
* {@see \Google\ApiCore\Middleware\MiddlewareInterface} when invoked.
*
* The callable must have the following method signature:
*
* callable(MiddlewareInterface): MiddlewareInterface
*
* An implementation may look something like this:
* ```
* $client->prependMiddleware(function (MiddlewareInterface $handler) {
* return new class ($handler) implements MiddlewareInterface {
* public function __construct(private MiddlewareInterface $handler) {
* }
*
* public function __invoke(Call $call, array $options) {
* // modify call and options (pre-request)
* $response = ($this->handler)($call, $options);
* // modify the response (post-request)
* return $response;
* }
* };
* });
* ```
*
* @param callable $middlewareCallable A callable which returns an instance
* of {@see \Google\ApiCore\Middleware\MiddlewareInterface} when invoked with a
* MiddlewareInterface instance as its first argument.
* @return void
*/
public function prependMiddleware(callable $middlewareCallable): void;

/**
* Get the default scopes required by the service.
*
* @return array
*/
public static function getServiceScopes(): array;

/**
* Initiates an orderly shutdown in which preexisting calls continue but new
* calls are immediately cancelled.
*
* @return void
*/
public function close(): void;
}
Loading
Loading