Skip to content

Commit 4825644

Browse files
feat: [Many APIs] usage deprecation of credentials client option (#8604)
* feat: support ClientOptions in client constructor docs: document universeDomain client option docs: add "generic" phpdocs for OperationResponse and ServerStream fix: Update pagination rules for compute clients deps: Update dependency google/protobuf to v4 PiperOrigin-RevId: 807444648 Source-Link: googleapis/googleapis@6288882 Source-Link: googleapis/googleapis-gen@577eee9 Copy-Tag: eyJwIjoiU2VydmljZVVzYWdlLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiMTcwZjZmOWY4YmQ3OTc1YTM2In0= Copy-Tag: eyJwIjoiU2hlbGwvLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiU2hvcHBpbmdDc3MvLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiU2hvcHBpbmdNZXJjaGFudEFjY291bnRzLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiMTcwZjZmOWY4YmQ3OTc1YTM2In0= Copy-Tag: eyJwIjoiU2hvcHBpbmdNZXJjaGFudENvbnZlcnNpb25zLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiMTcwZjZmOWY4YmQ3OTc1YTM2In0= Copy-Tag: eyJwIjoiU2hvcHBpbmdNZXJjaGFudERhdGFTb3VyY2VzLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiMTcwZjZmOWY4YmQ3OTc1YTM2In0= Copy-Tag: eyJwIjoiU2hvcHBpbmdNZXJjaGFudEludmVudG9yaWVzLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiM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3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiU2hvcHBpbmdNZXJjaGFudFJldmlld3MvLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiNTc3ZWVlOTMxYjczZTkxMGZmYWUxYjE3MGY2ZjlmOGJkNzk3NWEzNiJ9 Copy-Tag: eyJwIjoiU3BlZWNoLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiMTcwZjZmOWY4YmQ3OTc1YTM2In0= Copy-Tag: eyJwIjoiU3FsQWRtaW4vLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiU3RvcmFnZUJhdGNoT3BlcmF0aW9ucy8uT3dsQm90LnlhbWwiLCJoIjoiNTc3ZWVlOTMxYjczZTkxMGZmYWUxYjE3MGY2ZjlmOGJkNzk3NWEzNiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * docs: usage deprecation of credentials client option PiperOrigin-RevId: 809097824 Source-Link: googleapis/googleapis@e8ed6b4 Source-Link: googleapis/googleapis-gen@96cfee1 Copy-Tag: eyJwIjoiU2VydmljZVVzYWdlLy5Pd2xCb3QueWFtbCIsImgiOiI5NmNmZWUxNjM5MzY4ZTM0YThkMWY3NjVjZWRkZWNmOWRjYTExOWRjIn0= Copy-Tag: eyJwIjoiU2hlbGwvLk93bEJvdC55YW1sIiwiaCI6Ijk2Y2ZlZTE2MzkzNjhlMzRhOGQxZjc2NWNlZGRlY2Y5ZGNhMTE5ZGMifQ== Copy-Tag: eyJwIjoiU2hvc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: eyJwIjoiU3FsQWRtaW4vLk93bEJvdC55YW1sIiwiaCI6Ijk2Y2ZlZTE2MzkzNjhlMzRhOGQxZjc2NWNlZGRlY2Y5ZGNhMTE5ZGMifQ== Copy-Tag: eyJwIjoiU3RvcmFnZUJhdGNoT3BlcmF0aW9ucy8uT3dsQm90LnlhbWwiLCJoIjoiOTZjZmVlMTYzOTM2OGUzNGE4ZDFmNzY1Y2VkZGVjZjlkY2ExMTlkYyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 5b522c6 commit 4825644

105 files changed

Lines changed: 2709 additions & 2143 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ServiceUsage/src/V1/Client/ServiceUsageClient.php

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,20 @@
2828
use Google\ApiCore\CredentialsWrapper;
2929
use Google\ApiCore\GapicClientTrait;
3030
use Google\ApiCore\OperationResponse;
31+
use Google\ApiCore\Options\ClientOptions;
3132
use Google\ApiCore\PagedListResponse;
3233
use Google\ApiCore\RetrySettings;
3334
use Google\ApiCore\Transport\TransportInterface;
3435
use Google\ApiCore\ValidationException;
3536
use Google\Auth\FetchAuthTokenInterface;
3637
use Google\Cloud\ServiceUsage\V1\BatchEnableServicesRequest;
38+
use Google\Cloud\ServiceUsage\V1\BatchEnableServicesResponse;
3739
use Google\Cloud\ServiceUsage\V1\BatchGetServicesRequest;
3840
use Google\Cloud\ServiceUsage\V1\BatchGetServicesResponse;
3941
use Google\Cloud\ServiceUsage\V1\DisableServiceRequest;
42+
use Google\Cloud\ServiceUsage\V1\DisableServiceResponse;
4043
use Google\Cloud\ServiceUsage\V1\EnableServiceRequest;
44+
use Google\Cloud\ServiceUsage\V1\EnableServiceResponse;
4145
use Google\Cloud\ServiceUsage\V1\GetServiceRequest;
4246
use Google\Cloud\ServiceUsage\V1\ListServicesRequest;
4347
use Google\Cloud\ServiceUsage\V1\Service;
@@ -137,9 +141,7 @@ public function getOperationsClient()
137141
*/
138142
public function resumeOperation($operationName, $methodName = null)
139143
{
140-
$options = isset($this->descriptors[$methodName]['longRunning'])
141-
? $this->descriptors[$methodName]['longRunning']
142-
: [];
144+
$options = $this->descriptors[$methodName]['longRunning'] ?? [];
143145
$operation = new OperationResponse($operationName, $this->getOperationsClient(), $options);
144146
$operation->reload();
145147
return $operation;
@@ -167,25 +169,28 @@ private function createOperationsClient(array $options)
167169
/**
168170
* Constructor.
169171
*
170-
* @param array $options {
172+
* @param array|ClientOptions $options {
171173
* Optional. Options for configuring the service API wrapper.
172174
*
173175
* @type string $apiEndpoint
174176
* The address of the API remote host. May optionally include the port, formatted
175177
* as "<uri>:<port>". Default 'serviceusage.googleapis.com:443'.
176-
* @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
177-
* The credentials to be used by the client to authorize API calls. This option
178-
* accepts either a path to a credentials file, or a decoded credentials file as a
179-
* PHP array.
180-
* *Advanced usage*: In addition, this option can also accept a pre-constructed
181-
* {@see \Google\Auth\FetchAuthTokenInterface} object or
182-
* {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
183-
* objects are provided, any settings in $credentialsConfig will be ignored.
184-
* *Important*: If you accept a credential configuration (credential
185-
* JSON/File/Stream) from an external source for authentication to Google Cloud
186-
* Platform, you must validate it before providing it to any Google API or library.
187-
* Providing an unvalidated credential configuration to Google APIs can compromise
188-
* the security of your systems and data. For more information {@see
178+
* @type FetchAuthTokenInterface|CredentialsWrapper $credentials
179+
* This option should only be used with a pre-constructed
180+
* {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
181+
* when one of these objects are provided, any settings in $credentialsConfig will
182+
* be ignored.
183+
* **Important**: If you are providing a path to a credentials file, or a decoded
184+
* credentials file as a PHP array, this usage is now DEPRECATED. Providing an
185+
* unvalidated credential configuration to Google APIs can compromise the security
186+
* of your systems and data. It is recommended to create the credentials explicitly
187+
* ```
188+
* use Google\Auth\Credentials\ServiceAccountCredentials;
189+
* use Google\Cloud\ServiceUsage\V1\ServiceUsageClient;
190+
* $creds = new ServiceAccountCredentials($scopes, $json);
191+
* $options = new ServiceUsageClient(['credentials' => $creds]);
192+
* ```
193+
* {@see
189194
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
190195
* @type array $credentialsConfig
191196
* Options used to configure credentials, including auth token caching, for the
@@ -223,11 +228,13 @@ private function createOperationsClient(array $options)
223228
* @type false|LoggerInterface $logger
224229
* A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
225230
* 'GOOGLE_SDK_PHP_LOGGING' environment flag
231+
* @type string $universeDomain
232+
* The service domain for the client. Defaults to 'googleapis.com'.
226233
* }
227234
*
228235
* @throws ValidationException
229236
*/
230-
public function __construct(array $options = [])
237+
public function __construct(array|ClientOptions $options = [])
231238
{
232239
$clientOptions = $this->buildClientOptions($options);
233240
$this->setClientOptions($clientOptions);
@@ -264,7 +271,7 @@ public function __call($method, $args)
264271
* {@see RetrySettings} for example usage.
265272
* }
266273
*
267-
* @return OperationResponse
274+
* @return OperationResponse<BatchEnableServicesResponse>
268275
*
269276
* @throws ApiException Thrown if the API call fails.
270277
*/
@@ -295,10 +302,8 @@ public function batchEnableServices(BatchEnableServicesRequest $request, array $
295302
*
296303
* @throws ApiException Thrown if the API call fails.
297304
*/
298-
public function batchGetServices(
299-
BatchGetServicesRequest $request,
300-
array $callOptions = []
301-
): BatchGetServicesResponse {
305+
public function batchGetServices(BatchGetServicesRequest $request, array $callOptions = []): BatchGetServicesResponse
306+
{
302307
return $this->startApiCall('BatchGetServices', $request, $callOptions)->wait();
303308
}
304309

@@ -325,7 +330,7 @@ public function batchGetServices(
325330
* {@see RetrySettings} for example usage.
326331
* }
327332
*
328-
* @return OperationResponse
333+
* @return OperationResponse<DisableServiceResponse>
329334
*
330335
* @throws ApiException Thrown if the API call fails.
331336
*/
@@ -351,7 +356,7 @@ public function disableService(DisableServiceRequest $request, array $callOption
351356
* {@see RetrySettings} for example usage.
352357
* }
353358
*
354-
* @return OperationResponse
359+
* @return OperationResponse<EnableServiceResponse>
355360
*
356361
* @throws ApiException Thrown if the API call fails.
357362
*/

Shell/src/V1/Client/CloudShellServiceClient.php

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,20 @@
2828
use Google\ApiCore\CredentialsWrapper;
2929
use Google\ApiCore\GapicClientTrait;
3030
use Google\ApiCore\OperationResponse;
31+
use Google\ApiCore\Options\ClientOptions;
3132
use Google\ApiCore\ResourceHelperTrait;
3233
use Google\ApiCore\RetrySettings;
3334
use Google\ApiCore\Transport\TransportInterface;
3435
use Google\ApiCore\ValidationException;
3536
use Google\Auth\FetchAuthTokenInterface;
3637
use Google\Cloud\Shell\V1\AddPublicKeyRequest;
38+
use Google\Cloud\Shell\V1\AddPublicKeyResponse;
3739
use Google\Cloud\Shell\V1\AuthorizeEnvironmentRequest;
40+
use Google\Cloud\Shell\V1\AuthorizeEnvironmentResponse;
3841
use Google\Cloud\Shell\V1\Environment;
3942
use Google\Cloud\Shell\V1\GetEnvironmentRequest;
4043
use Google\Cloud\Shell\V1\RemovePublicKeyRequest;
44+
use Google\Cloud\Shell\V1\RemovePublicKeyResponse;
4145
use Google\Cloud\Shell\V1\StartEnvironmentMetadata;
4246
use Google\Cloud\Shell\V1\StartEnvironmentRequest;
4347
use Google\Cloud\Shell\V1\StartEnvironmentResponse;
@@ -94,7 +98,9 @@ final class CloudShellServiceClient
9498
private const CODEGEN_NAME = 'gapic';
9599

96100
/** The default scopes required by the service. */
97-
public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform'];
101+
public static $serviceScopes = [
102+
'https://www.googleapis.com/auth/cloud-platform',
103+
];
98104

99105
private $operationsClient;
100106

@@ -140,9 +146,7 @@ public function getOperationsClient()
140146
*/
141147
public function resumeOperation($operationName, $methodName = null)
142148
{
143-
$options = isset($this->descriptors[$methodName]['longRunning'])
144-
? $this->descriptors[$methodName]['longRunning']
145-
: [];
149+
$options = $this->descriptors[$methodName]['longRunning'] ?? [];
146150
$operation = new OperationResponse($operationName, $this->getOperationsClient(), $options);
147151
$operation->reload();
148152
return $operation;
@@ -211,25 +215,28 @@ public static function parseName(string $formattedName, ?string $template = null
211215
/**
212216
* Constructor.
213217
*
214-
* @param array $options {
218+
* @param array|ClientOptions $options {
215219
* Optional. Options for configuring the service API wrapper.
216220
*
217221
* @type string $apiEndpoint
218222
* The address of the API remote host. May optionally include the port, formatted
219223
* as "<uri>:<port>". Default 'cloudshell.googleapis.com:443'.
220-
* @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
221-
* The credentials to be used by the client to authorize API calls. This option
222-
* accepts either a path to a credentials file, or a decoded credentials file as a
223-
* PHP array.
224-
* *Advanced usage*: In addition, this option can also accept a pre-constructed
225-
* {@see \Google\Auth\FetchAuthTokenInterface} object or
226-
* {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
227-
* objects are provided, any settings in $credentialsConfig will be ignored.
228-
* *Important*: If you accept a credential configuration (credential
229-
* JSON/File/Stream) from an external source for authentication to Google Cloud
230-
* Platform, you must validate it before providing it to any Google API or library.
231-
* Providing an unvalidated credential configuration to Google APIs can compromise
232-
* the security of your systems and data. For more information {@see
224+
* @type FetchAuthTokenInterface|CredentialsWrapper $credentials
225+
* This option should only be used with a pre-constructed
226+
* {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
227+
* when one of these objects are provided, any settings in $credentialsConfig will
228+
* be ignored.
229+
* **Important**: If you are providing a path to a credentials file, or a decoded
230+
* credentials file as a PHP array, this usage is now DEPRECATED. Providing an
231+
* unvalidated credential configuration to Google APIs can compromise the security
232+
* of your systems and data. It is recommended to create the credentials explicitly
233+
* ```
234+
* use Google\Auth\Credentials\ServiceAccountCredentials;
235+
* use Google\Cloud\Shell\V1\CloudShellServiceClient;
236+
* $creds = new ServiceAccountCredentials($scopes, $json);
237+
* $options = new CloudShellServiceClient(['credentials' => $creds]);
238+
* ```
239+
* {@see
233240
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
234241
* @type array $credentialsConfig
235242
* Options used to configure credentials, including auth token caching, for the
@@ -267,11 +274,13 @@ public static function parseName(string $formattedName, ?string $template = null
267274
* @type false|LoggerInterface $logger
268275
* A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
269276
* 'GOOGLE_SDK_PHP_LOGGING' environment flag
277+
* @type string $universeDomain
278+
* The service domain for the client. Defaults to 'googleapis.com'.
270279
* }
271280
*
272281
* @throws ValidationException
273282
*/
274-
public function __construct(array $options = [])
283+
public function __construct(array|ClientOptions $options = [])
275284
{
276285
$clientOptions = $this->buildClientOptions($options);
277286
$this->setClientOptions($clientOptions);
@@ -308,7 +317,7 @@ public function __call($method, $args)
308317
* {@see RetrySettings} for example usage.
309318
* }
310319
*
311-
* @return OperationResponse
320+
* @return OperationResponse<AddPublicKeyResponse>
312321
*
313322
* @throws ApiException Thrown if the API call fails.
314323
*/
@@ -338,14 +347,12 @@ public function addPublicKey(AddPublicKeyRequest $request, array $callOptions =
338347
* {@see RetrySettings} for example usage.
339348
* }
340349
*
341-
* @return OperationResponse
350+
* @return OperationResponse<AuthorizeEnvironmentResponse>
342351
*
343352
* @throws ApiException Thrown if the API call fails.
344353
*/
345-
public function authorizeEnvironment(
346-
AuthorizeEnvironmentRequest $request,
347-
array $callOptions = []
348-
): OperationResponse {
354+
public function authorizeEnvironment(AuthorizeEnvironmentRequest $request, array $callOptions = []): OperationResponse
355+
{
349356
return $this->startApiCall('AuthorizeEnvironment', $request, $callOptions)->wait();
350357
}
351358

@@ -395,7 +402,7 @@ public function getEnvironment(GetEnvironmentRequest $request, array $callOption
395402
* {@see RetrySettings} for example usage.
396403
* }
397404
*
398-
* @return OperationResponse
405+
* @return OperationResponse<RemovePublicKeyResponse>
399406
*
400407
* @throws ApiException Thrown if the API call fails.
401408
*/
@@ -426,7 +433,7 @@ public function removePublicKey(RemovePublicKeyRequest $request, array $callOpti
426433
* {@see RetrySettings} for example usage.
427434
* }
428435
*
429-
* @return OperationResponse
436+
* @return OperationResponse<StartEnvironmentResponse>
430437
*
431438
* @throws ApiException Thrown if the API call fails.
432439
*/

ShoppingCss/src/V1/Client/AccountLabelsServiceClient.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Google\ApiCore\ApiException;
2828
use Google\ApiCore\CredentialsWrapper;
2929
use Google\ApiCore\GapicClientTrait;
30+
use Google\ApiCore\Options\ClientOptions;
3031
use Google\ApiCore\PagedListResponse;
3132
use Google\ApiCore\ResourceHelperTrait;
3233
use Google\ApiCore\RetrySettings;
@@ -82,7 +83,9 @@ final class AccountLabelsServiceClient
8283
private const CODEGEN_NAME = 'gapic';
8384

8485
/** The default scopes required by the service. */
85-
public static $serviceScopes = ['https://www.googleapis.com/auth/content'];
86+
public static $serviceScopes = [
87+
'https://www.googleapis.com/auth/content',
88+
];
8689

8790
private static function getClientDefaults()
8891
{
@@ -163,25 +166,28 @@ public static function parseName(string $formattedName, ?string $template = null
163166
/**
164167
* Constructor.
165168
*
166-
* @param array $options {
169+
* @param array|ClientOptions $options {
167170
* Optional. Options for configuring the service API wrapper.
168171
*
169172
* @type string $apiEndpoint
170173
* The address of the API remote host. May optionally include the port, formatted
171174
* as "<uri>:<port>". Default 'css.googleapis.com:443'.
172-
* @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
173-
* The credentials to be used by the client to authorize API calls. This option
174-
* accepts either a path to a credentials file, or a decoded credentials file as a
175-
* PHP array.
176-
* *Advanced usage*: In addition, this option can also accept a pre-constructed
177-
* {@see \Google\Auth\FetchAuthTokenInterface} object or
178-
* {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
179-
* objects are provided, any settings in $credentialsConfig will be ignored.
180-
* *Important*: If you accept a credential configuration (credential
181-
* JSON/File/Stream) from an external source for authentication to Google Cloud
182-
* Platform, you must validate it before providing it to any Google API or library.
183-
* Providing an unvalidated credential configuration to Google APIs can compromise
184-
* the security of your systems and data. For more information {@see
175+
* @type FetchAuthTokenInterface|CredentialsWrapper $credentials
176+
* This option should only be used with a pre-constructed
177+
* {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
178+
* when one of these objects are provided, any settings in $credentialsConfig will
179+
* be ignored.
180+
* **Important**: If you are providing a path to a credentials file, or a decoded
181+
* credentials file as a PHP array, this usage is now DEPRECATED. Providing an
182+
* unvalidated credential configuration to Google APIs can compromise the security
183+
* of your systems and data. It is recommended to create the credentials explicitly
184+
* ```
185+
* use Google\Auth\Credentials\ServiceAccountCredentials;
186+
* use Google\Shopping\Css\V1\AccountLabelsServiceClient;
187+
* $creds = new ServiceAccountCredentials($scopes, $json);
188+
* $options = new AccountLabelsServiceClient(['credentials' => $creds]);
189+
* ```
190+
* {@see
185191
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
186192
* @type array $credentialsConfig
187193
* Options used to configure credentials, including auth token caching, for the
@@ -219,11 +225,13 @@ public static function parseName(string $formattedName, ?string $template = null
219225
* @type false|LoggerInterface $logger
220226
* A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
221227
* 'GOOGLE_SDK_PHP_LOGGING' environment flag
228+
* @type string $universeDomain
229+
* The service domain for the client. Defaults to 'googleapis.com'.
222230
* }
223231
*
224232
* @throws ValidationException
225233
*/
226-
public function __construct(array $options = [])
234+
public function __construct(array|ClientOptions $options = [])
227235
{
228236
$clientOptions = $this->buildClientOptions($options);
229237
$this->setClientOptions($clientOptions);

0 commit comments

Comments
 (0)