Skip to content

Commit 7bb75d4

Browse files
feat: [Many APIs] usage deprecation of credentials client option (#8597)
* 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: eyJwIjoiQXNzZXQvLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiQXNzdXJlZFdvcmtsb2Fkcy8uT3dsQm90LnlhbWwiLCJoIjoiNTc3ZWVlOTMxYjczZTkxMGZmYWUxYjE3MGY2ZjlmOGJkNzk3NWEzNiJ9 Copy-Tag: eyJwIjoiQXV0b01sLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiMTcwZjZmOWY4YmQ3OTc1YTM2In0= Copy-Tag: eyJwIjoiQmFja3VwRHIvLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiQmFyZU1ldGFsU29sdXRpb24vLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiQmF0Y2gvLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiQmV5b25kQ29ycEFwcENvbm5lY3Rpb25zLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiMTcwZjZmOWY4YmQ3OTc1YTM2In0= Copy-Tag: eyJwIjoiQmV5b25kQ29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VHJhbnNmZXIvLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiQmlnUXVlcnlNaWdyYXRpb24vLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== Copy-Tag: eyJwIjoiQmlnUXVlcnlSZXNlcnZhdGlvbi8uT3dsQm90LnlhbWwiLCJoIjoiNTc3ZWVlOTMxYjczZTkxMGZmYWUxYjE3MGY2ZjlmOGJkNzk3NWEzNiJ9 Copy-Tag: eyJwIjoiQmlnUXVlcnlTdG9yYWdlLy5Pd2xCb3QueWFtbCIsImgiOiI1NzdlZWU5MzFiNzNlOTEwZmZhZTFiMTcwZjZmOWY4YmQ3OTc1YTM2In0= Copy-Tag: eyJwIjoiQmlndGFibGUvLk93bEJvdC55YW1sIiwiaCI6IjU3N2VlZTkzMWI3M2U5MTBmZmFlMWIxNzBmNmY5ZjhiZDc5NzVhMzYifQ== * 🦉 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: eyJwIjoiQXNzZXQvLk93bEJvdC55YW1sIiwiaCI6Ijk2Y2ZlZTE2MzkzNjhlMzRhOGQxZjc2NWNlZGRlY2Y5ZGNhMTE5ZGMifQ== Copy-Tag: eyJwIjoiQXNzdXJlZFdvcmtsb2Fkcy8uT3dsQm90LnlhbWwiLCJoIjoiOTZjZmVlMTYzOTM2OGUzNGE4ZDFmNzY1Y2VkZGVjZjlkY2ExMTlkYyJ9 Copy-Tag: eyJwIjoiQXV0b01sLy5Pd2xCb3QueWFtbCIsImgiOiI5NmNmZWUxNjM5MzY4ZTM0YThkMWY3NjVj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yJwIjoiQmlndGFibGUvLk93bEJvdC55YW1sIiwiaCI6Ijk2Y2ZlZTE2MzkzNjhlMzRhOGQxZjc2NWNlZGRlY2Y5ZGNhMTE5ZGMifQ== * 🦉 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 8e899d0 commit 7bb75d4

25 files changed

Lines changed: 886 additions & 932 deletions

File tree

Asset/src/V1/Client/AssetServiceClient.php

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
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;
3435
use Google\ApiCore\Transport\TransportInterface;
3536
use Google\ApiCore\ValidationException;
3637
use Google\Auth\FetchAuthTokenInterface;
3738
use Google\Cloud\Asset\V1\AnalyzeIamPolicyLongrunningRequest;
39+
use Google\Cloud\Asset\V1\AnalyzeIamPolicyLongrunningResponse;
3840
use Google\Cloud\Asset\V1\AnalyzeIamPolicyRequest;
3941
use Google\Cloud\Asset\V1\AnalyzeIamPolicyResponse;
4042
use Google\Cloud\Asset\V1\AnalyzeMoveRequest;
@@ -51,6 +53,7 @@
5153
use Google\Cloud\Asset\V1\DeleteFeedRequest;
5254
use Google\Cloud\Asset\V1\DeleteSavedQueryRequest;
5355
use Google\Cloud\Asset\V1\ExportAssetsRequest;
56+
use Google\Cloud\Asset\V1\ExportAssetsResponse;
5457
use Google\Cloud\Asset\V1\Feed;
5558
use Google\Cloud\Asset\V1\GetFeedRequest;
5659
use Google\Cloud\Asset\V1\GetSavedQueryRequest;
@@ -130,7 +133,9 @@ final class AssetServiceClient
130133
private const CODEGEN_NAME = 'gapic';
131134

132135
/** The default scopes required by the service. */
133-
public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform'];
136+
public static $serviceScopes = [
137+
'https://www.googleapis.com/auth/cloud-platform',
138+
];
134139

135140
private $operationsClient;
136141

@@ -176,9 +181,7 @@ public function getOperationsClient()
176181
*/
177182
public function resumeOperation($operationName, $methodName = null)
178183
{
179-
$options = isset($this->descriptors[$methodName]['longRunning'])
180-
? $this->descriptors[$methodName]['longRunning']
181-
: [];
184+
$options = $this->descriptors[$methodName]['longRunning'] ?? [];
182185
$operation = new OperationResponse($operationName, $this->getOperationsClient(), $options);
183186
$operation->reload();
184187
return $operation;
@@ -421,25 +424,28 @@ public static function parseName(string $formattedName, ?string $template = null
421424
/**
422425
* Constructor.
423426
*
424-
* @param array $options {
427+
* @param array|ClientOptions $options {
425428
* Optional. Options for configuring the service API wrapper.
426429
*
427430
* @type string $apiEndpoint
428431
* The address of the API remote host. May optionally include the port, formatted
429432
* as "<uri>:<port>". Default 'cloudasset.googleapis.com:443'.
430-
* @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
431-
* The credentials to be used by the client to authorize API calls. This option
432-
* accepts either a path to a credentials file, or a decoded credentials file as a
433-
* PHP array.
434-
* *Advanced usage*: In addition, this option can also accept a pre-constructed
435-
* {@see \Google\Auth\FetchAuthTokenInterface} object or
436-
* {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
437-
* objects are provided, any settings in $credentialsConfig will be ignored.
438-
* *Important*: If you accept a credential configuration (credential
439-
* JSON/File/Stream) from an external source for authentication to Google Cloud
440-
* Platform, you must validate it before providing it to any Google API or library.
441-
* Providing an unvalidated credential configuration to Google APIs can compromise
442-
* the security of your systems and data. For more information {@see
433+
* @type FetchAuthTokenInterface|CredentialsWrapper $credentials
434+
* This option should only be used with a pre-constructed
435+
* {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
436+
* when one of these objects are provided, any settings in $credentialsConfig will
437+
* be ignored.
438+
* **Important**: If you are providing a path to a credentials file, or a decoded
439+
* credentials file as a PHP array, this usage is now DEPRECATED. Providing an
440+
* unvalidated credential configuration to Google APIs can compromise the security
441+
* of your systems and data. It is recommended to create the credentials explicitly
442+
* ```
443+
* use Google\Auth\Credentials\ServiceAccountCredentials;
444+
* use Google\Cloud\Asset\V1\AssetServiceClient;
445+
* $creds = new ServiceAccountCredentials($scopes, $json);
446+
* $options = new AssetServiceClient(['credentials' => $creds]);
447+
* ```
448+
* {@see
443449
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
444450
* @type array $credentialsConfig
445451
* Options used to configure credentials, including auth token caching, for the
@@ -477,11 +483,13 @@ public static function parseName(string $formattedName, ?string $template = null
477483
* @type false|LoggerInterface $logger
478484
* A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
479485
* 'GOOGLE_SDK_PHP_LOGGING' environment flag
486+
* @type string $universeDomain
487+
* The service domain for the client. Defaults to 'googleapis.com'.
480488
* }
481489
*
482490
* @throws ValidationException
483491
*/
484-
public function __construct(array $options = [])
492+
public function __construct(array|ClientOptions $options = [])
485493
{
486494
$clientOptions = $this->buildClientOptions($options);
487495
$this->setClientOptions($clientOptions);
@@ -521,10 +529,8 @@ public function __call($method, $args)
521529
*
522530
* @throws ApiException Thrown if the API call fails.
523531
*/
524-
public function analyzeIamPolicy(
525-
AnalyzeIamPolicyRequest $request,
526-
array $callOptions = []
527-
): AnalyzeIamPolicyResponse {
532+
public function analyzeIamPolicy(AnalyzeIamPolicyRequest $request, array $callOptions = []): AnalyzeIamPolicyResponse
533+
{
528534
return $this->startApiCall('AnalyzeIamPolicy', $request, $callOptions)->wait();
529535
}
530536

@@ -555,14 +561,12 @@ public function analyzeIamPolicy(
555561
* {@see RetrySettings} for example usage.
556562
* }
557563
*
558-
* @return OperationResponse
564+
* @return OperationResponse<AnalyzeIamPolicyLongrunningResponse>
559565
*
560566
* @throws ApiException Thrown if the API call fails.
561567
*/
562-
public function analyzeIamPolicyLongrunning(
563-
AnalyzeIamPolicyLongrunningRequest $request,
564-
array $callOptions = []
565-
): OperationResponse {
568+
public function analyzeIamPolicyLongrunning(AnalyzeIamPolicyLongrunningRequest $request, array $callOptions = []): OperationResponse
569+
{
566570
return $this->startApiCall('AnalyzeIamPolicyLongrunning', $request, $callOptions)->wait();
567571
}
568572

@@ -692,10 +696,8 @@ public function analyzeOrgPolicies(AnalyzeOrgPoliciesRequest $request, array $ca
692696
*
693697
* @throws ApiException Thrown if the API call fails.
694698
*/
695-
public function analyzeOrgPolicyGovernedAssets(
696-
AnalyzeOrgPolicyGovernedAssetsRequest $request,
697-
array $callOptions = []
698-
): PagedListResponse {
699+
public function analyzeOrgPolicyGovernedAssets(AnalyzeOrgPolicyGovernedAssetsRequest $request, array $callOptions = []): PagedListResponse
700+
{
699701
return $this->startApiCall('AnalyzeOrgPolicyGovernedAssets', $request, $callOptions);
700702
}
701703

@@ -722,10 +724,8 @@ public function analyzeOrgPolicyGovernedAssets(
722724
*
723725
* @throws ApiException Thrown if the API call fails.
724726
*/
725-
public function analyzeOrgPolicyGovernedContainers(
726-
AnalyzeOrgPolicyGovernedContainersRequest $request,
727-
array $callOptions = []
728-
): PagedListResponse {
727+
public function analyzeOrgPolicyGovernedContainers(AnalyzeOrgPolicyGovernedContainersRequest $request, array $callOptions = []): PagedListResponse
728+
{
729729
return $this->startApiCall('AnalyzeOrgPolicyGovernedContainers', $request, $callOptions);
730730
}
731731

@@ -756,10 +756,8 @@ public function analyzeOrgPolicyGovernedContainers(
756756
*
757757
* @throws ApiException Thrown if the API call fails.
758758
*/
759-
public function batchGetAssetsHistory(
760-
BatchGetAssetsHistoryRequest $request,
761-
array $callOptions = []
762-
): BatchGetAssetsHistoryResponse {
759+
public function batchGetAssetsHistory(BatchGetAssetsHistoryRequest $request, array $callOptions = []): BatchGetAssetsHistoryResponse
760+
{
763761
return $this->startApiCall('BatchGetAssetsHistory', $request, $callOptions)->wait();
764762
}
765763

@@ -785,10 +783,8 @@ public function batchGetAssetsHistory(
785783
*
786784
* @throws ApiException Thrown if the API call fails.
787785
*/
788-
public function batchGetEffectiveIamPolicies(
789-
BatchGetEffectiveIamPoliciesRequest $request,
790-
array $callOptions = []
791-
): BatchGetEffectiveIamPoliciesResponse {
786+
public function batchGetEffectiveIamPolicies(BatchGetEffectiveIamPoliciesRequest $request, array $callOptions = []): BatchGetEffectiveIamPoliciesResponse
787+
{
792788
return $this->startApiCall('BatchGetEffectiveIamPolicies', $request, $callOptions)->wait();
793789
}
794790

@@ -920,7 +916,7 @@ public function deleteSavedQuery(DeleteSavedQueryRequest $request, array $callOp
920916
* {@see RetrySettings} for example usage.
921917
* }
922918
*
923-
* @return OperationResponse
919+
* @return OperationResponse<ExportAssetsResponse>
924920
*
925921
* @throws ApiException Thrown if the API call fails.
926922
*/
@@ -1121,10 +1117,8 @@ public function queryAssets(QueryAssetsRequest $request, array $callOptions = []
11211117
*
11221118
* @throws ApiException Thrown if the API call fails.
11231119
*/
1124-
public function searchAllIamPolicies(
1125-
SearchAllIamPoliciesRequest $request,
1126-
array $callOptions = []
1127-
): PagedListResponse {
1120+
public function searchAllIamPolicies(SearchAllIamPoliciesRequest $request, array $callOptions = []): PagedListResponse
1121+
{
11281122
return $this->startApiCall('SearchAllIamPolicies', $request, $callOptions);
11291123
}
11301124

AssuredWorkloads/src/V1/Client/AssuredWorkloadsServiceClient.php

Lines changed: 33 additions & 36 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;
@@ -98,7 +99,9 @@ final class AssuredWorkloadsServiceClient
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 $operationsClient;
104107

@@ -115,8 +118,7 @@ private static function getClientDefaults()
115118
],
116119
'transportConfig' => [
117120
'rest' => [
118-
'restClientConfigPath' =>
119-
__DIR__ . '/../resources/assured_workloads_service_rest_client_config.php',
121+
'restClientConfigPath' => __DIR__ . '/../resources/assured_workloads_service_rest_client_config.php',
120122
],
121123
],
122124
];
@@ -145,9 +147,7 @@ public function getOperationsClient()
145147
*/
146148
public function resumeOperation($operationName, $methodName = null)
147149
{
148-
$options = isset($this->descriptors[$methodName]['longRunning'])
149-
? $this->descriptors[$methodName]['longRunning']
150-
: [];
150+
$options = $this->descriptors[$methodName]['longRunning'] ?? [];
151151
$operation = new OperationResponse($operationName, $this->getOperationsClient(), $options);
152152
$operation->reload();
153153
return $operation;
@@ -200,12 +200,8 @@ public static function locationName(string $organization, string $location): str
200200
*
201201
* @return string The formatted violation resource.
202202
*/
203-
public static function violationName(
204-
string $organization,
205-
string $location,
206-
string $workload,
207-
string $violation
208-
): string {
203+
public static function violationName(string $organization, string $location, string $workload, string $violation): string
204+
{
209205
return self::getPathTemplate('violation')->render([
210206
'organization' => $organization,
211207
'location' => $location,
@@ -262,25 +258,28 @@ public static function parseName(string $formattedName, ?string $template = null
262258
/**
263259
* Constructor.
264260
*
265-
* @param array $options {
261+
* @param array|ClientOptions $options {
266262
* Optional. Options for configuring the service API wrapper.
267263
*
268264
* @type string $apiEndpoint
269265
* The address of the API remote host. May optionally include the port, formatted
270266
* as "<uri>:<port>". Default 'assuredworkloads.googleapis.com:443'.
271-
* @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
272-
* The credentials to be used by the client to authorize API calls. This option
273-
* accepts either a path to a credentials file, or a decoded credentials file as a
274-
* PHP array.
275-
* *Advanced usage*: In addition, this option can also accept a pre-constructed
276-
* {@see \Google\Auth\FetchAuthTokenInterface} object or
277-
* {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
278-
* objects are provided, any settings in $credentialsConfig will be ignored.
279-
* *Important*: If you accept a credential configuration (credential
280-
* JSON/File/Stream) from an external source for authentication to Google Cloud
281-
* Platform, you must validate it before providing it to any Google API or library.
282-
* Providing an unvalidated credential configuration to Google APIs can compromise
283-
* the security of your systems and data. For more information {@see
267+
* @type FetchAuthTokenInterface|CredentialsWrapper $credentials
268+
* This option should only be used with a pre-constructed
269+
* {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
270+
* when one of these objects are provided, any settings in $credentialsConfig will
271+
* be ignored.
272+
* **Important**: If you are providing a path to a credentials file, or a decoded
273+
* credentials file as a PHP array, this usage is now DEPRECATED. Providing an
274+
* unvalidated credential configuration to Google APIs can compromise the security
275+
* of your systems and data. It is recommended to create the credentials explicitly
276+
* ```
277+
* use Google\Auth\Credentials\ServiceAccountCredentials;
278+
* use Google\Cloud\AssuredWorkloads\V1\AssuredWorkloadsServiceClient;
279+
* $creds = new ServiceAccountCredentials($scopes, $json);
280+
* $options = new AssuredWorkloadsServiceClient(['credentials' => $creds]);
281+
* ```
282+
* {@see
284283
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
285284
* @type array $credentialsConfig
286285
* Options used to configure credentials, including auth token caching, for the
@@ -318,11 +317,13 @@ public static function parseName(string $formattedName, ?string $template = null
318317
* @type false|LoggerInterface $logger
319318
* A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
320319
* 'GOOGLE_SDK_PHP_LOGGING' environment flag
320+
* @type string $universeDomain
321+
* The service domain for the client. Defaults to 'googleapis.com'.
321322
* }
322323
*
323324
* @throws ValidationException
324325
*/
325-
public function __construct(array $options = [])
326+
public function __construct(array|ClientOptions $options = [])
326327
{
327328
$clientOptions = $this->buildClientOptions($options);
328329
$this->setClientOptions($clientOptions);
@@ -365,10 +366,8 @@ public function __call($method, $args)
365366
*
366367
* @throws ApiException Thrown if the API call fails.
367368
*/
368-
public function acknowledgeViolation(
369-
AcknowledgeViolationRequest $request,
370-
array $callOptions = []
371-
): AcknowledgeViolationResponse {
369+
public function acknowledgeViolation(AcknowledgeViolationRequest $request, array $callOptions = []): AcknowledgeViolationResponse
370+
{
372371
return $this->startApiCall('AcknowledgeViolation', $request, $callOptions)->wait();
373372
}
374373

@@ -390,7 +389,7 @@ public function acknowledgeViolation(
390389
* {@see RetrySettings} for example usage.
391390
* }
392391
*
393-
* @return OperationResponse
392+
* @return OperationResponse<Workload>
394393
*
395394
* @throws ApiException Thrown if the API call fails.
396395
*/
@@ -563,10 +562,8 @@ public function listWorkloads(ListWorkloadsRequest $request, array $callOptions
563562
*
564563
* @throws ApiException Thrown if the API call fails.
565564
*/
566-
public function restrictAllowedResources(
567-
RestrictAllowedResourcesRequest $request,
568-
array $callOptions = []
569-
): RestrictAllowedResourcesResponse {
565+
public function restrictAllowedResources(RestrictAllowedResourcesRequest $request, array $callOptions = []): RestrictAllowedResourcesResponse
566+
{
570567
return $this->startApiCall('RestrictAllowedResources', $request, $callOptions)->wait();
571568
}
572569

0 commit comments

Comments
 (0)