Skip to content

Commit f6c4e21

Browse files
feat: [WebSecurityScanner,Workflows] usage deprecation of credentials client option (#8606)
* 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: eyJwIjoiV2ViU2VjdXJpdHlTY2FubmVyLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiMTcwZjZmOWY4YmQ3OTc1YTM2In0= Copy-Tag: eyJwIjoiV29ya2Zsb3dzLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiMTcwZjZmOWY4YmQ3OTc1YTM2In0= * 🦉 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: eyJwIjoiV2ViU2VjdXJpdHlTY2FubmVyLy5Pd2xCb3QueWFtbCIsImgiOiI5NmNmZWUxNjM5MzY4ZTM0YThkMWY3NjVjZWRkZWNmOWRjYTExOWRjIn0= Copy-Tag: eyJwIjoiV29ya2Zsb3dzLy5Pd2xCb3QueWFtbCIsImgiOiI5NmNmZWUxNjM5MzY4ZTM0YThkMWY3NjVjZWRkZWNmOWRjYTExOWRjIn0= * 🦉 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 db4aee9 commit f6c4e21

3 files changed

Lines changed: 72 additions & 54 deletions

File tree

WebSecurityScanner/src/V1/Client/WebSecurityScannerClient.php

Lines changed: 26 additions & 20 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\RetrySettings;
3233
use Google\ApiCore\Transport\TransportInterface;
@@ -98,7 +99,9 @@ final class WebSecurityScannerClient
9899
private const CODEGEN_NAME = 'gapic';
99100

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

103106
private static function getClientDefaults()
104107
{
@@ -122,25 +125,28 @@ private static function getClientDefaults()
122125
/**
123126
* Constructor.
124127
*
125-
* @param array $options {
128+
* @param array|ClientOptions $options {
126129
* Optional. Options for configuring the service API wrapper.
127130
*
128131
* @type string $apiEndpoint
129132
* The address of the API remote host. May optionally include the port, formatted
130133
* as "<uri>:<port>". Default 'websecurityscanner.googleapis.com:443'.
131-
* @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
132-
* The credentials to be used by the client to authorize API calls. This option
133-
* accepts either a path to a credentials file, or a decoded credentials file as a
134-
* PHP array.
135-
* *Advanced usage*: In addition, this option can also accept a pre-constructed
136-
* {@see \Google\Auth\FetchAuthTokenInterface} object or
137-
* {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
138-
* objects are provided, any settings in $credentialsConfig will be ignored.
139-
* *Important*: If you accept a credential configuration (credential
140-
* JSON/File/Stream) from an external source for authentication to Google Cloud
141-
* Platform, you must validate it before providing it to any Google API or library.
142-
* Providing an unvalidated credential configuration to Google APIs can compromise
143-
* the security of your systems and data. For more information {@see
134+
* @type FetchAuthTokenInterface|CredentialsWrapper $credentials
135+
* This option should only be used with a pre-constructed
136+
* {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
137+
* when one of these objects are provided, any settings in $credentialsConfig will
138+
* be ignored.
139+
* **Important**: If you are providing a path to a credentials file, or a decoded
140+
* credentials file as a PHP array, this usage is now DEPRECATED. Providing an
141+
* unvalidated credential configuration to Google APIs can compromise the security
142+
* of your systems and data. It is recommended to create the credentials explicitly
143+
* ```
144+
* use Google\Auth\Credentials\ServiceAccountCredentials;
145+
* use Google\Cloud\WebSecurityScanner\V1\WebSecurityScannerClient;
146+
* $creds = new ServiceAccountCredentials($scopes, $json);
147+
* $options = new WebSecurityScannerClient(['credentials' => $creds]);
148+
* ```
149+
* {@see
144150
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
145151
* @type array $credentialsConfig
146152
* Options used to configure credentials, including auth token caching, for the
@@ -178,11 +184,13 @@ private static function getClientDefaults()
178184
* @type false|LoggerInterface $logger
179185
* A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
180186
* 'GOOGLE_SDK_PHP_LOGGING' environment flag
187+
* @type string $universeDomain
188+
* The service domain for the client. Defaults to 'googleapis.com'.
181189
* }
182190
*
183191
* @throws ValidationException
184192
*/
185-
public function __construct(array $options = [])
193+
public function __construct(array|ClientOptions $options = [])
186194
{
187195
$clientOptions = $this->buildClientOptions($options);
188196
$this->setClientOptions($clientOptions);
@@ -375,10 +383,8 @@ public function listCrawledUrls(ListCrawledUrlsRequest $request, array $callOpti
375383
*
376384
* @throws ApiException Thrown if the API call fails.
377385
*/
378-
public function listFindingTypeStats(
379-
ListFindingTypeStatsRequest $request,
380-
array $callOptions = []
381-
): ListFindingTypeStatsResponse {
386+
public function listFindingTypeStats(ListFindingTypeStatsRequest $request, array $callOptions = []): ListFindingTypeStatsResponse
387+
{
382388
return $this->startApiCall('ListFindingTypeStats', $request, $callOptions)->wait();
383389
}
384390

Workflows/src/Executions/V1/Client/ExecutionsClient.php

Lines changed: 21 additions & 15 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;
@@ -174,25 +175,28 @@ public static function parseName(string $formattedName, ?string $template = null
174175
/**
175176
* Constructor.
176177
*
177-
* @param array $options {
178+
* @param array|ClientOptions $options {
178179
* Optional. Options for configuring the service API wrapper.
179180
*
180181
* @type string $apiEndpoint
181182
* The address of the API remote host. May optionally include the port, formatted
182183
* as "<uri>:<port>". Default 'workflowexecutions.googleapis.com:443'.
183-
* @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
184-
* The credentials to be used by the client to authorize API calls. This option
185-
* accepts either a path to a credentials file, or a decoded credentials file as a
186-
* PHP array.
187-
* *Advanced usage*: In addition, this option can also accept a pre-constructed
188-
* {@see \Google\Auth\FetchAuthTokenInterface} object or
189-
* {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
190-
* objects are provided, any settings in $credentialsConfig will be ignored.
191-
* *Important*: If you accept a credential configuration (credential
192-
* JSON/File/Stream) from an external source for authentication to Google Cloud
193-
* Platform, you must validate it before providing it to any Google API or library.
194-
* Providing an unvalidated credential configuration to Google APIs can compromise
195-
* the security of your systems and data. For more information {@see
184+
* @type FetchAuthTokenInterface|CredentialsWrapper $credentials
185+
* This option should only be used with a pre-constructed
186+
* {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
187+
* when one of these objects are provided, any settings in $credentialsConfig will
188+
* be ignored.
189+
* **Important**: If you are providing a path to a credentials file, or a decoded
190+
* credentials file as a PHP array, this usage is now DEPRECATED. Providing an
191+
* unvalidated credential configuration to Google APIs can compromise the security
192+
* of your systems and data. It is recommended to create the credentials explicitly
193+
* ```
194+
* use Google\Auth\Credentials\ServiceAccountCredentials;
195+
* use Google\Cloud\Workflows\Executions\V1\ExecutionsClient;
196+
* $creds = new ServiceAccountCredentials($scopes, $json);
197+
* $options = new ExecutionsClient(['credentials' => $creds]);
198+
* ```
199+
* {@see
196200
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
197201
* @type array $credentialsConfig
198202
* Options used to configure credentials, including auth token caching, for the
@@ -230,11 +234,13 @@ public static function parseName(string $formattedName, ?string $template = null
230234
* @type false|LoggerInterface $logger
231235
* A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
232236
* 'GOOGLE_SDK_PHP_LOGGING' environment flag
237+
* @type string $universeDomain
238+
* The service domain for the client. Defaults to 'googleapis.com'.
233239
* }
234240
*
235241
* @throws ValidationException
236242
*/
237-
public function __construct(array $options = [])
243+
public function __construct(array|ClientOptions $options = [])
238244
{
239245
$clientOptions = $this->buildClientOptions($options);
240246
$this->setClientOptions($clientOptions);

Workflows/src/V1/Client/WorkflowsClient.php

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
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\ResourceHelperTrait;
3334
use Google\ApiCore\RetrySettings;
@@ -144,7 +145,7 @@ public function getOperationsClient()
144145
*/
145146
public function resumeOperation($operationName, $methodName = null)
146147
{
147-
$options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : [];
148+
$options = $this->descriptors[$methodName]['longRunning'] ?? [];
148149
$operation = new OperationResponse($operationName, $this->getOperationsClient(), $options);
149150
$operation->reload();
150151
return $operation;
@@ -279,25 +280,28 @@ public static function parseName(string $formattedName, ?string $template = null
279280
/**
280281
* Constructor.
281282
*
282-
* @param array $options {
283+
* @param array|ClientOptions $options {
283284
* Optional. Options for configuring the service API wrapper.
284285
*
285286
* @type string $apiEndpoint
286287
* The address of the API remote host. May optionally include the port, formatted
287288
* as "<uri>:<port>". Default 'workflows.googleapis.com:443'.
288-
* @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
289-
* The credentials to be used by the client to authorize API calls. This option
290-
* accepts either a path to a credentials file, or a decoded credentials file as a
291-
* PHP array.
292-
* *Advanced usage*: In addition, this option can also accept a pre-constructed
293-
* {@see \Google\Auth\FetchAuthTokenInterface} object or
294-
* {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
295-
* objects are provided, any settings in $credentialsConfig will be ignored.
296-
* *Important*: If you accept a credential configuration (credential
297-
* JSON/File/Stream) from an external source for authentication to Google Cloud
298-
* Platform, you must validate it before providing it to any Google API or library.
299-
* Providing an unvalidated credential configuration to Google APIs can compromise
300-
* the security of your systems and data. For more information {@see
289+
* @type FetchAuthTokenInterface|CredentialsWrapper $credentials
290+
* This option should only be used with a pre-constructed
291+
* {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
292+
* when one of these objects are provided, any settings in $credentialsConfig will
293+
* be ignored.
294+
* **Important**: If you are providing a path to a credentials file, or a decoded
295+
* credentials file as a PHP array, this usage is now DEPRECATED. Providing an
296+
* unvalidated credential configuration to Google APIs can compromise the security
297+
* of your systems and data. It is recommended to create the credentials explicitly
298+
* ```
299+
* use Google\Auth\Credentials\ServiceAccountCredentials;
300+
* use Google\Cloud\Workflows\V1\WorkflowsClient;
301+
* $creds = new ServiceAccountCredentials($scopes, $json);
302+
* $options = new WorkflowsClient(['credentials' => $creds]);
303+
* ```
304+
* {@see
301305
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
302306
* @type array $credentialsConfig
303307
* Options used to configure credentials, including auth token caching, for the
@@ -335,11 +339,13 @@ public static function parseName(string $formattedName, ?string $template = null
335339
* @type false|LoggerInterface $logger
336340
* A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
337341
* 'GOOGLE_SDK_PHP_LOGGING' environment flag
342+
* @type string $universeDomain
343+
* The service domain for the client. Defaults to 'googleapis.com'.
338344
* }
339345
*
340346
* @throws ValidationException
341347
*/
342-
public function __construct(array $options = [])
348+
public function __construct(array|ClientOptions $options = [])
343349
{
344350
$clientOptions = $this->buildClientOptions($options);
345351
$this->setClientOptions($clientOptions);
@@ -376,7 +382,7 @@ public function __call($method, $args)
376382
* {@see RetrySettings} for example usage.
377383
* }
378384
*
379-
* @return OperationResponse
385+
* @return OperationResponse<Workflow>
380386
*
381387
* @throws ApiException Thrown if the API call fails.
382388
*/
@@ -404,7 +410,7 @@ public function createWorkflow(CreateWorkflowRequest $request, array $callOption
404410
* {@see RetrySettings} for example usage.
405411
* }
406412
*
407-
* @return OperationResponse
413+
* @return OperationResponse<null>
408414
*
409415
* @throws ApiException Thrown if the API call fails.
410416
*/
@@ -513,7 +519,7 @@ public function listWorkflows(ListWorkflowsRequest $request, array $callOptions
513519
* {@see RetrySettings} for example usage.
514520
* }
515521
*
516-
* @return OperationResponse
522+
* @return OperationResponse<Workflow>
517523
*
518524
* @throws ApiException Thrown if the API call fails.
519525
*/

0 commit comments

Comments
 (0)